Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a log dump command to dump logs to a file. This only works for channels that have a log handler associated that supports dumping. For now that's limited to the circular log handler, but more could be added in the future. Differential revision: https://reviews.llvm.org/D128557
- Loading branch information
1 parent
becbbb7
commit 9bdb7e5
Showing
7 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
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"]) |