From 42b9a683523628bfbb4f7447c0ca9607f3eee83f Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Mon, 17 Aug 2020 13:08:40 +0200 Subject: [PATCH] [lldb][NFC] Use expect_expr in more tests --- .../TestArgumentPassingRestrictions.py | 8 +++---- .../TestCastIntToAnonymousEnum.py | 2 +- .../expr-in-syscall/TestExpressionInSyscall.py | 5 ++-- .../TestFunctionTemplateSpecializationTempArgs.py | 3 +-- .../ignore-artificial-constructors/main.cpp | 2 +- lldb/test/API/lang/cpp/namespace/TestNamespace.py | 23 +++++++----------- lldb/test/API/lang/objc/objc_direct-methods/main.m | 28 +++++++++++----------- 7 files changed, 32 insertions(+), 39 deletions(-) diff --git a/lldb/test/API/commands/expression/argument_passing_restrictions/TestArgumentPassingRestrictions.py b/lldb/test/API/commands/expression/argument_passing_restrictions/TestArgumentPassingRestrictions.py index 858f278..1e2fa1b 100644 --- a/lldb/test/API/commands/expression/argument_passing_restrictions/TestArgumentPassingRestrictions.py +++ b/lldb/test/API/commands/expression/argument_passing_restrictions/TestArgumentPassingRestrictions.py @@ -26,8 +26,8 @@ class TestArgumentPassingRestrictions(TestBase): lldbutil.run_to_source_breakpoint(self, '// break here', lldb.SBFileSpec("main.cpp")) - self.expect("expr returnPassByRef()", - substrs=['(PassByRef)', '= 11223344']) + self.expect_expr("returnPassByRef()", result_type="PassByRef", result_children=[ + ValueCheck(name="x", value="11223344") + ]) - self.expect("expr takePassByRef(p)", - substrs=['(int)', '= 42']) + self.expect_expr("takePassByRef(p)", result_type="int", result_value="42") diff --git a/lldb/test/API/commands/expression/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py b/lldb/test/API/commands/expression/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py index b8eaf51..7c1a4e8 100644 --- a/lldb/test/API/commands/expression/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py +++ b/lldb/test/API/commands/expression/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py @@ -19,4 +19,4 @@ class TestCastIntToAnonymousEnum(TestBase): lldbutil.run_to_source_breakpoint(self, '// break here', lldb.SBFileSpec("main.cpp", False)) - self.expect("expr (flow_e)0", substrs=['(flow_e) $0 = A']) + self.expect_expr("(flow_e)0", result_type="flow_e", result_value="A") diff --git a/lldb/test/API/commands/expression/expr-in-syscall/TestExpressionInSyscall.py b/lldb/test/API/commands/expression/expr-in-syscall/TestExpressionInSyscall.py index 7b5db6c..a8ed947 100644 --- a/lldb/test/API/commands/expression/expr-in-syscall/TestExpressionInSyscall.py +++ b/lldb/test/API/commands/expression/expr-in-syscall/TestExpressionInSyscall.py @@ -74,9 +74,8 @@ class ExprSyscallTestCase(TestBase): thread = process.GetSelectedThread() # try evaluating a couple of expressions in this state - self.expect("expr release_flag = 1", substrs=[" = 1"]) - self.expect("print (int)getpid()", - substrs=[str(process.GetProcessID())]) + self.expect_expr("release_flag = 1", result_value="1") + self.expect_expr("(int)getpid()", result_value=str(process.GetProcessID())) # and run the process to completion process.Continue() diff --git a/lldb/test/API/commands/expression/function_template_specialization_temp_args/TestFunctionTemplateSpecializationTempArgs.py b/lldb/test/API/commands/expression/function_template_specialization_temp_args/TestFunctionTemplateSpecializationTempArgs.py index bd5bc0e..ecbc7ea 100644 --- a/lldb/test/API/commands/expression/function_template_specialization_temp_args/TestFunctionTemplateSpecializationTempArgs.py +++ b/lldb/test/API/commands/expression/function_template_specialization_temp_args/TestFunctionTemplateSpecializationTempArgs.py @@ -13,5 +13,4 @@ class TestFunctionTemplateSpecializationTempArgs(TestBase): (self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, '// break here', lldb.SBFileSpec("main.cpp", False)) - self.expect("expr p0", - substrs=['(VType) $0 = {}']) + self.expect_expr("p0", result_type="VType", result_children=[]) diff --git a/lldb/test/API/commands/expression/ignore-artificial-constructors/main.cpp b/lldb/test/API/commands/expression/ignore-artificial-constructors/main.cpp index 41457eb..16ddeb1 100644 --- a/lldb/test/API/commands/expression/ignore-artificial-constructors/main.cpp +++ b/lldb/test/API/commands/expression/ignore-artificial-constructors/main.cpp @@ -6,5 +6,5 @@ struct Foo { int main() { Foo f; // Try to construct foo in our expression. - return 0; //%self.expect("expr Foo()", substrs=["(Foo) $0 = {}"]) + return 0; //%self.expect_expr("Foo()", result_type="Foo", result_children=[]) } diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespace.py b/lldb/test/API/lang/cpp/namespace/TestNamespace.py index 2221755..87d9a25 100644 --- a/lldb/test/API/lang/cpp/namespace/TestNamespace.py +++ b/lldb/test/API/lang/cpp/namespace/TestNamespace.py @@ -152,11 +152,11 @@ class NamespaceTestCase(TestBase): self.runToBkpt("run") # Evaluate ns1::value - self.expect("expression -- value", startstr="(int) $0 = 100") + self.expect_expr("value", result_value="100") self.runToBkpt("continue") # Evaluate ns2::value - self.expect("expression -- value", startstr="(int) $1 = 200") + self.expect_expr("value", result_value="200") self.runToBkpt("continue") # On Mac OS X, gcc 4.2 emits the wrong debug info with respect to @@ -206,28 +206,23 @@ class NamespaceTestCase(TestBase): # rdar://problem/8660275 # test/namespace: 'expression -- i+j' not working # This has been fixed. - self.expect("expression -- i + j", - startstr="(int) $2 = 7") + self.expect_expr("i + j", result_type="int", result_value="7") # (int) $2 = 7 - self.runCmd("expression -- i") - self.runCmd("expression -- j") + self.expect_expr("i", result_value="3") + self.expect_expr("j", result_value="4") # rdar://problem/8668674 # expression command with fully qualified namespace for a variable does # not work - self.expect("expression -- ::i", VARIABLES_DISPLAYED_CORRECTLY, - patterns=[' = 3']) - self.expect("expression -- A::B::j", VARIABLES_DISPLAYED_CORRECTLY, - patterns=[' = 4']) + self.expect_expr("::i", result_value="3") + self.expect_expr("A::B::j", result_value="4") # expression command with function in anonymous namespace - self.expect("expression -- myanonfunc(3)", - patterns=[' = 6']) + self.expect_expr("myanonfunc(3)", result_value="6") # global namespace qualification with function in anonymous namespace - self.expect("expression -- ::myanonfunc(4)", - patterns=[' = 8']) + self.expect_expr("myanonfunc(4)", result_value="8") self.expect("p myanonfunc", patterns=['\(anonymous namespace\)::myanonfunc\(int\)']) diff --git a/lldb/test/API/lang/objc/objc_direct-methods/main.m b/lldb/test/API/lang/objc/objc_direct-methods/main.m index 6799f22..5d8ff17 100644 --- a/lldb/test/API/lang/objc/objc_direct-methods/main.m +++ b/lldb/test/API/lang/objc/objc_direct-methods/main.m @@ -18,13 +18,13 @@ const char *directCallConflictingName() { -(int) entryPoint { // Try calling directly with self. Same as in the main method otherwise. - return 0; //%self.expect("expr [self directCallNoArgs]", substrs=["called directCallNoArgs"]) - //%self.expect("expr [self directCallArgs: 1111]", substrs=["= 2345"]) - //%self.expect("expr side_effect = 0; [self directCallVoidReturn]; side_effect", substrs=["= 4321"]) - //%self.expect("expr [self directCallNSStringArg: str]", substrs=['@"some string"']) - //%self.expect("expr [self directCallIdArg: (id)str]", substrs=['@"some string appendix"']) - //%self.expect("expr [self directCallConflictingName]", substrs=["correct function"]) - //%self.expect("expr [self directCallWithCategory]", substrs=["called function with category"]) + return 0; //%self.expect_expr("[self directCallNoArgs]", result_summary='"called directCallNoArgs"') + //%self.expect_expr("[self directCallArgs: 1111]", result_value="2345") + //%self.expect_expr("side_effect = 0; [self directCallVoidReturn]; side_effect", result_value="4321") + //%self.expect_expr("[self directCallNSStringArg: str]", result_summary='@"some string"') + //%self.expect_expr("[self directCallIdArg: (id)str]", result_summary='@"some string appendix"') + //%self.expect_expr("[self directCallConflictingName]", result_summary='"correct function"') + //%self.expect_expr("[self directCallWithCategory]", result_summary='"called function with category"') } // Declare several objc_direct functions we can test. @@ -81,12 +81,12 @@ int main() [foo directCallVoidReturn]; [foo directCallNSStringArg: str]; [foo directCallIdArg: (id)str]; - [foo entryPoint]; //%self.expect("expr [foo directCallNoArgs]", substrs=["called directCallNoArgs"]) - //%self.expect("expr [foo directCallArgs: 1111]", substrs=["= 2345"]) - //%self.expect("expr side_effect = 0; [foo directCallVoidReturn]; side_effect", substrs=["= 4321"]) - //%self.expect("expr [foo directCallNSStringArg: str]", substrs=['@"some string"']) - //%self.expect("expr [foo directCallIdArg: (id)str]", substrs=['@"some string appendix"']) - //%self.expect("expr [foo directCallConflictingName]", substrs=["correct function"]) - //%self.expect("expr [foo directCallWithCategory]", substrs=["called function with category"]) + [foo entryPoint]; //%self.expect_expr("[foo directCallNoArgs]", result_summary='"called directCallNoArgs"') + //%self.expect_expr("[foo directCallArgs: 1111]", result_value="2345") + //%self.expect_expr("side_effect = 0; [foo directCallVoidReturn]; side_effect", result_value="4321") + //%self.expect_expr("[foo directCallNSStringArg: str]", result_summary='@"some string"') + //%self.expect_expr("[foo directCallIdArg: (id)str]", result_summary='@"some string appendix"') + //%self.expect_expr("[foo directCallConflictingName]", result_summary='"correct function"') + //%self.expect_expr("[foo directCallWithCategory]", result_summary='"called function with category"') return 0; } -- 2.7.4