[Lldb-commits] [lldb] 81b0bec - [lldb/Test] Fix substrs order in self.expect for more tests (NFC)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 31 12:45:00 PST 2020


Author: Jonas Devlieghere
Date: 2020-01-31T12:44:24-08:00
New Revision: 81b0becaaee65fa5342eca6c2dc7855852a92372

URL: https://github.com/llvm/llvm-project/commit/81b0becaaee65fa5342eca6c2dc7855852a92372
DIFF: https://github.com/llvm/llvm-project/commit/81b0becaaee65fa5342eca6c2dc7855852a92372.diff

LOG: [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.

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
    lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py
    lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
    lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py
    lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py
    lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
    lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
    lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py

Removed: 
    


################################################################################
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 895f4fa1e374..9f0ba1116867 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 @@ def test_bad_command_lines(self):
         """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 @@ def do_test(self):
         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 @@ def do_test(self):
         # 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 @@ def do_test_depths(self):
         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 @@ def do_test_depths(self):
         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 @@ def do_test_cli(self):
         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 173442830810..4b36d02da14d 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 @@ def cleanup():
             '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 9d4759100ce2..0318ec96ec91 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 @@ def cleanup():
             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 @@ def cleanup():
         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 @@ def cleanup():
         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 @@ def cleanup():
         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 @@ def cleanup():
         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 @@ def cleanup():
         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 2e8ca4591c90..feac24be836d 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 @@ def cleanup():
             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 @@ def cleanup():
             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 400607d84eb0..626e6cd16e8f 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 @@ def cleanup():
             '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 53df271fdcb1..c1d308b98ffe 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 @@ def cleanup():
 
         # 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 3044e5e2a762..f7b4cd2e1543 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 @@ def recursive_inferior_crashing(self):
             "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 @@ def recursive_inferior_crashing_expr(self):
         # 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 e3751e02c45f..6a5a2902d5cd 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 @@ def mtc_tests(self):
 
         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:])


        


More information about the lldb-commits mailing list