2ff3d63d004d9f931c30a401dac26b1b0a3bae99
[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 LibcxxIteratorDataFormatterTestCase(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         ns = 'ndk' if lldbplatformutil.target_is_android() else ''
23         self.namespace = 'std::__' + ns + '1'
24
25     @add_test_categories(["libc++"])
26     def test_with_run_command(self):
27         """Test that libc++ iterators format properly."""
28         self.build()
29         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
30
31         lldbutil.run_break_set_by_file_and_line(
32             self, "main.cpp", self.line, num_expected_locations=-1)
33
34         self.runCmd("run", RUN_SUCCEEDED)
35
36         # The stop reason of the thread should be breakpoint.
37         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
38                     substrs=['stopped',
39                              'stop reason = breakpoint'])
40
41         # This is the function to remove the custom formats in order to have a
42         # clean slate for the next test case.
43         def cleanup():
44             self.runCmd('type format clear', check=False)
45             self.runCmd('type summary clear', check=False)
46             self.runCmd('type filter clear', check=False)
47             self.runCmd('type synth clear', check=False)
48             self.runCmd(
49                 "settings set target.max-children-count 256",
50                 check=False)
51
52         # Execute the cleanup function during test case tear down.
53         self.addTearDownHook(cleanup)
54
55         self.expect('frame variable ivI', substrs=['item = 3'])
56         self.expect('expr ivI', substrs=['item = 3'])
57
58         self.expect(
59             'frame variable iimI',
60             substrs=[
61                 'first = 43981',
62                 'second = 61681'])
63         self.expect('expr iimI', substrs=['first = 43981', 'second = 61681'])
64
65         self.expect(
66             'frame variable simI',
67             substrs=[
68                 'first = "world"',
69                 'second = 42'])
70         self.expect('expr simI', substrs=['first = "world"', 'second = 42'])
71
72         self.expect('frame variable svI', substrs=['item = "hello"'])
73         self.expect('expr svI', substrs=['item = "hello"'])