85ad6286716a7a311a2a2f8f9231bdc95c7d14df
[openbsd] /
1 """Test that we properly vend children for a single entry NSDictionary"""
2
3
4
5 import unittest2
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 ObjCSingleEntryDictionaryTestCase(TestBase):
15
16     mydir = TestBase.compute_mydir(__file__)
17
18     def setUp(self):
19         # Call super's setUp().
20         TestBase.setUp(self)
21         # Find the line number to break inside main().
22         self.line = line_number('main.m', '// break here')
23
24     @skipUnlessDarwin
25     @expectedFailureAll(oslist=['watchos'], bugnumber="rdar://problem/34642736") # bug in NSDictionary formatting on watchos
26     def test_single_entry_dict(self):
27         self.build()
28         exe = self.getBuildArtifact("a.out")
29         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
30
31         # Break inside the foo function which takes a bar_ptr argument.
32         lldbutil.run_break_set_by_file_and_line(
33             self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
34
35         self.runCmd("run", RUN_SUCCEEDED)
36
37         # The stop reason of the thread should be breakpoint.
38         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
39                     substrs=['stopped',
40                              'stop reason = breakpoint'])
41
42         # The breakpoint should have a hit count of 1.
43         self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
44                     substrs=[' resolved, hit count = 1'])
45
46         d1 = self.frame().FindVariable("d1")
47         d1.SetPreferSyntheticValue(True)
48         d1.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
49
50         self.assertTrue(
51             d1.GetNumChildren() == 1,
52             "dictionary has != 1 child elements")
53         pair = d1.GetChildAtIndex(0)
54         pair.SetPreferSyntheticValue(True)
55         pair.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
56
57         self.assertTrue(
58             pair.GetNumChildren() == 2,
59             "pair has != 2 child elements")
60
61         key = pair.GetChildMemberWithName("key")
62         value = pair.GetChildMemberWithName("value")
63
64         key.SetPreferSyntheticValue(True)
65         key.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
66         value.SetPreferSyntheticValue(True)
67         value.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
68
69         self.assertTrue(
70             key.GetSummary() == '@"key"',
71             "key doesn't contain key")
72         self.assertTrue(
73             value.GetSummary() == '@"value"',
74             "value doesn't contain value")