]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py
Vendor import of lldb trunk r338150:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / data-formatter / nsdictionarysynth / TestNSDictionarySynthetic.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 NSDictionarySyntheticTestCase(TestBase):
18
19     mydir = TestBase.compute_mydir(__file__)
20
21     def setUp(self):
22         # Call super's setUp().
23         TestBase.setUp(self)
24         # Find the line number to break at.
25         self.line = line_number('main.m', '// Set break point at this line.')
26
27     @skipUnlessDarwin
28     def test_rdar11988289_with_run_command(self):
29         """Test that NSDictionary reports its synthetic children properly."""
30         self.build()
31         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
32
33         lldbutil.run_break_set_by_file_and_line(
34             self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
35
36         self.runCmd("run", RUN_SUCCEEDED)
37
38         # The stop reason of the thread should be breakpoint.
39         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
40                     substrs=['stopped',
41                              'stop reason = breakpoint'])
42
43         # This is the function to remove the custom formats in order to have a
44         # clean slate for the next test case.
45         def cleanup():
46             self.runCmd('type format clear', check=False)
47             self.runCmd('type summary clear', check=False)
48             self.runCmd('type synth clear', check=False)
49
50         # Execute the cleanup function during test case tear down.
51         self.addTearDownHook(cleanup)
52
53         # Now check that we are displaying Cocoa classes correctly
54         self.expect('frame variable dictionary',
55                     substrs=['3 key/value pairs'])
56         self.expect('frame variable mutabledict',
57                     substrs=['4 key/value pairs'])
58         self.expect(
59             'frame variable dictionary --ptr-depth 1',
60             substrs=[
61                 '3 key/value pairs',
62                 '[0] = ',
63                 'key = 0x',
64                 'value = 0x',
65                 '[1] = ',
66                 '[2] = '])
67         self.expect(
68             'frame variable mutabledict --ptr-depth 1',
69             substrs=[
70                 '4 key/value pairs',
71                 '[0] = ',
72                 'key = 0x',
73                 'value = 0x',
74                 '[1] = ',
75                 '[2] = ',
76                 '[3] = '])
77         self.expect(
78             'frame variable dictionary --ptr-depth 1 --dynamic-type no-run-target',
79             substrs=[
80                 '3 key/value pairs',
81                 '@"bar"',
82                 '@"2 elements"',
83                 '@"baz"',
84                 '2 key/value pairs'])
85         self.expect(
86             'frame variable mutabledict --ptr-depth 1 --dynamic-type no-run-target',
87             substrs=[
88                 '4 key/value pairs',
89                 '(int)23',
90                 '@"123"',
91                 '@"http://www.apple.com"',
92                 '@"sourceofstuff"',
93                 '3 key/value pairs'])
94         self.expect(
95             'frame variable mutabledict --ptr-depth 2 --dynamic-type no-run-target',
96             substrs=[
97                 '4 key/value pairs',
98                 '(int)23',
99                 '@"123"',
100                 '@"http://www.apple.com"',
101                 '@"sourceofstuff"',
102                 '3 key/value pairs',
103                 '@"bar"',
104                 '@"2 elements"'])
105         self.expect(
106             'frame variable mutabledict --ptr-depth 3 --dynamic-type no-run-target',
107             substrs=[
108                 '4 key/value pairs',
109                 '(int)23',
110                 '@"123"',
111                 '@"http://www.apple.com"',
112                 '@"sourceofstuff"',
113                 '3 key/value pairs',
114                 '@"bar"',
115                 '@"2 elements"',
116                 '(int)1',
117                 '@"two"'])
118
119         self.assertTrue(
120             self.frame().FindVariable("dictionary").MightHaveChildren(),
121             "dictionary says it does not have children!")
122         self.assertTrue(
123             self.frame().FindVariable("mutabledict").MightHaveChildren(),
124             "mutable says it does not have children!")