[Lldb-commits] [lldb] 42b9a68 - [lldb][NFC] Use expect_expr in more tests
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 17 04:15:18 PDT 2020
Author: Raphael Isemann
Date: 2020-08-17T13:14:57+02:00
New Revision: 42b9a683523628bfbb4f7447c0ca9607f3eee83f
URL: https://github.com/llvm/llvm-project/commit/42b9a683523628bfbb4f7447c0ca9607f3eee83f
DIFF: https://github.com/llvm/llvm-project/commit/42b9a683523628bfbb4f7447c0ca9607f3eee83f.diff
LOG: [lldb][NFC] Use expect_expr in more tests
Added:
Modified:
lldb/test/API/commands/expression/argument_passing_restrictions/TestArgumentPassingRestrictions.py
lldb/test/API/commands/expression/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
lldb/test/API/commands/expression/expr-in-syscall/TestExpressionInSyscall.py
lldb/test/API/commands/expression/function_template_specialization_temp_args/TestFunctionTemplateSpecializationTempArgs.py
lldb/test/API/commands/expression/ignore-artificial-constructors/main.cpp
lldb/test/API/lang/cpp/namespace/TestNamespace.py
lldb/test/API/lang/objc/objc_direct-methods/main.m
Removed:
################################################################################
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 858f2785be84..1e2fa1bb1862 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 @@ def test_argument_passing_restrictions(self):
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 b8eaf51d3e2e..7c1a4e847923 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 @@ def test_cast_int_to_anonymous_enum(self):
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 7b5db6c45434..a8ed94791463 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 @@ def expr_syscall(self):
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 bd5bc0ec72a9..ecbc7ead6dcb 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 @@ def test_function_template_specialization_temp_args(self):
(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 41457ebe1dad..16ddeb1bc081 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 2221755fad33..87d9a2578639 100644
--- a/lldb/test/API/lang/cpp/namespace/TestNamespace.py
+++ b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
@@ -152,11 +152,11 @@ def test_with_run_command(self):
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 @@ def test_with_run_command(self):
# 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 6799f22500c9..5d8ff17bb43e 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 @@ @implementation Foo
-(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;
}
More information about the lldb-commits
mailing list