brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · 8debe73 Raw
81 lines · python
1"""Test that we properly vend children for a single entry NSDictionary"""2 3 4import lldb5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7from lldbsuite.test import lldbutil8 9 10class ObjCSingleEntryDictionaryTestCase(TestBase):11    def setUp(self):12        # Call super's setUp().13        TestBase.setUp(self)14        # Find the line number to break inside main().15        self.line = line_number("main.m", "// break here")16 17    @skipUnlessDarwin18    @expectedFailureAll(19        oslist=["watchos"], bugnumber="rdar://problem/34642736"20    )  # bug in NSDictionary formatting on watchos21    def test_single_entry_dict(self):22        self.build()23        self.run_tests()24 25    @skipUnlessDarwin26    @expectedFailureAll(27        oslist=["watchos"], bugnumber="rdar://problem/34642736"28    )  # bug in NSDictionary formatting on watchos29    def test_single_entry_dict_no_const(self):30        disable_constant_classes = {31            "CFLAGS_EXTRAS": "-fno-constant-nsnumber-literals "32            + "-fno-constant-nsarray-literals "33            + "-fno-constant-nsdictionary-literals",34        }35        # FIXME: Remove compiler when flags are available upstream.36        self.build(dictionary=disable_constant_classes, compiler="xcrun clang")37        self.run_tests()38 39    def run_tests(self):40        exe = self.getBuildArtifact("a.out")41        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)42 43        # Break inside the foo function which takes a bar_ptr argument.44        lldbutil.run_break_set_by_file_and_line(45            self, "main.m", self.line, num_expected_locations=1, loc_exact=True46        )47 48        self.runCmd("run", RUN_SUCCEEDED)49 50        # The stop reason of the thread should be breakpoint.51        self.expect(52            "thread list",53            STOPPED_DUE_TO_BREAKPOINT,54            substrs=["stopped", "stop reason = breakpoint"],55        )56 57        # The breakpoint should have a hit count of 1.58        lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)59 60        d1 = self.frame().FindVariable("d1")61        d1.SetPreferSyntheticValue(True)62        d1.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)63 64        self.assertEqual(d1.GetNumChildren(), 1, "dictionary has != 1 child elements")65        pair = d1.GetChildAtIndex(0)66        pair.SetPreferSyntheticValue(True)67        pair.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)68 69        self.assertEqual(pair.GetNumChildren(), 2, "pair has != 2 child elements")70 71        key = pair.GetChildMemberWithName("key")72        value = pair.GetChildMemberWithName("value")73 74        key.SetPreferSyntheticValue(True)75        key.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)76        value.SetPreferSyntheticValue(True)77        value.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)78 79        self.assertEqual(key.GetSummary(), '@"key"', "key doesn't contain key")80        self.assertEqual(value.GetSummary(), '@"value"', "value doesn't contain value")81