]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / data-formatter / type_summary_list_script / TestTypeSummaryListScript.py
1 """
2 Test lldb data formatter subsystem.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import time
10 import lldb
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14
15
16 class TypeSummaryListScriptTestCase(TestBase):
17
18     mydir = TestBase.compute_mydir(__file__)
19
20     def test_typesummarylist_script(self):
21         """Test data formatter commands."""
22         self.build()
23         self.data_formatter_commands()
24
25     def setUp(self):
26         # Call super's setUp().
27         TestBase.setUp(self)
28         # Find the line number to break at.
29         self.line = line_number('main.cpp', 'Break here')
30
31     def data_formatter_commands(self):
32         """Test printing out Python summary formatters."""
33         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
34
35         lldbutil.run_break_set_by_file_and_line(
36             self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
37
38         self.runCmd("run", RUN_SUCCEEDED)
39
40         # The stop reason of the thread should be breakpoint.
41         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
42                     substrs=['stopped',
43                              'stop reason = breakpoint'])
44
45         # This is the function to remove the custom formats in order to have a
46         # clean slate for the next test case.
47         def cleanup():
48             self.runCmd('type category delete TSLSFormatters', check=False)
49             self.runCmd('type format clear', check=False)
50             self.runCmd('type summary clear', check=False)
51             self.runCmd('type filter clear', check=False)
52             self.runCmd('type synth clear', check=False)
53
54         self.addTearDownHook(cleanup)
55
56         self.runCmd("command script import tslsformatters.py")
57
58         self.expect(
59             "frame variable myStruct",
60             substrs=['A data formatter at work'])
61
62         self.expect('type summary list', substrs=['Struct_SummaryFormatter'])
63         self.expect(
64             'type summary list Struct',
65             substrs=['Struct_SummaryFormatter'])