1# encoding: utf-8 2""" 3Test lldb data formatter subsystem. 4""" 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class NSIndexPathDataFormatterTestCase(TestBase): 14 def appkit_tester_impl(self, commands): 15 self.build() 16 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 17 18 lldbutil.run_break_set_by_file_and_line( 19 self, "main.m", self.line, num_expected_locations=1, loc_exact=True 20 ) 21 22 self.runCmd("run", RUN_SUCCEEDED) 23 24 # The stop reason of the thread should be breakpoint. 25 self.expect( 26 "thread list", 27 STOPPED_DUE_TO_BREAKPOINT, 28 substrs=["stopped", "stop reason = breakpoint"], 29 ) 30 31 # This is the function to remove the custom formats in order to have a 32 # clean slate for the next test case. 33 def cleanup(): 34 self.runCmd("type format clear", check=False) 35 self.runCmd("type summary clear", check=False) 36 self.runCmd("type synth clear", check=False) 37 38 # Execute the cleanup function during test case tear down. 39 self.addTearDownHook(cleanup) 40 commands() 41 42 @skipUnlessDarwin 43 @expectedFailureAll(archs=["i386"], bugnumber="rdar://28656605") 44 @expectedFailureAll( 45 archs=["armv7", "armv7k", "arm64_32"], bugnumber="rdar://problem/34561607" 46 ) # NSIndexPath formatter isn't working for 32-bit arm 47 def test_nsindexpath_with_run_command(self): 48 """Test formatters for NSIndexPath.""" 49 self.appkit_tester_impl(self.nsindexpath_data_formatter_commands) 50 51 def setUp(self): 52 # Call super's setUp(). 53 TestBase.setUp(self) 54 # Find the line number to break at. 55 self.line = line_number("main.m", "// break here") 56 57 def nsindexpath_data_formatter_commands(self): 58 # check 'frame variable' 59 self.expect( 60 "frame variable --ptr-depth=1 -d run -- indexPath1", substrs=["[0] = 1"] 61 ) 62 self.expect( 63 "frame variable --ptr-depth=1 -d run -- indexPath2", 64 substrs=["[0] = 1", "[1] = 2"], 65 ) 66 self.expect( 67 "frame variable --ptr-depth=1 -d run -- indexPath3", 68 substrs=["[0] = 1", "[1] = 2", "[2] = 3"], 69 ) 70 self.expect( 71 "frame variable --ptr-depth=1 -d run -- indexPath4", 72 substrs=["[0] = 1", "[1] = 2", "[2] = 3", "[3] = 4"], 73 ) 74 self.expect( 75 "frame variable --ptr-depth=1 -d run -- indexPath5", 76 substrs=["[0] = 1", "[1] = 2", "[2] = 3", "[3] = 4", "[4] = 5"], 77 ) 78 79 # and 'expression' 80 self.expect( 81 "expression --ptr-depth=1 -d run -- indexPath1", substrs=["[0] = 1"] 82 ) 83 self.expect( 84 "expression --ptr-depth=1 -d run -- indexPath2", 85 substrs=["[0] = 1", "[1] = 2"], 86 ) 87 self.expect( 88 "expression --ptr-depth=1 -d run -- indexPath3", 89 substrs=["[0] = 1", "[1] = 2", "[2] = 3"], 90 ) 91 self.expect( 92 "expression --ptr-depth=1 -d run -- indexPath4", 93 substrs=["[0] = 1", "[1] = 2", "[2] = 3", "[3] = 4"], 94 ) 95 self.expect( 96 "expression --ptr-depth=1 -d run -- indexPath5", 97 substrs=["[0] = 1", "[1] = 2", "[2] = 3", "[3] = 4", "[4] = 5"], 98 ) 99