From 81b0becaaee65fa5342eca6c2dc7855852a92372 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 31 Jan 2020 12:44:24 -0800 Subject: [PATCH] [lldb/Test] Fix substrs order in self.expect for more 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. --- .../scripted_bkpt/TestScriptedResolver.py | 22 ++--- .../compactvectors/TestCompactVectors.py | 7 +- .../TestDataFormatterPythonSynth.py | 99 ++++++++++++++-------- .../nssetsynth/TestNSSetSynthetic.py | 24 +++--- .../data-formatter/poarray/TestPrintObjectArray.py | 7 +- .../synthcapping/TestSyntheticCapping.py | 19 +++-- .../recursive-inferior/TestRecursiveInferior.py | 4 +- .../functionalities/mtc/simple/TestMTCSimple.py | 8 +- 8 files changed, 116 insertions(+), 74 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py index 895f4fa..9f0ba11 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py @@ -38,7 +38,7 @@ class TestScriptedResolver(TestBase): """Make sure we get appropriate errors when we give invalid key/value options""" self.build() - self.do_test_bad_options() + self.do_test_bad_options() def make_target_and_import(self): target = lldbutil.run_to_breakpoint_make_target(self) @@ -110,7 +110,7 @@ class TestScriptedResolver(TestBase): module_list.Clear() file_list.Append(lldb.SBFileSpec("noFileOfThisName.xxx")) wrong.append(target.BreakpointCreateFromScript("resolver.Resolver", extra_args, module_list, file_list)) - + # Now make sure the CU level iteration obeys the file filters: file_list.Clear() module_list.Clear() @@ -142,7 +142,7 @@ class TestScriptedResolver(TestBase): # Now run to main and ensure we hit the breakpoints we should have: lldbutil.run_to_breakpoint_do_run(self, target, right[0]) - + # Test the hit counts: for i in range(0, len(right)): self.assertEqual(right[i].GetHitCount(), 1, "Breakpoint %d has the wrong hit count"%(i)) @@ -167,12 +167,12 @@ class TestScriptedResolver(TestBase): bkpt = target.BreakpointCreateFromScript("resolver.Resolver", extra_args, module_list, file_list) self.assertTrue(bkpt.GetNumLocations() > 0, "Resolver got no locations.") self.expect("script print(resolver.Resolver.got_files)", substrs=["2"], msg="Was only passed modules") - + # Make a breakpoint that asks for modules, check that we didn't get any files: bkpt = target.BreakpointCreateFromScript("resolver.ResolverModuleDepth", extra_args, module_list, file_list) self.assertTrue(bkpt.GetNumLocations() > 0, "ResolverModuleDepth got no locations.") self.expect("script print(resolver.Resolver.got_files)", substrs=["2"], msg="Was only passed modules") - + # Make a breakpoint that asks for compile units, check that we didn't get any files: bkpt = target.BreakpointCreateFromScript("resolver.ResolverCUDepth", extra_args, module_list, file_list) self.assertTrue(bkpt.GetNumLocations() > 0, "ResolverCUDepth got no locations.") @@ -187,7 +187,7 @@ class TestScriptedResolver(TestBase): bkpt = target.BreakpointCreateFromScript("resolver.ResolverFuncDepth", extra_args, module_list, file_list) self.assertTrue(bkpt.GetNumLocations() > 0, "ResolverFuncDepth got no locations.") self.expect("script print(resolver.Resolver.got_files)", substrs=["3"], msg="Was only passed modules") - self.expect("script print(resolver.Resolver.func_list)", substrs=["break_on_me", "main", "test_func"], msg="Saw all the functions") + self.expect("script print(resolver.Resolver.func_list)", substrs=['test_func', 'break_on_me', 'main'], msg="Saw all the functions") def do_test_cli(self): target = self.make_target_and_import() @@ -210,15 +210,15 @@ class TestScriptedResolver(TestBase): bp_se = bp_sc.GetLineEntry() self.assertEqual(bp_se.GetLine(), 12, "Got the right line number") self.assertEqual(bp_se.GetFileSpec().GetFilename(), "main.c", "Got the right filename") - + def do_test_bad_options(self): target = self.make_target_and_import() - self.expect("break set -P resolver.Resolver -k a_key", error = True, msg="Missing value at end", + self.expect("break set -P resolver.Resolver -k a_key", error = True, msg="Missing value at end", substrs=['Key: "a_key" missing value']) - self.expect("break set -P resolver.Resolver -v a_value", error = True, msg="Missing key at end", + self.expect("break set -P resolver.Resolver -v a_value", error = True, msg="Missing key at end", substrs=['Value: "a_value" missing matching key']) - self.expect("break set -P resolver.Resolver -v a_value -k a_key -v another_value", error = True, msg="Missing key among args", + self.expect("break set -P resolver.Resolver -v a_value -k a_key -v another_value", error = True, msg="Missing key among args", substrs=['Value: "a_value" missing matching key']) - self.expect("break set -P resolver.Resolver -k a_key -k a_key -v another_value", error = True, msg="Missing value among args", + self.expect("break set -P resolver.Resolver -k a_key -k a_key -v another_value", error = True, msg="Missing value among args", substrs=['Key: "a_key" missing value']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py index 1734428..4b36d02 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py @@ -48,13 +48,14 @@ class CompactVectorsFormattingTestCase(TestBase): 'frame variable', substrs=[ '(vFloat) valueFL = (1.25, 0, 0.25, 0)', + '(vDouble) valueDL = (1.25, 2.25)', '(int16_t [8]) valueI16 = (1, 0, 4, 0, 0, 1, 0, 4)', '(int32_t [4]) valueI32 = (1, 0, 4, 0)', - '(vDouble) valueDL = (1.25, 2.25)', '(vUInt8) valueU8 = (0x01, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)', '(vUInt16) valueU16 = (1, 0, 4, 0, 0, 1, 0, 4)', '(vUInt32) valueU32 = (1, 2, 3, 4)', - "(vSInt8) valueS8 = (1, 0, 4, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0)", + '(vSInt8) valueS8 = (1, 0, 4, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0)', '(vSInt16) valueS16 = (1, 0, 4, 0, 0, 1, 0, 4)', '(vSInt32) valueS32 = (4, 3, 2, 1)', - '(vBool32) valueBool32 = (0, 1, 0, 1)']) + '(vBool32) valueBool32 = (0, 1, 0, 1)', + ]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py index 9d47591..0318ec9 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py @@ -72,10 +72,13 @@ class PythonSynthDataFormatterTestCase(TestBase): fake_a_val = 0x00000100 # check that we get the two real vars and the fake_a variables - self.expect("frame variable f00_1", - substrs=['r = 34', - 'fake_a = %d' % fake_a_val, - 'a = 1']) + self.expect( + "frame variable f00_1", + substrs=[ + 'a = 1', + 'fake_a = %d' % fake_a_val, + 'r = 34', + ]) # check that we do not get the extra vars self.expect("frame variable f00_1", matching=False, @@ -110,10 +113,13 @@ class PythonSynthDataFormatterTestCase(TestBase): else: fake_a_val = 0x00000200 - self.expect("frame variable f00_1", - substrs=['r = 34', - 'fake_a = %d' % fake_a_val, - 'a = 2']) + self.expect( + "frame variable f00_1", + substrs=[ + 'a = 2', + 'fake_a = %d' % fake_a_val, + 'r = 34', + ]) # check that altering the object also alters fake_a self.runCmd("expr f00_1.a = 280") @@ -123,10 +129,13 @@ class PythonSynthDataFormatterTestCase(TestBase): else: fake_a_val = 0x00011800 - self.expect("frame variable f00_1", - substrs=['r = 34', - 'fake_a = %d' % fake_a_val, - 'a = 280']) + self.expect( + "frame variable f00_1", + substrs=[ + 'a = 280', + 'fake_a = %d' % fake_a_val, + 'r = 34', + ]) # check that expanding a pointer does the right thing if process.GetByteOrder() == lldb.eByteOrderLittle: @@ -134,14 +143,20 @@ class PythonSynthDataFormatterTestCase(TestBase): else: fake_a_val = 0x00000c00 - self.expect("frame variable --ptr-depth 1 f00_ptr", - substrs=['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) - self.expect("frame variable --ptr-depth 1 wrapper", - substrs=['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) + self.expect( + "frame variable --ptr-depth 1 f00_ptr", + substrs=[ + 'a = 12', + 'fake_a = %d' % fake_a_val, + 'r = 45', + ]) + self.expect( + "frame variable --ptr-depth 1 wrapper", + substrs=[ + 'a = 12', + 'fake_a = %d' % fake_a_val, + 'r = 45', + ]) # now add a filter.. it should fail self.expect("type filter add foo --child b --child j", error=True, @@ -151,14 +166,20 @@ class PythonSynthDataFormatterTestCase(TestBase): self.expect('frame variable f00_1', matching=False, substrs=['b = 1', 'j = 17']) - self.expect("frame variable --ptr-depth 1 f00_ptr", - substrs=['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) - self.expect("frame variable --ptr-depth 1 wrapper", - substrs=['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) + self.expect( + "frame variable --ptr-depth 1 f00_ptr", + substrs=[ + 'a = 12', + 'fake_a = %d' % fake_a_val, + 'r = 45', + ]) + self.expect( + "frame variable --ptr-depth 1 wrapper", + substrs=[ + 'a = 12', + 'fake_a = %d' % fake_a_val, + 'r = 45', + ]) # Test that the custom dereference operator for `wrapfoo` works through # the Python API. The synthetic children provider gets queried at @@ -207,14 +228,20 @@ class PythonSynthDataFormatterTestCase(TestBase): self.expect('frame variable f00_1', matching=False, substrs=['b = 2', 'j = 18']) - self.expect("frame variable --ptr-depth 1 f00_ptr", - substrs=['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) - self.expect("frame variable --ptr-depth 1 wrapper", - substrs=['r = 45', - 'fake_a = %d' % fake_a_val, - 'a = 12']) + self.expect( + "frame variable --ptr-depth 1 f00_ptr", + substrs=[ + 'a = 12', + 'fake_a = %d' % fake_a_val, + 'r = 45', + ]) + self.expect( + "frame variable --ptr-depth 1 wrapper", + substrs=[ + 'a = 12', + 'fake_a = %d' % fake_a_val, + 'r = 45', + ]) # check the listing self.expect('type synth list', diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py index 2e8ca45..feac24b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py @@ -56,13 +56,14 @@ class NSSetSyntheticTestCase(TestBase): substrs=[ '4 elements', '[0]', + 'hello', '[1]', + '(int)2', '[2]', + '(int)1', '[3]', - 'hello', 'world', - '(int)1', - '(int)2']) + ]) self.expect( 'frame variable mutable --ptr-depth 1 -d run -T', substrs=[ @@ -86,26 +87,27 @@ class NSSetSyntheticTestCase(TestBase): substrs=[ '4 elements', '[0]', + '(int)1', '[1]', + '(int)2', '[2]', - '[3]', 'hello', + '[3]', 'world', - '(int)1', - '(int)2']) + ]) self.runCmd("next") - self.expect('frame variable mutable', - substrs=['4 elements']) + self.expect('frame variable mutable', substrs=['4 elements']) self.expect( 'frame variable mutable --ptr-depth 1 -d run -T', substrs=[ '4 elements', '[0]', + '(int)1', '[1]', + '(int)2', '[2]', - '[3]', 'hello', + '[3]', 'world', - '(int)1', - '(int)2']) + ]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py index 400607d..626e6cd 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py @@ -99,10 +99,11 @@ class PrintObjectArrayTestCase(TestBase): 'expr --element-count 3 -d run --ptr-depth=1 -- objects', substrs=[ '3 elements', - '2 elements', - '2 key/value pairs', '3735928559', '4276993775', '3203398366', + '2 elements', '"Hello"', - '"World"']) + '"World"', + '2 key/value pairs', + ]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py index 53df271..c1d308b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py @@ -63,18 +63,23 @@ class SyntheticCappingTestCase(TestBase): # check that the synthetic children work, so we know we are doing the # right thing - self.expect("frame variable f00_1", - substrs=['r = 34', - 'fake_a = %d' % fake_a_val, - 'a = 1']) + self.expect( + "frame variable f00_1", + substrs=[ + 'a = 1', + 'fake_a = %d' % fake_a_val, + 'r = 34', + ]) # check that capping works self.runCmd("settings set target.max-children-count 2", check=False) self.expect("frame variable f00_1", - substrs=['...', - 'fake_a = %d' % fake_a_val, - 'a = 1']) + substrs=[ + 'a = 1', + 'fake_a = %d' % fake_a_val, + '...', + ]) self.expect("frame variable f00_1", matching=False, substrs=['r = 34']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py b/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py index 3044e5e..f7b4cd2 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py @@ -78,10 +78,11 @@ class CrashingRecursiveInferiorTestCase(TestBase): "thread backtrace all", substrs=[ stop_reason, + 'recursive_function', 'main', 'argc', 'argv', - 'recursive_function']) + ]) # And it should report the correct line number. self.expect("thread backtrace all", @@ -138,4 +139,3 @@ class CrashingRecursiveInferiorTestCase(TestBase): # of the inferior after a crash. self.expect("p i", startstr='(int) $0 =') - diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py b/lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py index e3751e0..6a5a290 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py @@ -46,7 +46,13 @@ class MTCSimpleTestCase(TestBase): self.expect( "thread info -s", - substrs=["instrumentation_class", "api_name", "class_name", "selector", "description"]) + substrs=[ + "api_name", + "class_name", + "description", + "instrumentation_class", + "selector" + ]) self.assertEqual(thread.GetStopReason(), lldb.eStopReasonInstrumentation) output_lines = self.res.GetOutput().split('\n') json_line = '\n'.join(output_lines[2:]) -- 2.7.4