129 lines · python
1"""2Test lldb data formatter subsystem.3"""4 5 6import lldb7from lldbsuite.test.decorators import *8from lldbsuite.test.lldbtest import *9from lldbsuite.test import lldbutil10 11 12class NSSetSyntheticTestCase(TestBase):13 def setUp(self):14 # Call super's setUp().15 TestBase.setUp(self)16 # Find the line number to break at.17 self.line = line_number("main.m", "// Set break point at this line.")18 19 @skipUnlessDarwin20 def test_rdar12529957_with_run_command(self):21 """Test that NSSet reports its synthetic children properly."""22 self.build()23 self.run_tests()24 25 @skipUnlessDarwin26 def test_rdar12529957_with_run_command_no_const(self):27 """Test that NSSet reports its synthetic children properly."""28 disable_constant_classes = {29 "CFLAGS_EXTRAS": "-fno-constant-nsnumber-literals "30 + "-fno-constant-nsarray-literals "31 + "-fno-constant-nsdictionary-literals",32 }33 # FIXME: Remove compiler when flags are available upstream.34 self.build(dictionary=disable_constant_classes, compiler="xcrun clang")35 self.run_tests()36 37 def run_tests(self):38 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)39 40 lldbutil.run_break_set_by_file_and_line(41 self, "main.m", self.line, num_expected_locations=1, loc_exact=True42 )43 44 self.runCmd("run", RUN_SUCCEEDED)45 46 # The stop reason of the thread should be breakpoint.47 self.expect(48 "thread list",49 STOPPED_DUE_TO_BREAKPOINT,50 substrs=["stopped", "stop reason = breakpoint"],51 )52 53 # This is the function to remove the custom formats in order to have a54 # clean slate for the next test case.55 def cleanup():56 self.runCmd("type format clear", check=False)57 self.runCmd("type summary clear", check=False)58 self.runCmd("type synth clear", check=False)59 60 # Execute the cleanup function during test case tear down.61 self.addTearDownHook(cleanup)62 63 # Now check that we are displaying Cocoa classes correctly64 self.expect("frame variable set", substrs=["4 elements"])65 self.expect("frame variable mutable", substrs=["9 elements"])66 self.expect(67 "frame variable set --ptr-depth 1 -d run -T",68 substrs=[69 "4 elements",70 "[0]",71 "hello",72 "[1]",73 "(int)2",74 "[2]",75 "(int)1",76 "[3]",77 "world",78 ],79 )80 self.expect(81 "frame variable mutable --ptr-depth 1 -d run -T",82 substrs=[83 "9 elements",84 "(int)5",85 '@"3 elements"',86 '@"www.apple.com"',87 "(int)3",88 '@"world"',89 "(int)4",90 ],91 )92 93 self.runCmd("next")94 self.expect("frame variable mutable", substrs=["0 elements"])95 96 self.runCmd("next")97 self.expect("frame variable mutable", substrs=["4 elements"])98 self.expect(99 "frame variable mutable --ptr-depth 1 -d run -T",100 substrs=[101 "4 elements",102 "[0]",103 "(int)1",104 "[1]",105 "(int)2",106 "[2]",107 "hello",108 "[3]",109 "world",110 ],111 )112 113 self.runCmd("next")114 self.expect("frame variable mutable", substrs=["4 elements"])115 self.expect(116 "frame variable mutable --ptr-depth 1 -d run -T",117 substrs=[118 "4 elements",119 "[0]",120 "(int)1",121 "[1]",122 "(int)2",123 "[2]",124 "hello",125 "[3]",126 "world",127 ],128 )129