52387a414849fff49861f0d3493c7340a8cc2d01
[openbsd] /
1 """
2 Test lldb data formatter subsystem.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class StdIteratorDataFormatterTestCase(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     def setUp(self):
18         # Call super's setUp().
19         TestBase.setUp(self)
20         # Find the line number to break at.
21         self.line = line_number('main.cpp', '// Set break point at this line.')
22
23     @add_test_categories(["libstdcxx"])
24     def test_with_run_command(self):
25         """Test that libstdcpp iterators format properly."""
26         self.build()
27         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
28
29         lldbutil.run_break_set_by_file_and_line(
30             self, "main.cpp", self.line, num_expected_locations=-1)
31
32         self.runCmd("run", RUN_SUCCEEDED)
33
34         # The stop reason of the thread should be breakpoint.
35         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
36                     substrs=['stopped',
37                              'stop reason = breakpoint'])
38
39         # This is the function to remove the custom formats in order to have a
40         # clean slate for the next test case.
41         def cleanup():
42             self.runCmd('type format clear', check=False)
43             self.runCmd('type summary clear', check=False)
44             self.runCmd('type filter clear', check=False)
45             self.runCmd('type synth clear', check=False)
46             self.runCmd(
47                 "settings set target.max-children-count 256",
48                 check=False)
49
50         # Execute the cleanup function during test case tear down.
51         self.addTearDownHook(cleanup)
52
53         self.expect('frame variable ivI', substrs=['item = 3'])
54         self.expect('expr ivI', substrs=['item = 3'])
55
56         self.expect(
57             'frame variable iimI',
58             substrs=[
59                 'first = 0',
60                 'second = 12'])
61         self.expect('expr iimI', substrs=['first = 0', 'second = 12'])
62
63         self.expect(
64             'frame variable simI',
65             substrs=[
66                 'first = "world"',
67                 'second = 42'])
68         self.expect('expr simI', substrs=['first = "world"', 'second = 42'])
69
70         self.expect('frame variable svI', substrs=['item = "hello"'])
71         self.expect('expr svI', substrs=['item = "hello"'])