2 Test basic DarwinLog functionality provided by the StructuredDataDarwinLog
5 These tests are currently only supported when running against Darwin
12 from lldbsuite.test import decorators
13 from lldbsuite.test import lldbtest
14 from lldbsuite.test import darwin_log
17 class TestDarwinLogFilterRegexActivityChain(darwin_log.DarwinLogTestBase):
19 mydir = lldbtest.TestBase.compute_mydir(__file__)
22 # Call super's setUp().
23 super(TestDarwinLogFilterRegexActivityChain, self).setUp()
26 self.source = 'main.c'
29 self.exe_name = self.getBuildArtifact("a.out")
30 self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
33 self.line = lldbtest.line_number(self.source, '// break here')
36 # Shut down the process if it's still running.
38 self.runCmd('process kill')
43 super(TestDarwinLogFilterRegexActivityChain, self).tearDown()
45 # ==========================================================================
46 # activity-chain filter tests
47 # ==========================================================================
49 @decorators.skipUnlessDarwin
50 def test_filter_accept_activity_chain_full_match(self):
51 """Test that fall-through reject, accept full-match activity chain works."""
53 ["--no-match-accepts false",
54 "--filter \"accept activity-chain regex "
55 "parent-activity:child-activity\""])
57 # We should only see the second log message as we only accept
59 self.assertIsNotNone(self.child.match)
62 self.child.match.groups()) > 1) and (
63 self.child.match.group(2) == "cat2"),
64 "first log line should not be present, second log line "
67 @decorators.skipUnlessDarwin
68 def test_filter_accept_activity_chain_partial_match(self):
69 """Test that fall-through reject, accept activity-chain via partial match works."""
71 ["--no-match-accepts false",
72 "--filter \"accept activity-chain regex :child-activity\""])
74 # We should only see the second log message as we only accept
76 self.assertIsNotNone(self.child.match)
79 self.child.match.groups()) > 1) and (
80 self.child.match.group(2) == "cat2"),
81 "first log line should not be present, second log line "
84 @decorators.skipUnlessDarwin
85 def test_filter_reject_activity_chain_full_match(self):
86 """Test that fall-through accept, reject activity-chain works."""
88 ["--no-match-accepts true",
89 "--filter \"reject activity-chain regex parent-activity:child-..tivity\""])
91 # We should only see the second log message as we rejected the first
92 # via activity-chain rejection.
93 self.assertIsNotNone(self.child.match)
96 self.child.match.groups()) > 1) and (
97 self.child.match.group(2) == "cat1"),
98 "first log line should not be present, second log line "
101 @decorators.skipUnlessDarwin
102 def test_filter_reject_activity_chain_partial_match(self):
103 """Test that fall-through accept, reject activity-chain by partial match works."""
105 ["--no-match-accepts true",
106 "--filter \"reject activity-chain regex ^p[^:]+$\""])
108 # We should only see the second log message as we rejected the first
109 # via activity-chain rejection.
110 self.assertIsNotNone(self.child.match)
113 self.child.match.groups()) > 1) and (
114 self.child.match.group(2) == "cat2"),
115 "first log line should not be present, second log line "
118 @decorators.skipUnlessDarwin
119 def test_filter_accept_activity_chain_second_rule(self):
120 """Test that fall-through reject, accept activity-chain on second rule works."""
122 ["--no-match-accepts false",
123 "--filter \"accept activity-chain regex non-existent\"",
124 "--filter \"accept activity-chain regex child-activity\""])
126 # We should only see the second message since we reject by default,
127 # the first filter doesn't match any, and the second filter matches
128 # the activity-chain of the second log message.
129 self.assertIsNotNone(self.child.match)
132 self.child.match.groups()) > 1) and (
133 self.child.match.group(2) == "cat2"),
134 "first log line should not be present, second log line "