]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / data-formatter / nsarraysynth / TestNSArraySynthetic.py
1 """
2 Test lldb data formatter subsystem.
3 """
4
5 from __future__ import print_function
6
7
8
9 import os, time
10 import lldb
11 from lldbsuite.test.lldbtest import *
12 import datetime
13 import lldbsuite.test.lldbutil as lldbutil
14
15 class NSArraySyntheticTestCase(TestBase):
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     def setUp(self):
20         # Call super's setUp().
21         TestBase.setUp(self)
22         # Find the line number to break at.
23         self.line = line_number('main.m', '// Set break point at this line.')
24
25     @skipUnlessDarwin
26     def test_rdar11086338_with_run_command(self):
27         """Test that NSArray reports its synthetic children properly."""
28         self.build()
29         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
30
31         lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
32
33         self.runCmd("run", RUN_SUCCEEDED)
34
35         # The stop reason of the thread should be breakpoint.
36         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
37             substrs = ['stopped',
38                        'stop reason = breakpoint'])
39
40         # This is the function to remove the custom formats in order to have a
41         # clean slate for the next test case.
42         def cleanup():
43             self.runCmd('type format clear', check=False)
44             self.runCmd('type summary clear', check=False)
45             self.runCmd('type synth clear', check=False)
46
47         # Execute the cleanup function during test case tear down.
48         self.addTearDownHook(cleanup)
49
50         # Now check that we are displaying Cocoa classes correctly
51         self.expect('frame variable arr',
52                     substrs = ['@"6 elements"'])
53         self.expect('frame variable other_arr',
54                     substrs = ['@"4 elements"'])
55         self.expect('frame variable arr --ptr-depth 1',
56                     substrs = ['@"6 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x','[4] = 0x','[5] = 0x'])
57         self.expect('frame variable other_arr --ptr-depth 1',
58                     substrs = ['@"4 elements"','[0] = 0x','[1] = 0x','[2] = 0x','[3] = 0x'])
59         self.expect('frame variable arr --ptr-depth 1 -d no-run-target',
60                     substrs = ['@"6 elements"','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com'])
61         self.expect('frame variable other_arr --ptr-depth 1 -d no-run-target',
62                     substrs = ['@"4 elements"','(int)5','@"a string"','@"6 elements"'])
63         self.expect('frame variable other_arr --ptr-depth 2 -d no-run-target',
64                     substrs = ['@"4 elements"','@"6 elements" {','@"hello"','@"world"','@"this"','@"is"','@"me"','@"http://www.apple.com'])
65
66         self.assertTrue(self.frame().FindVariable("arr").MightHaveChildren(), "arr says it does not have children!")
67         self.assertTrue(self.frame().FindVariable("other_arr").MightHaveChildren(), "arr says it does not have children!")