diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/objc/foundation')
7 files changed, 312 insertions, 161 deletions
diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py index 4a62d6240d980..2a81c42eb5036 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py @@ -6,13 +6,14 @@ parser. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ConstStringTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -30,25 +31,30 @@ class ConstStringTestCase(TestBase): """Test constant string generation amd comparison by the expression parser.""" self.build(dictionary=self.d) self.setTearDownCleanup(self.d) - + exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, self.main_source, self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, + self.main_source, + self.line, + num_expected_locations=1, + loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) self.expect("process status", STOPPED_DUE_TO_BREAKPOINT, - substrs = [" at %s:%d" % (self.main_source, self.line), - "stop reason = breakpoint"]) + substrs=[" at %s:%d" % (self.main_source, self.line), + "stop reason = breakpoint"]) self.expect('expression (int)[str compare:@"hello"]', - startstr = "(int) $0 = 0") + startstr="(int) $0 = 0") self.expect('expression (int)[str compare:@"world"]', - startstr = "(int) $1 = -1") + startstr="(int) $1 = -1") # Test empty strings, too. self.expect('expression (int)[@"" length]', - startstr = "(int) $2 = 0") + startstr="(int) $2 = 0") self.expect('expression (int)[@"123" length]', - startstr = "(int) $3 = 3") + startstr="(int) $3 = 3") diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py index 0867eec62ebe5..51d9d22bf44a0 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py @@ -5,14 +5,15 @@ Test the lldb disassemble command on foundation framework. from __future__ import print_function - import unittest2 -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + @skipUnlessDarwin class FoundationDisassembleTestCase(TestBase): @@ -20,20 +21,23 @@ class FoundationDisassembleTestCase(TestBase): # rdar://problem/8504895 # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]" - @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") + @unittest2.skipIf( + TestBase.skipLongRunningTest(), + "Skip this long running test") def test_foundation_disasm(self): """Do 'disassemble -n func' on each and every 'Code' symbol entry from the Foundation.framework.""" self.build() - + # Enable synchronous mode self.dbg.SetAsync(False) - + # Create a target by the debugger. target = self.dbg.CreateTarget("a.out") self.assertTrue(target, VALID_TARGET) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) foundation_framework = None @@ -43,7 +47,9 @@ class FoundationDisassembleTestCase(TestBase): foundation_framework = module.file.fullpath break - self.assertTrue(foundation_framework != None, "Foundation.framework path located") + self.assertTrue( + foundation_framework is not None, + "Foundation.framework path located") self.runCmd("image dump symtab '%s'" % foundation_framework) raw_output = self.res.GetOutput() # Now, grab every 'Code' symbol and feed it into the command: @@ -64,7 +70,6 @@ class FoundationDisassembleTestCase(TestBase): #print("line:", line) #print("func:", func) self.runCmd('disassemble -n "%s"' % func) - def test_simple_disasm(self): """Test the lldb 'disassemble' command""" @@ -80,25 +85,45 @@ class FoundationDisassembleTestCase(TestBase): # Stop at +[NSString stringWithFormat:]. symbol_name = "+[NSString stringWithFormat:]" - break_results = lldbutil.run_break_set_command (self, "_regexp-break %s"%(symbol_name)) - - lldbutil.check_breakpoint_result (self, break_results, symbol_name=symbol_name, num_locations=1) + break_results = lldbutil.run_break_set_command( + self, "_regexp-break %s" % (symbol_name)) + + lldbutil.check_breakpoint_result( + self, + break_results, + symbol_name=symbol_name, + num_locations=1) # Stop at -[MyString initWithNSString:]. - lldbutil.run_break_set_by_symbol (self, '-[MyString initWithNSString:]', num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, + '-[MyString initWithNSString:]', + num_expected_locations=1, + sym_exact=True) # Stop at the "description" selector. - lldbutil.run_break_set_by_selector (self, 'description', num_expected_locations=1, module_name='a.out') + lldbutil.run_break_set_by_selector( + self, + 'description', + num_expected_locations=1, + module_name='a.out') # Stop at -[NSAutoreleasePool release]. - break_results = lldbutil.run_break_set_command (self, "_regexp-break -[NSAutoreleasePool release]") - lldbutil.check_breakpoint_result (self, break_results, symbol_name='-[NSAutoreleasePool release]', num_locations=1) + break_results = lldbutil.run_break_set_command( + self, "_regexp-break -[NSAutoreleasePool release]") + lldbutil.check_breakpoint_result( + self, + break_results, + symbol_name='-[NSAutoreleasePool release]', + num_locations=1) self.runCmd("run", RUN_SUCCEEDED) # First stop is +[NSString stringWithFormat:]. - self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", - substrs = ["Foundation`+[NSString stringWithFormat:]"]) + self.expect( + "thread backtrace", + "Stop at +[NSString stringWithFormat:]", + substrs=["Foundation`+[NSString stringWithFormat:]"]) # Do the disassemble for the currently stopped function. self.runCmd("disassemble -f") @@ -108,8 +133,10 @@ class FoundationDisassembleTestCase(TestBase): self.runCmd("process continue") # Followed by a.out`-[MyString initWithNSString:]. - self.expect("thread backtrace", "Stop at a.out`-[MyString initWithNSString:]", - substrs = ["a.out`-[MyString initWithNSString:]"]) + self.expect( + "thread backtrace", + "Stop at a.out`-[MyString initWithNSString:]", + substrs=["a.out`-[MyString initWithNSString:]"]) # Do the disassemble for the currently stopped function. self.runCmd("disassemble -f") @@ -118,7 +145,7 @@ class FoundationDisassembleTestCase(TestBase): # Followed by -[MyString description]. self.expect("thread backtrace", "Stop at -[MyString description]", - substrs = ["a.out`-[MyString description]"]) + substrs=["a.out`-[MyString description]"]) # Do the disassemble for the currently stopped function. self.runCmd("disassemble -f") @@ -129,7 +156,7 @@ class FoundationDisassembleTestCase(TestBase): # Followed by -[NSAutoreleasePool release]. self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", - substrs = ["Foundation`-[NSAutoreleasePool release]"]) + substrs=["Foundation`-[NSAutoreleasePool release]"]) # Do the disassemble for the currently stopped function. self.runCmd("disassemble -f") diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py index 2a8e80f6d76ee..d636458ce1aa6 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py @@ -6,8 +6,9 @@ Also lookup objective-c data types and evaluate expressions. from __future__ import print_function - -import os, os.path, time +import os +import os.path +import time import lldb import string from lldbsuite.test.decorators import * @@ -15,6 +16,8 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil file_index = 0 + + @skipUnlessDarwin class FoundationTestCase(TestBase): @@ -25,7 +28,9 @@ class FoundationTestCase(TestBase): TestBase.setUp(self) # Find the line number to break inside main(). self.main_source = "main.m" - self.line = line_number(self.main_source, '// Set break point at this line.') + self.line = line_number( + self.main_source, + '// Set break point at this line.') def test_break(self): """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" @@ -34,54 +39,78 @@ class FoundationTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at +[NSString stringWithFormat:]. - break_results = lldbutil.run_break_set_command(self, "_regexp-break +[NSString stringWithFormat:]") - lldbutil.check_breakpoint_result (self, break_results, symbol_name='+[NSString stringWithFormat:]', num_locations=1) + break_results = lldbutil.run_break_set_command( + self, "_regexp-break +[NSString stringWithFormat:]") + lldbutil.check_breakpoint_result( + self, + break_results, + symbol_name='+[NSString stringWithFormat:]', + num_locations=1) # Stop at -[MyString initWithNSString:]. - lldbutil.run_break_set_by_symbol (self, '-[MyString initWithNSString:]', num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, + '-[MyString initWithNSString:]', + num_expected_locations=1, + sym_exact=True) # Stop at the "description" selector. - lldbutil.run_break_set_by_selector (self, 'description', num_expected_locations=1, module_name='a.out') + lldbutil.run_break_set_by_selector( + self, + 'description', + num_expected_locations=1, + module_name='a.out') # Stop at -[NSAutoreleasePool release]. - break_results = lldbutil.run_break_set_command(self, "_regexp-break -[NSAutoreleasePool release]") - lldbutil.check_breakpoint_result (self, break_results, symbol_name='-[NSAutoreleasePool release]', num_locations=1) + break_results = lldbutil.run_break_set_command( + self, "_regexp-break -[NSAutoreleasePool release]") + lldbutil.check_breakpoint_result( + self, + break_results, + symbol_name='-[NSAutoreleasePool release]', + num_locations=1) self.runCmd("run", RUN_SUCCEEDED) # First stop is +[NSString stringWithFormat:]. - self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", - substrs = ["Foundation`+[NSString stringWithFormat:]"]) + self.expect( + "thread backtrace", + "Stop at +[NSString stringWithFormat:]", + substrs=["Foundation`+[NSString stringWithFormat:]"]) self.runCmd("process continue") # Second stop is still +[NSString stringWithFormat:]. - self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", - substrs = ["Foundation`+[NSString stringWithFormat:]"]) + self.expect( + "thread backtrace", + "Stop at +[NSString stringWithFormat:]", + substrs=["Foundation`+[NSString stringWithFormat:]"]) self.runCmd("process continue") # Followed by a.out`-[MyString initWithNSString:]. - self.expect("thread backtrace", "Stop at a.out`-[MyString initWithNSString:]", - substrs = ["a.out`-[MyString initWithNSString:]"]) + self.expect( + "thread backtrace", + "Stop at a.out`-[MyString initWithNSString:]", + substrs=["a.out`-[MyString initWithNSString:]"]) self.runCmd("process continue") # Followed by -[MyString description]. self.expect("thread backtrace", "Stop at -[MyString description]", - substrs = ["a.out`-[MyString description]"]) + substrs=["a.out`-[MyString description]"]) self.runCmd("process continue") # Followed by the same -[MyString description]. self.expect("thread backtrace", "Stop at -[MyString description]", - substrs = ["a.out`-[MyString description]"]) + substrs=["a.out`-[MyString description]"]) self.runCmd("process continue") # Followed by -[NSAutoreleasePool release]. self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", - substrs = ["Foundation`-[NSAutoreleasePool release]"]) + substrs=["Foundation`-[NSAutoreleasePool release]"]) # rdar://problem/8542091 # rdar://problem/8492646 @@ -92,32 +121,40 @@ class FoundationTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at -[MyString description]. - lldbutil.run_break_set_by_symbol (self, '-[MyString description]', num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, + '-[MyString description]', + num_expected_locations=1, + sym_exact=True) # self.expect("breakpoint set -n '-[MyString description]", BREAKPOINT_CREATED, -# startstr = "Breakpoint created: 1: name = '-[MyString description]', locations = 1") +# startstr = "Breakpoint created: 1: name = '-[MyString description]', +# locations = 1") self.runCmd("run", RUN_SUCCEEDED) # The backtrace should show we stop at -[MyString description]. self.expect("thread backtrace", "Stop at -[MyString description]", - substrs = ["a.out`-[MyString description]"]) + substrs=["a.out`-[MyString description]"]) # Lookup objc data type MyString and evaluate some expressions. self.expect("image lookup -t NSString", DATA_TYPES_DISPLAYED_CORRECTLY, - substrs = ['name = "NSString"', - 'compiler_type = "@interface NSString']) + substrs=['name = "NSString"', + 'compiler_type = "@interface NSString']) self.expect("image lookup -t MyString", DATA_TYPES_DISPLAYED_CORRECTLY, - substrs = ['name = "MyString"', - 'compiler_type = "@interface MyString', - 'NSString * str;', - 'NSDate * date;']) - - self.expect("frame variable --show-types --scope", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["ARG: (MyString *) self"], - patterns = ["ARG: \(.*\) _cmd", - "(objc_selector *)|(SEL)"]) + substrs=['name = "MyString"', + 'compiler_type = "@interface MyString', + 'NSString * str;', + 'NSDate * date;']) + + self.expect( + "frame variable --show-types --scope", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=["ARG: (MyString *) self"], + patterns=[ + "ARG: \(.*\) _cmd", + "(objc_selector *)|(SEL)"]) # rdar://problem/8651752 # don't crash trying to ask clang how many children an empty record has @@ -126,28 +163,37 @@ class FoundationTestCase(TestBase): # rdar://problem/8492646 # test/foundation fails after updating to tot r115023 # self->str displays nothing as output - self.expect("frame variable --show-types self->str", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "(NSString *) self->str") + self.expect( + "frame variable --show-types self->str", + VARIABLES_DISPLAYED_CORRECTLY, + startstr="(NSString *) self->str") # rdar://problem/8447030 # 'frame variable self->date' displays the wrong data member - self.expect("frame variable --show-types self->date", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "(NSDate *) self->date") + self.expect( + "frame variable --show-types self->date", + VARIABLES_DISPLAYED_CORRECTLY, + startstr="(NSDate *) self->date") # This should display the str and date member fields as well. - self.expect("frame variable --show-types *self", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["(MyString) *self", - "(NSString *) str", - "(NSDate *) date"]) - + self.expect( + "frame variable --show-types *self", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + "(MyString) *self", + "(NSString *) str", + "(NSDate *) date"]) + # isa should be accessible. self.expect("expression self->isa", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["(Class)"]) + substrs=["(Class)"]) # This should fail expectedly. - self.expect("expression self->non_existent_member", - COMMAND_FAILED_AS_EXPECTED, error=True, - startstr = "error: 'MyString' does not have a member named 'non_existent_member'") + self.expect( + "expression self->non_existent_member", + COMMAND_FAILED_AS_EXPECTED, + error=True, + startstr="error: 'MyString' does not have a member named 'non_existent_member'") # Use expression parser. self.runCmd("expression self->str") @@ -163,7 +209,8 @@ class FoundationTestCase(TestBase): # self.runCmd("breakpoint delete 1") - lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("process continue") @@ -171,12 +218,15 @@ class FoundationTestCase(TestBase): # test/foundation: expr -o -- my not working? # # Test new feature with r115115: - # Add "-o" option to "expression" which prints the object description if available. - self.expect("expression --object-description -- my", "Object description displayed correctly", - patterns = ["Hello from.*a.out.*with timestamp: "]) + # Add "-o" option to "expression" which prints the object description + # if available. + self.expect( + "expression --object-description -- my", + "Object description displayed correctly", + patterns=["Hello from.*a.out.*with timestamp: "]) @add_test_categories(['pyapi']) - def test_print_ivars_correctly (self): + def test_print_ivars_correctly(self): self.build() # See: <rdar://problem/8717050> lldb needs to use the ObjC runtime symbols for ivar offsets # Only fails for the ObjC 2.0 runtime. @@ -189,7 +239,8 @@ class FoundationTestCase(TestBase): self.assertTrue(break1, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) @@ -205,7 +256,7 @@ class FoundationTestCase(TestBase): cur_frame = thread.GetFrameAtIndex(0) line_number = cur_frame.GetLineEntry().GetLine() - self.assertTrue (line_number == self.line, "Hit the first breakpoint.") + self.assertTrue(line_number == self.line, "Hit the first breakpoint.") my_var = cur_frame.FindVariable("my") self.assertTrue(my_var, "Made a variable object for my") @@ -222,7 +273,9 @@ class FoundationTestCase(TestBase): my_str_value = int(my_str_var.GetValue(), 0) - self.assertTrue(str_value == my_str_value, "Got the correct value for my->str") + self.assertTrue( + str_value == my_str_value, + "Got the correct value for my->str") def test_expression_lookups_objc(self): """Test running an expression detect spurious debug info lookups (DWARF).""" @@ -231,32 +284,43 @@ class FoundationTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at -[MyString initWithNSString:]. - lldbutil.run_break_set_by_symbol (self, '-[MyString initWithNSString:]', num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, + '-[MyString initWithNSString:]', + num_expected_locations=1, + sym_exact=True) self.runCmd("run", RUN_SUCCEEDED) global file_index # Log any DWARF lookups ++file_index - logfile = os.path.join(os.getcwd(), "dwarf-lookups-" + self.getArchitecture() + "-" + str(file_index) + ".txt") + logfile = os.path.join( + os.getcwd(), + "dwarf-lookups-" + + self.getArchitecture() + + "-" + + str(file_index) + + ".txt") self.runCmd("log enable -f %s dwarf lookups" % (logfile)) self.runCmd("expr self") self.runCmd("log disable dwarf lookups") - + def cleanup(): - if os.path.exists (logfile): - os.unlink (logfile) - + if os.path.exists(logfile): + os.unlink(logfile) + self.addTearDownHook(cleanup) - - if os.path.exists (logfile): + + if os.path.exists(logfile): f = open(logfile) lines = f.readlines() num_errors = 0 for line in lines: if string.find(line, "$__lldb") != -1: if num_errors == 0: - print("error: found spurious name lookups when evaluating an expression:") + print( + "error: found spurious name lookups when evaluating an expression:") num_errors += 1 print(line, end='') self.assertTrue(num_errors == 0, "Spurious lookups detected") diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py index 1ee01f7f35f6c..ce7e7742bfe82 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py @@ -5,28 +5,44 @@ Test more expression command sequences with objective-c. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + @skipUnlessDarwin class FoundationTestCase2(TestBase): mydir = TestBase.compute_mydir(__file__) - + def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line numbers to break at. self.lines = [] - self.lines.append(line_number('main.m', '// Break here for selector: tests')) - self.lines.append(line_number('main.m', '// Break here for NSArray tests')) - self.lines.append(line_number('main.m', '// Break here for NSString tests')) - self.lines.append(line_number('main.m', '// Break here for description test')) - self.lines.append(line_number('main.m', '// Set break point at this line')) + self.lines.append( + line_number( + 'main.m', + '// Break here for selector: tests')) + self.lines.append( + line_number( + 'main.m', + '// Break here for NSArray tests')) + self.lines.append( + line_number( + 'main.m', + '// Break here for NSString tests')) + self.lines.append( + line_number( + 'main.m', + '// Break here for description test')) + self.lines.append( + line_number( + 'main.m', + '// Set break point at this line')) def test_more_expr_commands(self): """More expression commands for objective-c.""" @@ -36,15 +52,16 @@ class FoundationTestCase2(TestBase): # Create a bunch of breakpoints. for line in self.lines: - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # Test_Selector: self.runCmd("thread backtrace") self.expect("expression (char *)sel_getName(sel)", - substrs = ["(char *)", - "length"]) + substrs=["(char *)", + "length"]) self.runCmd("process continue") @@ -59,8 +76,8 @@ class FoundationTestCase2(TestBase): # Test_MyString: self.runCmd("thread backtrace") self.expect("expression (char *)sel_getName(_cmd)", - substrs = ["(char *)", - "description"]) + substrs=["(char *)", + "description"]) self.runCmd("process continue") @@ -72,25 +89,25 @@ class FoundationTestCase2(TestBase): # Break inside Test_NSArray: line = self.lines[1] - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # Test_NSArray: self.runCmd("thread backtrace") self.expect("expression (int)[nil_mutable_array count]", - patterns = ["\(int\) \$.* = 0"]) + patterns=["\(int\) \$.* = 0"]) self.expect("expression (int)[array1 count]", - patterns = ["\(int\) \$.* = 3"]) + patterns=["\(int\) \$.* = 3"]) self.expect("expression (int)[array2 count]", - patterns = ["\(int\) \$.* = 3"]) + patterns=["\(int\) \$.* = 3"]) self.expect("expression (int)array1.count", - patterns = ["\(int\) \$.* = 3"]) + patterns=["\(int\) \$.* = 3"]) self.expect("expression (int)array2.count", - patterns = ["\(int\) \$.* = 3"]) + patterns=["\(int\) \$.* = 3"]) self.runCmd("process continue") - @expectedFailureAll(oslist=["macosx"], debug_info="gmodules", bugnumber="llvm.org/pr27861") def test_NSString_expr_commands(self): """Test expression commands for NSString.""" self.build() @@ -99,73 +116,90 @@ class FoundationTestCase2(TestBase): # Break inside Test_NSString: line = self.lines[2] - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # Test_NSString: self.runCmd("thread backtrace") self.expect("expression (int)[str length]", - patterns = ["\(int\) \$.* ="]) + patterns=["\(int\) \$.* ="]) self.expect("expression (int)[str_id length]", - patterns = ["\(int\) \$.* ="]) - self.expect("expression [str description]", - patterns = ["\(id\) \$.* = 0x"]) + patterns=["\(int\) \$.* ="]) + self.expect("expression (id)[str description]", + patterns=["\(id\) \$.* = 0x"]) self.expect("expression (id)[str_id description]", - patterns = ["\(id\) \$.* = 0x"]) + patterns=["\(id\) \$.* = 0x"]) self.expect("expression str.length") - self.expect("expression str.description") self.expect('expression str = @"new"') self.runCmd("image lookup -t NSString") - self.expect('expression str = [NSString stringWithCString: "new"]') + self.expect('expression str = (id)[NSString stringWithCString: "new"]') self.runCmd("process continue") - def test_MyString_dump(self): + @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>") + def test_MyString_dump_with_runtime(self): """Test dump of a known Objective-C object by dereferencing it.""" self.build() exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - + line = self.lines[4] - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) - - self.expect("expression --show-types -- *my", - patterns = ["\(MyString\) \$.* = ", "\(MyBase\)", "\(NSObject\)", "\(Class\)"]) + + self.expect( + "expression --show-types -- *my", + patterns=[ + "\(MyString\) \$.* = ", + "\(MyBase\)"]) self.runCmd("process continue") - @expectedFailureAll(archs=["i[3-6]86"]) - def test_NSError_po(self): - """Test that po of the result of an unknown method doesn't require a cast.""" + @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>") + def test_runtime_types(self): + """Test commands that require runtime types""" self.build() exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - line = self.lines[4] - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + # Break inside Test_NSString: + line = self.lines[2] + lldbutil.run_break_set_by_source_regexp( + self, "NSString tests") self.runCmd("run", RUN_SUCCEEDED) - self.expect('po [NSError errorWithDomain:@"Hello" code:35 userInfo:@{@"NSDescription" : @"be completed."}]', - substrs = ["Error Domain=Hello", "Code=35", "be completed."]) + # Test_NSString: + self.runCmd("thread backtrace") + self.expect("expression [str length]", + patterns=["\(NSUInteger\) \$.* ="]) + self.expect("expression str.length") + self.expect('expression str = [NSString stringWithCString: "new"]') + self.expect( + 'po [NSError errorWithDomain:@"Hello" code:35 userInfo:@{@"NSDescription" : @"be completed."}]', + substrs=[ + "Error Domain=Hello", + "Code=35", + "be completed."]) self.runCmd("process continue") - + + @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>") def test_NSError_p(self): """Test that p of the result of an unknown method does require a cast.""" self.build() exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - + line = self.lines[4] - lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.m", line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) - self.expect("p [NSError thisMethodIsntImplemented:0]", - error = True, - patterns = ["no known method", "cast the message send to the method's return type"]) + self.expect("p [NSError thisMethodIsntImplemented:0]", error=True, patterns=[ + "no known method", "cast the message send to the method's return type"]) self.runCmd("process continue") diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py index 13ef44f195bbd..8ef9f39434e3d 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py @@ -5,14 +5,15 @@ Test SBValue.GetObjectDescription() with the value from SBTarget.FindGlobalVaria from __future__ import print_function - -import os, time +import os +import time import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjectDescriptionAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,7 +23,8 @@ class ObjectDescriptionAPITestCase(TestBase): TestBase.setUp(self) # Find the line number to break at. self.source = 'main.m' - self.line = line_number(self.source, '// Set break point at this line.') + self.line = line_number( + self.source, '// Set break point at this line.') # rdar://problem/10857337 @skipUnlessDarwin @@ -42,11 +44,13 @@ class ObjectDescriptionAPITestCase(TestBase): self.assertTrue(breakpoint, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) # Make sure we hit our breakpoint: - thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint) - self.assertTrue (len(thread_list) == 1) + thread_list = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint) + self.assertTrue(len(thread_list) == 1) thread = thread_list[0] frame0 = thread.GetFrameAtIndex(0) @@ -59,7 +63,8 @@ class ObjectDescriptionAPITestCase(TestBase): print("val:", v) print("object description:", v.GetObjectDescription()) if v.GetName() == 'my_global_str': - self.assertTrue(v.GetObjectDescription() == 'This is a global string') + self.assertTrue(v.GetObjectDescription() == + 'This is a global string') # But not here! value_list2 = target.FindGlobalVariables('my_global_str', 3) @@ -69,4 +74,5 @@ class ObjectDescriptionAPITestCase(TestBase): print("val:", v) print("object description:", v.GetObjectDescription()) if v.GetName() == 'my_global_str': - self.assertTrue(v.GetObjectDescription() == 'This is a global string') + self.assertTrue(v.GetObjectDescription() == + 'This is a global string') diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py index 8b37f9309ac60..334ebba8e642b 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py @@ -5,19 +5,23 @@ Test that Objective-C methods from the runtime work correctly. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + @skipUnlessDarwin class RuntimeTypesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["macosx"], debug_info="gmodules", bugnumber="llvm.org/pr27862") + @expectedFailureAll( + oslist=["macosx"], + debug_info="gmodules", + bugnumber="llvm.org/pr27862") def test_break(self): """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" if self.getArchitecture() != 'x86_64': @@ -28,23 +32,31 @@ class RuntimeTypesTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at -[MyString description]. - lldbutil.run_break_set_by_symbol (self, '-[MyString description]', num_expected_locations=1, sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, + '-[MyString description]', + num_expected_locations=1, + sym_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The backtrace should show we stop at -[MyString description]. self.expect("thread backtrace", "Stop at -[MyString description]", - substrs = ["a.out`-[MyString description]"]) + substrs=["a.out`-[MyString description]"]) # Use runtime information about NSString. # The length property should be usable. self.expect("expression str.length", VARIABLES_DISPLAYED_CORRECTLY, - patterns = [r"(\(unsigned long long\))|\(NSUInteger\)"]) + patterns=[r"(\(unsigned long long\))|\(NSUInteger\)"]) # Static methods on NSString should work. - self.expect("expr [NSString stringWithCString:\"foo\" encoding:1]", VALID_TYPE, - substrs = ["(id)", "$1"]) + self.expect( + "expr [NSString stringWithCString:\"foo\" encoding:1]", + VALID_TYPE, + substrs=[ + "(id)", + "$1"]) self.expect("po $1", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["foo"]) + substrs=["foo"]) diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py index b75a874c81450..6e5bc4d9fb0f7 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py @@ -5,7 +5,6 @@ Test symbol table access for main.m. from __future__ import print_function - import os import time @@ -14,6 +13,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + @skipUnlessDarwin class FoundationSymtabTestCase(TestBase): @@ -23,7 +23,8 @@ class FoundationSymtabTestCase(TestBase): '-[MyString dealloc]', '-[MyString description]', '-[MyString descriptionPauses]', # synthesized property - '-[MyString setDescriptionPauses:]', # synthesized property + # synthesized property + '-[MyString setDescriptionPauses:]', 'Test_Selector', 'Test_NSString', 'Test_MyString', @@ -42,7 +43,8 @@ class FoundationSymtabTestCase(TestBase): self.assertTrue(target, VALID_TARGET) # Launch the process, and do not stop at the entry point. - process = target.LaunchSimple (None, None, self.get_process_working_directory()) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) # # Exercise Python APIs to access the symbol table entries. |