2 Test basic DarwinLog functionality provided by the StructuredDataDarwinLog
5 These tests are currently only supported when running against Darwin
9 from __future__ import print_function
15 from lldbsuite.test import decorators
16 from lldbsuite.test import lldbtest
17 from lldbsuite.test import darwin_log
20 class TestDarwinLogFilterRegexActivity(darwin_log.DarwinLogTestBase):
22 mydir = lldbtest.TestBase.compute_mydir(__file__)
25 # Call super's setUp().
26 super(TestDarwinLogFilterRegexActivity, self).setUp()
29 self.source = 'main.c'
32 self.exe_name = 'a.out'
33 self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
36 self.line = lldbtest.line_number(self.source, '// break here')
39 # Shut down the process if it's still running.
41 self.runCmd('process kill')
46 super(TestDarwinLogFilterRegexActivity, self).tearDown()
48 # ==========================================================================
49 # activity filter tests
50 # ==========================================================================
52 @decorators.skipUnlessDarwin
53 def test_filter_accept_activity_full_match(self):
54 """Test that fall-through reject, accept regex full-match activity works."""
56 ["--no-match-accepts false",
57 "--filter \"accept activity regex child-activity\""]
60 # We should only see the second log message as we only accept
62 self.assertIsNotNone(self.child.match)
65 self.child.match.groups()) > 1) and (
66 self.child.match.group(2) == "cat2"),
67 "first log line should not be present, second log line "
70 @decorators.skipUnlessDarwin
71 def test_filter_accept_activity_partial_match(self):
72 """Test that fall-through reject, regex accept activity via partial match works."""
74 ["--no-match-accepts false",
75 "--filter \"accept activity regex child-.*\""]
78 # We should only see the second log message as we only accept
80 self.assertIsNotNone(self.child.match)
83 self.child.match.groups()) > 1) and (
84 self.child.match.group(2) == "cat2"),
85 "first log line should not be present, second log line "
88 @decorators.skipUnlessDarwin
89 def test_filter_reject_activity_full_match(self):
90 """Test that fall-through accept, reject regex activity works."""
92 ["--no-match-accepts true",
93 "--filter \"reject activity regex parent-activity\""]
96 # We should only see the second log message as we rejected the first
97 # via activity rejection.
98 self.assertIsNotNone(self.child.match)
101 self.child.match.groups()) > 1) and (
102 self.child.match.group(2) == "cat2"),
103 "first log line should not be present, second log line "
106 @decorators.skipUnlessDarwin
107 def test_filter_reject_activity_partial_match(self):
108 """Test that fall-through accept, reject regex activity by partial match works."""
110 ["--no-match-accepts true",
111 "--filter \"reject activity regex p.+-activity\""]
114 # We should only see the second log message as we rejected the first
115 # via activity 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 def test_filter_accept_activity_second_rule(self):
126 """Test that fall-through reject, accept regex activity on second rule works."""
128 ["--no-match-accepts false",
129 "--filter \"accept activity regex non-existent\"",
130 "--filter \"accept activity regex child-activity\""
134 # We should only see the second message since we reject by default,
135 # the first filter doesn't match any, and the second filter matches
136 # the activity of the second log message.
137 self.assertIsNotNone(self.child.match)
140 self.child.match.groups()) > 1) and (
141 self.child.match.group(2) == "cat2"),
142 "first log line should not be present, second log line "