[lldb] Modernize TestVLA.py
authorPavel Labath <pavel@labath.sk>
Wed, 27 Oct 2021 10:47:11 +0000 (12:47 +0200)
committerPavel Labath <pavel@labath.sk>
Wed, 27 Oct 2021 10:47:56 +0000 (12:47 +0200)
Use expect_expr/var_path instead of regular expect and substring checks

lldb/test/API/lang/c/vla/TestVLA.py

index 215eadc..758406d 100644 (file)
@@ -32,14 +32,19 @@ class TestVLA(TestBase):
         _, process, _, _ = lldbutil.run_to_source_breakpoint(
             self, "break here", lldb.SBFileSpec('main.c'))
 
-        def test(a, array):
+        def test(a):
+            children = []
             for i in range(a):
-                self.expect("fr v vla[%d]"%i, substrs=["int", "%d"%(a-i)])
-                self.expect("expr vla[%d]"%i, substrs=["int", "%d"%(a-i)])
-            self.expect("fr v vla", substrs=array)
+                name = "[%d]"%i
+                value = str(a-i)
+                self.expect_var_path("vla"+name, type="int", value=value)
+                self.expect_expr("vla"+name, result_type="int",
+                        result_value=value)
+                children.append(ValueCheck(name=name, value=value))
+            self.expect_var_path("vla", type="int[]", children=children)
             self.expect("expr vla", error=True, substrs=["incomplete"])
 
-        test(2, ["int[]", "[0] = 2, [1] = 1"])
+        test(2)
         process.Continue()
-        test(4, ["int[]", "[0] = 4, [1] = 3, [2] = 2, [3] = 1"])
+        test(4)