]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / darwin_log / source / info / TestDarwinLogSourceInfo.py
1 """
2 Test DarwinLog "source include info-level" functionality provided by the
3 StructuredDataDarwinLog 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 TestDarwinLogSourceInfo(darwin_log.DarwinLogTestBase):
21
22     mydir = lldbtest.TestBase.compute_mydir(__file__)
23
24     def setUp(self):
25         # Call super's setUp().
26         super(TestDarwinLogSourceInfo, 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         # Indicate we want strict-sources behavior.
39         self.strict_sources = True
40
41     def tearDown(self):
42         # Shut down the process if it's still running.
43         if self.child:
44             self.runCmd('process kill')
45             self.expect_prompt()
46             self.runCmd('quit')
47
48         # Let parent clean up
49         super(TestDarwinLogSourceInfo, self).tearDown()
50
51     # ==========================================================================
52     # source include/exclude debug filter tests
53     # ==========================================================================
54
55     @decorators.skipUnlessDarwin
56     @decorators.expectedFailureAll(bugnumber="rdar://27316264")
57     def test_source_exclude_info_level(self):
58         """Test that default excluding of info-level log messages works."""
59         self.do_test([])
60
61         # We should only see the second log message as the first is an
62         # info-level message and we're not including debug-level messages.
63         self.assertIsNotNone(self.child.match)
64         self.assertTrue(
65             (len(
66                 self.child.match.groups()) > 1) and (
67                 self.child.match.group(2) == "cat2"),
68             "first log line should not be present, second log line "
69             "should be")
70
71     @decorators.skipUnlessDarwin
72     def test_source_include_info_level(self):
73         """Test that explicitly including info-level log messages works."""
74         self.do_test(
75             ["--info"]
76         )
77
78         # We should only see the second log message as the first is a
79         # debug-level message and we're not including debug-level messages.
80         self.assertIsNotNone(self.child.match)
81         self.assertTrue((len(self.child.match.groups()) > 1) and
82                         (self.child.match.group(2) == "cat1"),
83                         "first log line should be present since we're "
84                         "including info-level log messages")