12461ab03de66a17d3f92c7033f5138bf231bc3e
[openbsd] /
1 # encoding: utf-8
2 """
3 Test lldb data formatter subsystem.
4 """
5
6
7
8 import lldb
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
12
13
14 class NSIndexPathDataFormatterTestCase(TestBase):
15
16     mydir = TestBase.compute_mydir(__file__)
17
18     def appkit_tester_impl(self, commands):
19         self.build()
20         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
21
22         lldbutil.run_break_set_by_file_and_line(
23             self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
24
25         self.runCmd("run", RUN_SUCCEEDED)
26
27         # The stop reason of the thread should be breakpoint.
28         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
29                     substrs=['stopped',
30                              'stop reason = breakpoint'])
31
32         # This is the function to remove the custom formats in order to have a
33         # clean slate for the next test case.
34         def cleanup():
35             self.runCmd('type format clear', check=False)
36             self.runCmd('type summary clear', check=False)
37             self.runCmd('type synth clear', check=False)
38
39         # Execute the cleanup function during test case tear down.
40         self.addTearDownHook(cleanup)
41         commands()
42
43     @skipUnlessDarwin
44     @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656605")
45     @expectedFailureAll(archs=['armv7', 'armv7k', 'arm64_32'], bugnumber="rdar://problem/34561607") # NSIndexPath formatter isn't working for 32-bit arm
46     def test_nsindexpath_with_run_command(self):
47         """Test formatters for NSIndexPath."""
48         self.appkit_tester_impl(self.nsindexpath_data_formatter_commands)
49
50     def setUp(self):
51         # Call super's setUp().
52         TestBase.setUp(self)
53         # Find the line number to break at.
54         self.line = line_number('main.m', '// break here')
55
56     def nsindexpath_data_formatter_commands(self):
57         # check 'frame variable'
58         self.expect(
59             'frame variable --ptr-depth=1 -d run -- indexPath1',
60             substrs=['[0] = 1'])
61         self.expect(
62             'frame variable --ptr-depth=1 -d run -- indexPath2',
63             substrs=[
64                 '[0] = 1',
65                 '[1] = 2'])
66         self.expect(
67             'frame variable --ptr-depth=1 -d run -- indexPath3',
68             substrs=[
69                 '[0] = 1',
70                 '[1] = 2',
71                 '[2] = 3'])
72         self.expect(
73             'frame variable --ptr-depth=1 -d run -- indexPath4',
74             substrs=[
75                 '[0] = 1',
76                 '[1] = 2',
77                 '[2] = 3',
78                 '[3] = 4'])
79         self.expect(
80             'frame variable --ptr-depth=1 -d run -- indexPath5',
81             substrs=[
82                 '[0] = 1',
83                 '[1] = 2',
84                 '[2] = 3',
85                 '[3] = 4',
86                 '[4] = 5'])
87
88         # and 'expression'
89         self.expect(
90             'expression --ptr-depth=1 -d run -- indexPath1',
91             substrs=['[0] = 1'])
92         self.expect(
93             'expression --ptr-depth=1 -d run -- indexPath2',
94             substrs=[
95                 '[0] = 1',
96                 '[1] = 2'])
97         self.expect(
98             'expression --ptr-depth=1 -d run -- indexPath3',
99             substrs=[
100                 '[0] = 1',
101                 '[1] = 2',
102                 '[2] = 3'])
103         self.expect('expression --ptr-depth=1 -d run -- indexPath4',
104                     substrs=['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4'])
105         self.expect(
106             'expression --ptr-depth=1 -d run -- indexPath5',
107             substrs=[
108                 '[0] = 1',
109                 '[1] = 2',
110                 '[2] = 3',
111                 '[3] = 4',
112                 '[4] = 5'])