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 TestDarwinLogFilterMatchActivityChain(darwin_log.DarwinLogTestBase):
19 mydir = lldbtest.TestBase.compute_mydir(__file__)
22 # Call super's setUp().
23 super(TestDarwinLogFilterMatchActivityChain, 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(TestDarwinLogFilterMatchActivityChain, self).tearDown()
45 # ==========================================================================
46 # activity-chain filter tests
47 # ==========================================================================
49 @decorators.skipUnlessDarwin
50 def test_filter_accept_activity_chain_match(self):
51 """Test that fall-through reject, accept full-match activity chain works."""
53 ["--no-match-accepts false",
54 "--filter \"accept activity-chain match "
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_reject_activity_chain_partial_match(self):
69 """Test that fall-through reject, doesn't accept only partial match of activity-chain."""
71 ["--no-match-accepts false",
72 # Match the second fully.
73 "--filter \"accept activity-chain match parent-activity:child-activity\"",
74 "--filter \"accept activity-chain match parent-ac\""]) # Only partially match the first.
76 # We should only see the second log message as we only accept
78 self.assertIsNotNone(self.child.match)
81 self.child.match.groups()) > 1) and (
82 self.child.match.group(2) == "cat2"),
83 "first log line should not be present, second log line "
86 @decorators.skipUnlessDarwin
87 def test_filter_reject_activity_chain_full_match(self):
88 """Test that fall-through accept, reject match activity-chain works."""
90 ["--no-match-accepts true",
91 "--filter \"reject activity-chain match parent-activity\""])
93 # We should only see the second log message as we rejected the first
94 # via activity-chain rejection.
95 self.assertIsNotNone(self.child.match)
98 self.child.match.groups()) > 1) and (
99 self.child.match.group(2) == "cat2"),
100 "first log line should not be present, second log line "
103 @decorators.skipUnlessDarwin
104 def test_filter_accept_activity_chain_second_rule(self):
105 """Test that fall-through reject, accept activity-chain on second rule works."""
107 ["--no-match-accepts false",
108 "--filter \"accept activity-chain match non-existent\"",
109 "--filter \"accept activity-chain match parent-activity:child-activity\""])
111 # We should only see the second message since we reject by default,
112 # the first filter doesn't match any, and the second filter matches
113 # the activity-chain of the second log message.
114 self.assertIsNotNone(self.child.match)
117 self.child.match.groups()) > 1) and (
118 self.child.match.group(2) == "cat2"),
119 "first log line should not be present, second log line "