]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / data-formatter / poarray / TestPrintObjectArray.py
1 """
2 Test lldb data formatter subsystem.
3 """
4
5 from __future__ import print_function
6
7
8 import datetime
9 import os
10 import time
11 import lldb
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 from lldbsuite.test import lldbutil
15
16
17 class PrintObjectArrayTestCase(TestBase):
18
19     mydir = TestBase.compute_mydir(__file__)
20
21     @skipUnlessDarwin
22     def test_print_array(self):
23         """Test that expr -O -Z works"""
24         self.build()
25         self.printarray_data_formatter_commands()
26
27     def setUp(self):
28         # Call super's setUp().
29         TestBase.setUp(self)
30         # Find the line number to break at.
31         self.line = line_number('main.mm', 'break here')
32
33     def printarray_data_formatter_commands(self):
34         """Test that expr -O -Z works"""
35         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
36
37         lldbutil.run_break_set_by_file_and_line(
38             self, "main.mm", self.line, num_expected_locations=1, loc_exact=True)
39
40         self.runCmd("run", RUN_SUCCEEDED)
41
42         # The stop reason of the thread should be breakpoint.
43         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
44                     substrs=['stopped',
45                              'stop reason = breakpoint'])
46
47         # This is the function to remove the custom formats in order to have a
48         # clean slate for the next test case.
49         def cleanup():
50             self.runCmd('type format clear', check=False)
51             self.runCmd('type summary clear', check=False)
52             self.runCmd('type synth clear', check=False)
53
54         # Execute the cleanup function during test case tear down.
55         self.addTearDownHook(cleanup)
56
57         self.expect(
58             'expr --element-count 3 --object-description -- objects',
59             substrs=[
60                 '3735928559',
61                 '4276993775',
62                 '3203398366',
63                 'Hello',
64                 'World',
65                 'Two =',
66                 '1 ='])
67         self.expect(
68             'poarray 3 objects',
69             substrs=[
70                 '3735928559',
71                 '4276993775',
72                 '3203398366',
73                 'Hello',
74                 'World',
75                 'Two =',
76                 '1 ='])
77         self.expect(
78             'expr --element-count 3 --object-description --description-verbosity=full -- objects',
79             substrs=[
80                 '[0] =',
81                 '3735928559',
82                 '4276993775',
83                 '3203398366',
84                 '[1] =',
85                 'Hello',
86                 'World',
87                 '[2] =',
88                 'Two =',
89                 '1 ='])
90         self.expect(
91             'parray 3 objects',
92             substrs=[
93                 '[0] = 0x',
94                 '[1] = 0x',
95                 '[2] = 0x'])
96         self.expect(
97             'expr --element-count 3 -d run -- objects',
98             substrs=[
99                 '3 elements',
100                 '2 elements',
101                 '2 key/value pairs'])
102         self.expect(
103             'expr --element-count 3 -d run --ptr-depth=1 -- objects',
104             substrs=[
105                 '3 elements',
106                 '2 elements',
107                 '2 key/value pairs',
108                 '3735928559',
109                 '4276993775',
110                 '3203398366',
111                 '"Hello"',
112                 '"World"'])