diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py | 113 |
1 files changed, 73 insertions, 40 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py b/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py index 1ee01f7f35f..8f836a1da73 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py +++ b/lldb/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,29 @@ 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") + @expectedFailureAll( + oslist=["macosx"], + debug_info="gmodules", + bugnumber="llvm.org/pr27861") def test_NSString_expr_commands(self): """Test expression commands for NSString.""" self.build() @@ -99,20 +120,21 @@ 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\) \$.* ="]) + patterns=["\(int\) \$.* ="]) self.expect("expression [str description]", - patterns = ["\(id\) \$.* = 0x"]) + 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"') @@ -125,15 +147,21 @@ class FoundationTestCase2(TestBase): 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\)", + "\(NSObject\)", + "\(Class\)"]) self.runCmd("process continue") @expectedFailureAll(archs=["i[3-6]86"]) @@ -142,30 +170,35 @@ class FoundationTestCase2(TestBase): 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('po [NSError errorWithDomain:@"Hello" code:35 userInfo:@{@"NSDescription" : @"be completed."}]', - substrs = ["Error Domain=Hello", "Code=35", "be completed."]) + self.expect( + 'po [NSError errorWithDomain:@"Hello" code:35 userInfo:@{@"NSDescription" : @"be completed."}]', + substrs=[ + "Error Domain=Hello", + "Code=35", + "be completed."]) self.runCmd("process continue") - + 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") |