[lldb] Modernize TestVLA.py

Use expect_expr/var_path instead of regular expect and substring checks
This commit is contained in:
Pavel Labath 2021-10-27 12:47:11 +02:00
parent e1acadb61d
commit 560221ac7f
1 changed files with 11 additions and 6 deletions

View 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)