57 lines · python
1"""2Test lldb log handlers.3"""4 5import os6import lldb7from lldbsuite.test.decorators import *8from lldbsuite.test.lldbtest import *9from lldbsuite.test import lldbutil10 11 12class LogHandlerTestCase(TestBase):13 NO_DEBUG_INFO_TESTCASE = True14 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)20 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))25 26 with open(self.log_file, "r") as f:27 log_lines = f.readlines()28 29 self.assertEqual(len(log_lines), 5)30 31 found_command_log_dump = False32 found_command_bogus = False33 34 for line in log_lines:35 if "Processing command: log dump" in line:36 found_command_log_dump = True37 if "Processing command: bogus" in line:38 found_command_bogus = True39 40 self.assertTrue(found_command_log_dump)41 self.assertFalse(found_command_bogus)42 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"],48 )49 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"],56 )57