1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
"""
Test basic DarwinLog functionality provided by the StructuredDataDarwinLog
plugin.
These tests are currently only supported when running against Darwin
targets.
"""
# System imports
from __future__ import print_function
import re
# LLDB imports
import lldb
from lldbsuite.test import decorators
from lldbsuite.test import lldbtest
from lldbsuite.test import darwin_log
class TestDarwinLogFilterRegexMessage(darwin_log.DarwinLogEventBasedTestBase):
mydir = lldbtest.TestBase.compute_mydir(__file__)
@decorators.skipUnlessDarwin
@decorators.expectedFailureAll(oslist=["macosx"],
bugnumber="llvm.org/pr30299")
def test_filter_accept_message_full_match(self):
"""Test that fall-through reject, accept regex whole message works."""
log_entries = self.do_test(
["--no-match-accepts false",
# Note below, the four '\' characters are to get us two
# backslashes over on the gdb-remote side, which then
# becomes one as the cstr interprets it as an escape
# sequence. This needs to be rationalized. Initially I
# supported std::regex ECMAScript, which has the
# [[:digit:]] character classes and such. That was much
# more tenable. The backslashes have to travel through
# so many layers of escaping. (And note if you take
# off the Python raw string marker here, you need to put
# in 8 backslashes to go to two on the remote side.)
r'--filter "accept message regex log message sub2-cat\\\\d+"'])
# We should have received at least one log entry.
self.assertIsNotNone(log_entries,
"Log entry list should not be None.")
self.assertEqual(len(log_entries), 1,
"Should receive one log entry.")
self.assertRegexpMatches(log_entries[0]["message"], r"sub2-cat2",
"First os_log call should have been skipped.")
@decorators.skipUnlessDarwin
@decorators.expectedFailureAll(oslist=["macosx"],
bugnumber="llvm.org/pr30299")
def test_filter_accept_message_partial_match(self):
"""Test that fall-through reject, accept regex message via partial
match works."""
log_entries = self.do_test(
["--no-match-accepts false",
"--filter \"accept message regex [^-]+2\""])
# We should only see the second log message as we only accept
# that message contents.
self.assertIsNotNone(log_entries,
"Log entry list should not be None.")
self.assertEqual(len(log_entries), 1,
"Should receive one log entry.")
self.assertRegexpMatches(log_entries[0]["message"], r"sub2-cat2",
"First os_log call should have been skipped.")
@decorators.skipUnlessDarwin
@decorators.expectedFailureAll(oslist=["macosx"],
bugnumber="llvm.org/pr30299")
def test_filter_reject_message_full_match(self):
"""Test that fall-through accept, reject regex message works."""
log_entries = self.do_test(
["--no-match-accepts true",
"--filter \"reject message regex log message sub1-cat1\""])
# We should only see the second log message as we rejected the first
# via message contents rejection.
self.assertIsNotNone(log_entries,
"Log entry list should not be None.")
self.assertEqual(len(log_entries), 1,
"Should receive one log entry.")
self.assertRegexpMatches(log_entries[0]["message"], r"sub2-cat2",
"First os_log call should have been skipped.")
@decorators.skipUnlessDarwin
@decorators.expectedFailureAll(oslist=["macosx"],
bugnumber="llvm.org/pr30299")
def test_filter_reject_message_partial_match(self):
"""Test that fall-through accept, reject regex message by partial
match works."""
log_entries = self.do_test(
["--no-match-accepts true",
"--filter \"reject message regex t1\""])
# We should only see the second log message as we rejected the first
# via partial message contents rejection.
self.assertIsNotNone(log_entries,
"Log entry list should not be None.")
self.assertEqual(len(log_entries), 1,
"Should receive one log entry.")
self.assertRegexpMatches(log_entries[0]["message"], r"sub2-cat2",
"First os_log call should have been skipped.")
@decorators.skipUnlessDarwin
@decorators.expectedFailureAll(oslist=["macosx"],
bugnumber="llvm.org/pr30299")
def test_filter_accept_message_second_rule(self):
"""Test that fall-through reject, accept regex message on second rule
works."""
log_entries = self.do_test(
["--no-match-accepts false",
"--filter \"accept message regex non-existent\"",
"--filter \"accept message regex cat2\""])
# We should only see the second message since we reject by default,
# the first filter doesn't match any, and the second filter matches
# the message of the second log message.
self.assertIsNotNone(log_entries,
"Log entry list should not be None.")
self.assertEqual(len(log_entries), 1,
"Should receive one log entry.")
self.assertRegexpMatches(log_entries[0]["message"], r"sub2-cat2",
"First os_log call should have been skipped.")
|