ca57442e4528bfe933cf1645a13390dce6af61cb
[openbsd] /
1 """
2 Test lldb data formatter subsystem.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.lldbtest import *
9 import lldbsuite.test.lldbutil as lldbutil
10
11
12 class EnumFormatTestCase(TestBase):
13
14     mydir = TestBase.compute_mydir(__file__)
15
16     def setUp(self):
17         # Call super's setUp().
18         TestBase.setUp(self)
19         # Find the line number to break at.
20         self.line = line_number('main.cpp', '// Set break point at this line.')
21
22     def test_with_run_command(self):
23         """Test that that file and class static variables display correctly."""
24         self.build()
25         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
26
27         lldbutil.run_break_set_by_file_and_line(
28             self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
29
30         self.runCmd("run", RUN_SUCCEEDED)
31
32         # The stop reason of the thread should be breakpoint.
33         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
34                     substrs=['stopped',
35                              'stop reason = breakpoint'])
36
37         self.expect("frame variable",
38                     substrs=['(Foo) f = Case45',
39                              '(int) x = 1',
40                              '(int) y = 45',
41                              '(int) z = 43'
42                              ])
43
44         # This is the function to remove the custom formats in order to have a
45         # clean slate for the next test case.
46         def cleanup():
47             self.runCmd('type format clear', check=False)
48             self.runCmd('type summary clear', check=False)
49
50         # Execute the cleanup function during test case tear down.
51         self.addTearDownHook(cleanup)
52
53         self.runCmd("type format add --type Foo int")
54
55         # The type format list should show our custom formats.
56         self.expect("type format list -w default",
57                     substrs=['int: as type Foo'])
58
59         self.expect("frame variable",
60                     substrs=['(Foo) f = Case45',
61                              '(int) x = Case1',
62                              '(int) y = Case45',
63                              '(int) z = 43'
64                              ])