Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / commands / log / basic / TestLogHandlers.py
blob74b6264dd6a4795f1eedae9adf267a5eecfc4dfe
1 """
2 Test lldb log handlers.
3 """
5 import os
6 import lldb
7 from lldbsuite.test.decorators import *
8 from lldbsuite.test.lldbtest import *
9 from lldbsuite.test import lldbutil
12 class LogHandlerTestCase(TestBase):
13 NO_DEBUG_INFO_TESTCASE = True
15 def setUp(self):
16 TestBase.setUp(self)
17 self.log_file = self.getBuildArtifact("log-file.txt")
18 if os.path.exists(self.log_file):
19 os.remove(self.log_file)
21 def test_circular(self):
22 self.runCmd("log enable -b 5 -h circular lldb commands")
23 self.runCmd("bogus", check=False)
24 self.runCmd("log dump lldb -f {}".format(self.log_file))
26 with open(self.log_file, "r") as f:
27 log_lines = f.readlines()
29 self.assertEqual(len(log_lines), 5)
31 found_command_log_dump = False
32 found_command_bogus = False
34 for line in log_lines:
35 if "Processing command: log dump" in line:
36 found_command_log_dump = True
37 if "Processing command: bogus" in line:
38 found_command_bogus = True
40 self.assertTrue(found_command_log_dump)
41 self.assertFalse(found_command_bogus)
43 def test_circular_no_buffer_size(self):
44 self.expect(
45 "log enable -h circular lldb commands",
46 error=True,
47 substrs=["the circular buffer handler requires a non-zero buffer size"],
50 def test_dump_unsupported(self):
51 self.runCmd("log enable lldb commands -f {}".format(self.log_file))
52 self.expect(
53 "log dump lldb",
54 error=True,
55 substrs=["log channel 'lldb' does not support dumping"],