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 TestDarwinLogFilterMatchCategory(darwin_log.DarwinLogTestBase):
19 mydir = lldbtest.TestBase.compute_mydir(__file__)
22 # Call super's setUp().
23 super(TestDarwinLogFilterMatchCategory, 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(TestDarwinLogFilterMatchCategory, 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 match single category works."""
53 ["--no-match-accepts false",
54 "--filter \"accept category match 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_reject_category_partial_match(self):
69 """Test that fall-through reject, accept regex category via partial match works."""
71 ["--no-match-accepts false",
72 # Fully match the second message.
73 "--filter \"accept category match cat2\"",
74 "--filter \"accept category match at1\""] # Only partially match first message. Should not show up.
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_category_full_match(self):
89 """Test that fall-through accept, reject match category works."""
91 ["--no-match-accepts true",
92 "--filter \"reject category match cat1\""]
95 # We should only see the second log message as we rejected the first
96 # via category 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_category_second_rule(self):
107 """Test that fall-through reject, accept match category on second rule works."""
109 ["--no-match-accepts false",
110 "--filter \"accept category match non-existent\"",
111 "--filter \"accept category match cat2\""
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 category 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 "