]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/TestDarwinLogFilterRegexActivity.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / darwin_log / filter / regex / activity / TestDarwinLogFilterRegexActivity.py
1 """
2 Test basic DarwinLog functionality provided by the StructuredDataDarwinLog
3 plugin.
4
5 These tests are currently only supported when running against Darwin
6 targets.
7 """
8
9 from __future__ import print_function
10
11 import lldb
12 import os
13 import re
14
15 from lldbsuite.test import decorators
16 from lldbsuite.test import lldbtest
17 from lldbsuite.test import darwin_log
18
19
20 class TestDarwinLogFilterRegexActivity(darwin_log.DarwinLogTestBase):
21
22     mydir = lldbtest.TestBase.compute_mydir(__file__)
23
24     def setUp(self):
25         # Call super's setUp().
26         super(TestDarwinLogFilterRegexActivity, self).setUp()
27
28         # Source filename.
29         self.source = 'main.c'
30
31         # Output filename.
32         self.exe_name = 'a.out'
33         self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
34
35         # Locate breakpoint.
36         self.line = lldbtest.line_number(self.source, '// break here')
37
38     def tearDown(self):
39         # Shut down the process if it's still running.
40         if self.child:
41             self.runCmd('process kill')
42             self.expect_prompt()
43             self.runCmd('quit')
44
45         # Let parent clean up
46         super(TestDarwinLogFilterRegexActivity, self).tearDown()
47
48     # ==========================================================================
49     # activity filter tests
50     # ==========================================================================
51
52     @decorators.skipUnlessDarwin
53     def test_filter_accept_activity_full_match(self):
54         """Test that fall-through reject, accept regex full-match activity works."""
55         self.do_test(
56             ["--no-match-accepts false",
57              "--filter \"accept activity regex child-activity\""]
58         )
59
60         # We should only see the second log message as we only accept
61         # that activity.
62         self.assertIsNotNone(self.child.match)
63         self.assertTrue(
64             (len(
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 "
68             "should be")
69
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."""
73         self.do_test(
74             ["--no-match-accepts false",
75              "--filter \"accept activity regex child-.*\""]
76         )
77
78         # We should only see the second log message as we only accept
79         # that activity.
80         self.assertIsNotNone(self.child.match)
81         self.assertTrue(
82             (len(
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 "
86             "should be")
87
88     @decorators.skipUnlessDarwin
89     def test_filter_reject_activity_full_match(self):
90         """Test that fall-through accept, reject regex activity works."""
91         self.do_test(
92             ["--no-match-accepts true",
93              "--filter \"reject activity regex parent-activity\""]
94         )
95
96         # We should only see the second log message as we rejected the first
97         # via activity rejection.
98         self.assertIsNotNone(self.child.match)
99         self.assertTrue(
100             (len(
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 "
104             "should be")
105
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."""
109         self.do_test(
110             ["--no-match-accepts true",
111              "--filter \"reject activity regex p.+-activity\""]
112         )
113
114         # We should only see the second log message as we rejected the first
115         # via activity rejection.
116         self.assertIsNotNone(self.child.match)
117         self.assertTrue(
118             (len(
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 "
122             "should be")
123
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."""
127         self.do_test(
128             ["--no-match-accepts false",
129              "--filter \"accept activity regex non-existent\"",
130              "--filter \"accept activity regex child-activity\""
131              ]
132         )
133
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)
138         self.assertTrue(
139             (len(
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 "
143             "should be")