2 Test basic DarwinLog functionality provided by the StructuredDataDarwinLog
5 These tests are currently only supported when running against Darwin
13 from lldbsuite.test import decorators
14 from lldbsuite.test import lldbtest
15 from lldbsuite.test import darwin_log
18 class TestDarwinLogFilterMatchMessage(darwin_log.DarwinLogTestBase):
20 mydir = lldbtest.TestBase.compute_mydir(__file__)
23 # Call super's setUp().
24 super(TestDarwinLogFilterMatchMessage, self).setUp()
27 self.source = 'main.c'
30 self.exe_name = self.getBuildArtifact("a.out")
31 self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
34 self.line = lldbtest.line_number(self.source, '// break here')
36 self.strict_sources = True
38 # Turn on process monitor logging while we work out issues.
39 self.enable_process_monitor_logging = True
42 # Shut down the process if it's still running.
44 self.runCmd('process kill')
49 super(TestDarwinLogFilterMatchMessage, self).tearDown()
51 # ==========================================================================
52 # category filter tests
53 # ==========================================================================
56 re.compile(r"log message ([^-]+)-(\S+)"),
57 re.compile(r"exited with status")
60 @decorators.skipUnlessDarwin
61 @decorators.expectedFailureAll(oslist=["macosx"],
62 bugnumber="llvm.org/pr30299")
63 def test_filter_accept_message_full_match(self):
64 """Test that fall-through reject, accept match whole message works."""
66 ["--no-match-accepts false",
67 "--filter \"accept message match log message sub2-cat2\""],
68 expect_regexes=self.EXPECT_REGEXES
71 # We should only see the second log message as we only accept
72 # that message contents.
73 self.assertIsNotNone(self.child.match)
76 self.child.match.groups()) > 1) and (
77 self.child.match.group(2) == "cat2"),
78 "first log line should not be present, second log line "
81 @decorators.skipUnlessDarwin
82 @decorators.expectedFailureAll(oslist=["macosx"],
83 bugnumber="llvm.org/pr30299")
84 def test_filter_no_accept_message_partial_match(self):
85 """Test that fall-through reject, match message via partial content match doesn't accept."""
87 ["--no-match-accepts false",
88 "--filter \"accept message match log message sub2-cat2\"",
89 "--filter \"accept message match sub1-cat1\""],
90 expect_regexes=self.EXPECT_REGEXES
93 # We should only see the second log message as the partial match on
94 # the first message should not pass.
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 @decorators.expectedFailureAll(oslist=["macosx"],
105 bugnumber="llvm.org/pr30299")
106 def test_filter_reject_category_full_match(self):
107 """Test that fall-through accept, reject match message works."""
109 ["--no-match-accepts true",
110 "--filter \"reject message match log message sub1-cat1\""],
111 expect_regexes=self.EXPECT_REGEXES
114 # We should only see the second log message as we rejected the first
115 # via message contents rejection.
116 self.assertIsNotNone(self.child.match)
119 self.child.match.groups()) > 1) and (
120 self.child.match.group(2) == "cat2"),
121 "first log line should not be present, second log line "
124 @decorators.skipUnlessDarwin
125 @decorators.expectedFailureAll(oslist=["macosx"],
126 bugnumber="llvm.org/pr30299")
127 def test_filter_accept_category_second_rule(self):
128 """Test that fall-through reject, accept match category on second rule works."""
130 ["--no-match-accepts false",
131 "--filter \"accept message match non-existent\"",
132 "--filter \"accept message match log message sub2-cat2\""],
133 expect_regexes=self.EXPECT_REGEXES
136 # We should only see the second message since we reject by default,
137 # the first filter doesn't match any, and the second filter matches
138 # the category of the second log message.
139 self.assertIsNotNone(self.child.match)
142 self.child.match.groups()) > 1) and (
143 self.child.match.group(2) == "cat2"),
144 "first log line should not be present, second log line "