]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py
Vendor import of lldb trunk r256945:
[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
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 NSDictionarySyntheticTestCase(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_rdar11988289_with_run_command(self):
27         """Test that NSDictionary 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 dictionary',
52                     substrs = ['3 key/value pairs'])
53         self.expect('frame variable mutabledict',
54                     substrs = ['4 key/value pairs'])
55         self.expect('frame variable dictionary --ptr-depth 1',
56                     substrs = ['3 key/value pairs','[0] = ','key = 0x','value = 0x','[1] = ','[2] = '])
57         self.expect('frame variable mutabledict --ptr-depth 1',
58                     substrs = ['4 key/value pairs','[0] = ','key = 0x','value = 0x','[1] = ','[2] = ','[3] = '])
59         self.expect('frame variable dictionary --ptr-depth 1 --dynamic-type no-run-target',
60                     substrs = ['3 key/value pairs','@"bar"','@"2 elements"','@"baz"','2 key/value pairs'])
61         self.expect('frame variable mutabledict --ptr-depth 1 --dynamic-type no-run-target',
62                     substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs'])
63         self.expect('frame variable mutabledict --ptr-depth 2 --dynamic-type no-run-target',
64         substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs','@"bar"','@"2 elements"'])
65         self.expect('frame variable mutabledict --ptr-depth 3 --dynamic-type no-run-target',
66         substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs','@"bar"','@"2 elements"','(int)1','@"two"'])
67
68         self.assertTrue(self.frame().FindVariable("dictionary").MightHaveChildren(), "dictionary says it does not have children!")
69         self.assertTrue(self.frame().FindVariable("mutabledict").MightHaveChildren(), "mutable says it does not have children!")