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 TestDarwinLogFilterMatchSubsystem(darwin_log.DarwinLogTestBase):
19 mydir = lldbtest.TestBase.compute_mydir(__file__)
22 # Call super's setUp().
23 super(TestDarwinLogFilterMatchSubsystem, 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(TestDarwinLogFilterMatchSubsystem, self).tearDown()
45 # ==========================================================================
46 # subsystem filter tests
47 # ==========================================================================
49 @decorators.skipUnlessDarwin
50 def test_filter_accept_subsystem_full_match(self):
51 """Test that fall-through reject, accept match single subsystem works."""
53 ["--no-match-accepts false",
54 "--filter \"accept subsystem match org.llvm.lldb.test.sub2\""]
57 # We should only see the second log message as we only accept
59 self.assertIsNotNone(self.child.match)
62 self.child.match.groups()) > 0) and (
63 self.child.match.group(1) == "sub2"),
64 "first log line should not be present, second log line "
67 @decorators.skipUnlessDarwin
68 def test_filter_reject_subsystem_partial_match(self):
69 """Test that fall-through reject, doesn't accept match subsystem via partial-match."""
71 ["--no-match-accepts false",
72 # Fully match second message subsystem.
73 "--filter \"accept subsystem match org.llvm.lldb.test.sub2\"",
74 "--filter \"accept subsystem match sub1\""] # Only partially match first subsystem.
77 # We should only see the second log message as we only accept
79 self.assertIsNotNone(self.child.match)
82 self.child.match.groups()) > 0) and (
83 self.child.match.group(1) == "sub2"),
84 "first log line should not be present, second log line "
87 @decorators.skipUnlessDarwin
88 def test_filter_reject_subsystem_full_match(self):
89 """Test that fall-through accept, reject match subsystem works."""
91 ["--no-match-accepts true",
92 "--filter \"reject subsystem match org.llvm.lldb.test.sub1\""]
95 # We should only see the second log message as we rejected the first
96 # via subsystem rejection.
97 self.assertIsNotNone(self.child.match)
100 self.child.match.groups()) > 0) and (
101 self.child.match.group(1) == "sub2"),
102 "first log line should not be present, second log line "
105 @decorators.skipUnlessDarwin
106 def test_filter_accept_subsystem_second_rule(self):
107 """Test that fall-through reject, accept match subsystem on second rule works."""
109 ["--no-match-accepts false",
110 "--filter \"accept subsystem match non-existent\"",
111 "--filter \"accept subsystem match org.llvm.lldb.test.sub2\""
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 subsystem of the second log message.
118 self.assertIsNotNone(self.child.match)
121 self.child.match.groups()) > 0) and (
122 self.child.match.group(1) == "sub2"),
123 "first log line should not be present, second log line "