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 TestDarwinLogFilterMatchActivity(darwin_log.DarwinLogTestBase):
19 mydir = lldbtest.TestBase.compute_mydir(__file__)
22 # Call super's setUp().
23 super(TestDarwinLogFilterMatchActivity, 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(TestDarwinLogFilterMatchActivity, self).tearDown()
45 # ==========================================================================
46 # activity filter tests
47 # ==========================================================================
49 @decorators.skipUnlessDarwin
50 def test_filter_accept_activity_match(self):
51 """Test that fall-through reject, accept match activity works."""
53 ["--no-match-accepts false",
54 "--filter \"accept activity match 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_partial_match(self):
69 """Test that fall-through reject, accept match activity via partial match does not accept."""
71 ["--no-match-accepts false",
72 # Fully match second message.
73 "--filter \"accept activity match child-activity\"",
74 "--filter \"accept activity match parent-\""] # Only partially match first message.
77 # We should only see the second log message as we only accept
79 self.assertIsNotNone(self.child.match)
82 self.child.match.groups()) > 1) and (
83 self.child.match.group(2) == "cat2"),
84 "first log line should not be present, second log line "
87 @decorators.skipUnlessDarwin
88 def test_filter_reject_activity_full_match(self):
89 """Test that fall-through accept, reject match activity works."""
91 ["--no-match-accepts true",
92 "--filter \"reject activity match parent-activity\""]
95 # We should only see the second log message as we rejected the first
96 # via activity rejection.
97 self.assertIsNotNone(self.child.match)
100 self.child.match.groups()) > 1) and (
101 self.child.match.group(2) == "cat2"),
102 "first log line should not be present, second log line "
105 @decorators.skipUnlessDarwin
106 def test_filter_accept_activity_second_rule(self):
107 """Test that fall-through reject, accept regex activity on second rule works."""
109 ["--no-match-accepts false",
110 "--filter \"accept activity match non-existent\"",
111 "--filter \"accept activity match child-activity\""
115 # We should only see the second message since we reject by default,
116 # the first filter doesn't match any, and the second filter matches
117 # the activity of the second log message.
118 self.assertIsNotNone(self.child.match)
121 self.child.match.groups()) > 1) and (
122 self.child.match.group(2) == "cat2"),
123 "first log line should not be present, second log line "