aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py
blob: 44348374636d6211fe855d31d5496252c2643838 (plain) (blame)
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
"""
Test DarwinLog "source include info-level" functionality provided by the
StructuredDataDarwinLog plugin.

These tests are currently only supported when running against Darwin
targets.
"""

from __future__ import print_function

import lldb
import os
import re

from lldbsuite.test import decorators
from lldbsuite.test import lldbtest
from lldbsuite.test import darwin_log


class TestDarwinLogSourceInfo(darwin_log.DarwinLogTestBase):

    mydir = lldbtest.TestBase.compute_mydir(__file__)

    def setUp(self):
        # Call super's setUp().
        super(TestDarwinLogSourceInfo, self).setUp()

        # Source filename.
        self.source = 'main.c'

        # Output filename.
        self.exe_name = 'a.out'
        self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}

        # Locate breakpoint.
        self.line = lldbtest.line_number(self.source, '// break here')

        # Indicate we want strict-sources behavior.
        self.strict_sources = True

    def tearDown(self):
        # Shut down the process if it's still running.
        if self.child:
            self.runCmd('process kill')
            self.expect_prompt()
            self.runCmd('quit')

        # Let parent clean up
        super(TestDarwinLogSourceInfo, self).tearDown()

    # ==========================================================================
    # source include/exclude debug filter tests
    # ==========================================================================

    @decorators.skipUnlessDarwin
    @decorators.expectedFailureAll(bugnumber="rdar://27316264")
    def test_source_exclude_info_level(self):
        """Test that default excluding of info-level log messages works."""
        self.do_test([])

        # We should only see the second log message as the first is an
        # info-level message and we're not including debug-level messages.
        self.assertIsNotNone(self.child.match)
        self.assertTrue(
            (len(
                self.child.match.groups()) > 1) and (
                self.child.match.group(2) == "cat2"),
            "first log line should not be present, second log line "
            "should be")

    @decorators.skipUnlessDarwin
    def test_source_include_info_level(self):
        """Test that explicitly including info-level log messages works."""
        self.do_test(
            ["--info"]
        )

        # We should only see the second log message as the first is a
        # debug-level message and we're not including debug-level messages.
        self.assertIsNotNone(self.child.match)
        self.assertTrue((len(self.child.match.groups()) > 1) and
                        (self.child.match.group(2) == "cat1"),
                        "first log line should be present since we're "
                        "including info-level log messages")