File: TestLogHandlers.py

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (56 lines) | stat: -rw-r--r-- 1,666 bytes parent folder | download | duplicates (10)
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
"""
Test lldb log handlers.
"""

import os
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class LogHandlerTestCase(TestBase):
    NO_DEBUG_INFO_TESTCASE = True

    def setUp(self):
        TestBase.setUp(self)
        self.log_file = self.getBuildArtifact("log-file.txt")
        if os.path.exists(self.log_file):
            os.remove(self.log_file)

    def test_circular(self):
        self.runCmd("log enable -b 5 -h circular lldb commands")
        self.runCmd("bogus", check=False)
        self.runCmd("log dump lldb -f {}".format(self.log_file))

        with open(self.log_file, "r") as f:
            log_lines = f.readlines()

        self.assertEqual(len(log_lines), 5)

        found_command_log_dump = False
        found_command_bogus = False

        for line in log_lines:
            if "Processing command: log dump" in line:
                found_command_log_dump = True
            if "Processing command: bogus" in line:
                found_command_bogus = True

        self.assertTrue(found_command_log_dump)
        self.assertFalse(found_command_bogus)

    def test_circular_no_buffer_size(self):
        self.expect(
            "log enable -h circular lldb commands",
            error=True,
            substrs=["the circular buffer handler requires a non-zero buffer size"],
        )

    def test_dump_unsupported(self):
        self.runCmd("log enable lldb commands -f {}".format(self.log_file))
        self.expect(
            "log dump lldb",
            error=True,
            substrs=["log channel 'lldb' does not support dumping"],
        )