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 TestDarwinLogFilterRegexCategory(darwin_log.DarwinLogTestBase):
19 mydir = lldbtest.TestBase.compute_mydir(__file__)
22 # Call super's setUp().
23 super(TestDarwinLogFilterRegexCategory, 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(TestDarwinLogFilterRegexCategory, self).tearDown()
45 # ==========================================================================
46 # category filter tests
47 # ==========================================================================
49 @decorators.skipUnlessDarwin
50 def test_filter_accept_category_full_match(self):
51 """Test that fall-through reject, accept regex single category works."""
53 ["--no-match-accepts false",
54 "--filter \"accept category regex cat2\""]
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_category_partial_match(self):
69 """Test that fall-through reject, accept regex category via partial match works."""
71 ["--no-match-accepts false",
72 "--filter \"accept category regex .+2\""]
75 # We should only see the second log message as we only accept
77 self.assertIsNotNone(self.child.match)
80 self.child.match.groups()) > 1) and (
81 self.child.match.group(2) == "cat2"),
82 "first log line should not be present, second log line "
85 @decorators.skipUnlessDarwin
86 def test_filter_reject_category_full_match(self):
87 """Test that fall-through accept, reject regex category works."""
89 ["--no-match-accepts true",
90 "--filter \"reject category regex cat1\""]
93 # We should only see the second log message as we rejected the first
94 # via category 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_reject_category_partial_match(self):
105 """Test that fall-through accept, reject regex category by partial match works."""
107 ["--no-match-accepts true",
108 "--filter \"reject category regex t1\""]
111 # We should only see the second log message as we rejected the first
112 # via category rejection.
113 self.assertIsNotNone(self.child.match)
116 self.child.match.groups()) > 1) and (
117 self.child.match.group(2) == "cat2"),
118 "first log line should not be present, second log line "
121 @decorators.skipUnlessDarwin
122 def test_filter_accept_category_second_rule(self):
123 """Test that fall-through reject, accept regex category on second rule works."""
125 ["--no-match-accepts false",
126 "--filter \"accept category regex non-existent\"",
127 "--filter \"accept category regex cat2\""
131 # We should only see the second message since we reject by default,
132 # the first filter doesn't match any, and the second filter matches
133 # the category of the second log message.
134 self.assertIsNotNone(self.child.match)
137 self.child.match.groups()) > 1) and (
138 self.child.match.group(2) == "cat2"),
139 "first log line should not be present, second log line "