From 1463341f4bd7a584bfb07ad13c1c84ecfc7cb664 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 31 Jan 2020 13:26:51 -0800 Subject: [PATCH] [lldb/Test] Fix substrs order in self.expect for the remaining tests (NFC) Currently the substrs parameter takes a list of strings that need to be found but the ordering isn't checked. D73766 might change that so this changes a several tests so that the order of the strings in the substrs list is in the order in which they appear in the output. --- .../command/TestWatchpointCommandLLDB.py | 11 +- .../TestDataFormatterAdv.py | 40 ++++-- .../data-formatter-cpp/TestDataFormatterCpp.py | 9 +- .../data-formatter-objc/TestDataFormatterObjCCF.py | 22 +-- .../TestDataFormatterObjCNSContainer.py | 20 ++- .../TestDataFormatterObjCNSError.py | 2 +- .../libcxx/map/TestDataFormatterLibccMap.py | 142 +++++++++----------- .../multimap/TestDataFormatterLibccMultiMap.py | 149 +++++++++------------ .../multiset/TestDataFormatterLibcxxMultiSet.py | 10 +- 9 files changed, 193 insertions(+), 212 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py b/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py index cb5a535b730..b604d567b8c 100644 --- a/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py +++ b/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py @@ -1,4 +1,4 @@ -""" +""" Test 'watchpoint command'. """ @@ -83,9 +83,12 @@ class WatchpointLLDBCommandTestCase(TestBase): substrs=['stop reason = watchpoint']) # Check that the watchpoint snapshoting mechanism is working. - self.expect("watchpoint list -v", - substrs=['old value:', ' = 0', - 'new value:', ' = 1']) + self.expect( + "watchpoint list -v", + substrs=[ + 'old value: 0', 'new value: 1', 'hw_index = 0', + 'hit_count = 1', 'ignore_count = 0' + ]) # The watchpoint command "forced" our global variable 'cookie' to # become 777. diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index 246ebb3d4ae..d29547bb605 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -147,15 +147,30 @@ class AdvDataFormatterTestCase(TestBase): self.runCmd("type summary add -c -x \"i_am_cool \[[0-9]\]\"") self.runCmd("type summary add -c i_am_cool") - self.expect("frame variable cool_array", - substrs=['[0]', - '[1]', - '[2]', - '[3]', - '[4]', - 'integer', - 'character', - 'floating']) + self.expect( + "frame variable cool_array", + substrs=[ + '[0]', + 'integer', + 'floating', + 'character', + '[1]', + 'integer', + 'floating', + 'character', + '[2]', + 'integer', + 'floating', + 'character', + '[3]', + 'integer', + 'floating', + 'character', + '[4]', + 'integer', + 'floating', + 'character', + ]) self.runCmd( "type summary add --summary-string \"int = ${*var.int_pointer}, float = ${*var.float_pointer}\" IWrapPointers") @@ -315,11 +330,12 @@ class AdvDataFormatterTestCase(TestBase): matching=True, substrs=[ 'e_2', - 'n_2', - 'r_2', 'i_2', 'k_2', - 'o_2']) + 'n_2', + 'o_2', + 'r_2', + ]) self.expect( 'frame variable a_long_guy --show-all-children', matching=False, diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py index 733c427cdaa..7a82991a1c8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py @@ -56,12 +56,9 @@ class CppDataFormatterTestCase(TestBase): self.runCmd("type format add -C yes -f c Type1") # The type format list should show our custom formats. - self.expect("type format list", - substrs=['RealNumber', - 'Speed', - 'BitField', - 'Type1', - 'Type2']) + self.expect( + "type format list", + substrs=['Speed', 'BitField', 'RealNumber', 'Type2', 'Type1']) self.expect("frame variable", patterns=['\(Speed\) SPILookHex = 0x[0-9a-f]+' # Speed should look hex-ish now. diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py index 8671146b649..5b82bb6528f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py @@ -31,6 +31,7 @@ class ObjCDataFormatterCF(ObjCDataFormatterTestCase): # check formatters for common Objective-C types expect_strings = [ '(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds', + '(CFGregorianDate) cf_greg_date = @"4/11/1985 2:0:0"', '(CFRange) cf_range = location=4 length=4', '(NSPoint) ns_point = (x = 4, y = 4)', '(NSRange) ns_range = location=4, length=4', @@ -43,17 +44,16 @@ class ObjCDataFormatterCF(ObjCDataFormatterTestCase): '(Rect) rect = (t=4, l=8, b=4, r=7)', '(Rect *) rect_ptr = (t=4, l=8, b=4, r=7)', '(Point) point = (v=7, h=12)', '(Point *) point_ptr = (v=7, h=12)', - '1985', 'foo_selector_impl' + '(SEL) foo_selector = "foo_selector_impl"' ] - if self.getArchitecture() in ['i386', 'x86_64']: - expect_strings.append('(HIPoint) hi_point = (x=7, y=12)') - expect_strings.append( - '(HIRect) hi_rect = origin=(x = 3, y = 5) size=(width = 4, height = 6)' - ) - expect_strings.append( - '(RGBColor) rgb_color = red=3 green=56 blue=35') - expect_strings.append( - '(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35') - self.expect("frame variable", substrs=expect_strings) + + if self.getArchitecture() in ['i386', 'x86_64']: + extra_string = [ + '(RGBColor) rgb_color = red=3 green=56 blue=35', + '(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35', + '(HIPoint) hi_point = (x=7, y=12)', + '(HIRect) hi_rect = origin=(x = 3, y = 5) size=(width = 4, height = 6)', + ] + self.expect("frame variable", substrs=extra_string) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py index 2bd22ff3abd..52170082238 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py @@ -23,14 +23,20 @@ class ObjCDataFormatterNSContainer(ObjCDataFormatterTestCase): self.expect( 'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary cfarray_ref mutable_array_ref', substrs=[ - '(NSArray *) newArray = ', '@"50 elements"', - '(NSDictionary *) newDictionary = ', ' 12 key/value pairs', + '(NSArray *) newArray = ', + ' @"50 elements"', + '(NSDictionary *) nsDictionary = ', + ' 2 key/value pairs', + '(NSDictionary *) newDictionary = ', + ' 12 key/value pairs', + '(CFDictionaryRef) cfDictionaryRef = ', + ' 3 key/value pairs', '(NSDictionary *) newMutableDictionary = ', - ' 21 key/value pairs', '(NSDictionary *) nsDictionary = ', - ' 2 key/value pairs', '(CFDictionaryRef) cfDictionaryRef = ', - ' 3 key/value pairs', '(CFArrayRef) cfarray_ref = ', - '@"3 elements"', '(CFMutableArrayRef) mutable_array_ref = ', - '@"11 elements"' + ' 21 key/value pairs', + '(CFArrayRef) cfarray_ref = ', + ' @"3 elements"', + '(CFMutableArrayRef) mutable_array_ref = ', + ' @"11 elements"', ]) self.expect( diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py index df380aefd88..2da1b5130a9 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py @@ -32,4 +32,4 @@ class ObjCDataFormatterNSError(ObjCDataFormatterTestCase): self.expect( 'frame variable nserror->_userInfo --ptr-depth 1 -d run-target', - substrs=['@"a"', '@"b"', "1", "2"]) + substrs=['@"a"', "1", '@"b"', "2"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py index d9da0c3886e..5cd6e45bf8a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py @@ -152,35 +152,27 @@ class LibcxxMapDataFormatterTestCase(TestBase): lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable si", - substrs=['%s::map' % ns, 'size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) - - self.expect("p si", - substrs=['%s::map' % ns, 'size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + self.expect( + "frame variable si", + substrs=[ + '%s::map' % ns, + 'size=4', + '[0] = (first = "one", second = 1)', + '[1] = (first = "three", second = 3)', + '[2] = (first = "two", second = 2)', + '[3] = (first = "zero", second = 0)', + ]) + + self.expect( + "p si", + substrs=[ + '%s::map' % ns, + 'size=4', + '[0] = (first = "one", second = 1)', + '[1] = (first = "three", second = 3)', + '[2] = (first = "two", second = 2)', + '[3] = (first = "zero", second = 0)', + ]) # check that MightHaveChildren() gets it right self.assertTrue( @@ -214,35 +206,27 @@ class LibcxxMapDataFormatterTestCase(TestBase): lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable is", - substrs=['%s::map' % ns, 'size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) - - self.expect("p is", - substrs=['%s::map' % ns, 'size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) + self.expect( + "frame variable is", + substrs=[ + '%s::map' % ns, + 'size=4', + '[0] = (first = 1, second = "is")', + '[1] = (first = 2, second = "smart")', + '[2] = (first = 3, second = "!!!")', + '[3] = (first = 85, second = "goofy")', + ]) + + self.expect( + "p is", + substrs=[ + '%s::map' % ns, + 'size=4', + '[0] = (first = 1, second = "is")', + '[1] = (first = 2, second = "smart")', + '[2] = (first = 3, second = "!!!")', + '[3] = (first = 85, second = "goofy")', + ]) # check that MightHaveChildren() gets it right self.assertTrue( @@ -276,29 +260,25 @@ class LibcxxMapDataFormatterTestCase(TestBase): lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ss", - substrs=['%s::map' % ns, 'size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) - - self.expect("p ss", - substrs=['%s::map' % ns, 'size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) + self.expect( + "frame variable ss", + substrs=[ + '%s::map' % ns, + 'size=3', + '[0] = (first = "casa", second = "house")', + '[1] = (first = "ciao", second = "hello")', + '[2] = (first = "gatto", second = "cat")', + ]) + + self.expect( + "p ss", + substrs=[ + '%s::map' % ns, + 'size=3', + '[0] = (first = "casa", second = "house")', + '[1] = (first = "ciao", second = "hello")', + '[2] = (first = "gatto", second = "cat")', + ]) # check that MightHaveChildren() gets it right self.assertTrue( diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py index 39adc04e49a..022a46bdd28 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py @@ -58,14 +58,14 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase): lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect('frame variable ii', - substrs=[multimap, 'size=2', - '[0] = ', - 'first = 0', - 'second = 0', - '[1] = ', - 'first = 1', - 'second = 1']) + self.expect( + 'frame variable ii', + substrs=[ + multimap, + 'size=2', + '[0] = (first = 0, second = 0)', + '[1] = (first = 1, second = 1)', + ]) lldbutil.continue_to_breakpoint(self.process(), bkpt) @@ -139,35 +139,24 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase): lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable si", - substrs=[multimap, 'size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + self.expect( + "frame variable si", + substrs=[ + multimap, + 'size=4', + '[0] = (first = "one", second = 1)', + '[1] = (first = "three", second = 3)', + '[2] = (first = "two", second = 2)', + '[3] = (first = "zero", second = 0)', + ]) self.expect("p si", substrs=[multimap, 'size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + '[0] = (first = "one", second = 1)', + '[1] = (first = "three", second = 3)', + '[2] = (first = "two", second = 2)', + '[3] = (first = "zero", second = 0)', + ]) # check that MightHaveChildren() gets it right self.assertTrue( @@ -201,35 +190,27 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase): lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable is", - substrs=[multimap, 'size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) - - self.expect("p is", - substrs=[multimap, 'size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) + self.expect( + "frame variable is", + substrs=[ + multimap, + 'size=4', + '[0] = (first = 1, second = "is")', + '[1] = (first = 2, second = "smart")', + '[2] = (first = 3, second = "!!!")', + '[3] = (first = 85, second = "goofy")', + ]) + + self.expect( + "p is", + substrs=[ + multimap, + 'size=4', + '[0] = (first = 1, second = "is")', + '[1] = (first = 2, second = "smart")', + '[2] = (first = 3, second = "!!!")', + '[3] = (first = 85, second = "goofy")', + ]) # check that MightHaveChildren() gets it right self.assertTrue( @@ -263,29 +244,25 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase): lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ss", - substrs=[multimap, 'size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) - - self.expect("p ss", - substrs=[multimap, 'size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) + self.expect( + "frame variable ss", + substrs=[ + multimap, + 'size=3', + '[0] = (first = "casa", second = "house")', + '[1] = (first = "ciao", second = "hello")', + '[2] = (first = "gatto", second = "cat")', + ]) + + self.expect( + "p ss", + substrs=[ + multimap, + 'size=3', + '[0] = (first = "casa", second = "house")', + '[1] = (first = "ciao", second = "hello")', + '[2] = (first = "gatto", second = "cat")', + ]) # check that MightHaveChildren() gets it right self.assertTrue( diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py index 621b22a538c..021307eb781 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py @@ -104,18 +104,20 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase): "frame variable ss", substrs=[ "size=4", + '[0] = "a"', + '[1] = "a very long string is right here"', '[2] = "b"', '[3] = "c"', - '[0] = "a"', - '[1] = "a very long string is right here"']) + ]) self.expect( "p ss", substrs=[ "size=4", + '[0] = "a"', + '[1] = "a very long string is right here"', '[2] = "b"', '[3] = "c"', - '[0] = "a"', - '[1] = "a very long string is right here"']) + ]) self.expect("frame variable ss[2]", substrs=[' = "b"']) lldbutil.continue_to_breakpoint(process, bkpt) self.expect( -- 2.11.0