From 6f9f8f411fe7f0fd6cf7fd39b259ba1c56569421 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Wed, 25 Sep 2019 13:33:50 +0000 Subject: [lldb][modern-type-lookup] Add two basic tests for modern-type-lookup The story so far: LLDB's modern type lookup mode has no (as in, 0%) test coverage. It was supposed to be tested by hardcoding the default to 'true' and then running the normal LLDB tests, but to my knowledge no one is doing that. As a around 130 tests seem to fail with this mode enabled, we also can't just enable it globally for now. As we touch the surrounding code all the time and also want to refactor parts of it, we should be a bit more ambitious with our testing efforts. So this patch adds two basic tests that enable this mode and do some basic expression parsing which should hopefully be basic enough to not break anywhere but still lets us know if this mode works at all (i.e. setting up the ExternalASTMerger in LLDB, using its basic import functionality to move declarations around and do some lookups). llvm-svn: 372869 --- .../modern-type-lookup/basic-objc/Makefile | 4 ++++ .../basic-objc/TestBasicObjcModernTypeLookup.py | 18 ++++++++++++++++++ .../modern-type-lookup/basic-objc/main.m | 17 +++++++++++++++++ .../modern-type-lookup/basic/Makefile | 2 ++ .../basic/TestBasicModernTypeLookup.py | 21 +++++++++++++++++++++ .../modern-type-lookup/basic/main.cpp | 7 +++++++ 6 files changed, 69 insertions(+) create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp (limited to 'lldb/packages/Python/lldbsuite/test/functionalities') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile new file mode 100644 index 00000000000..afecbf96948 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile @@ -0,0 +1,4 @@ +OBJC_SOURCES := main.m +LD_EXTRAS := -lobjc -framework Foundation + +include Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py new file mode 100644 index 00000000000..700b3ecbe6b --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py @@ -0,0 +1,18 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestBasicObjcModernTypeLookup(TestBase): + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessDarwin + def test(self): + self.build() + # Activate modern-type-lookup. + # FIXME: This has to happen before we create any target otherwise we crash... + self.runCmd("settings set target.experimental.use-modern-type-lookup true") + (target, process, thread, main_breakpoint) = lldbutil.run_to_source_breakpoint(self, + "break here", lldb.SBFileSpec("main.m")) + self.expect("expr 1", substrs=["(int) ", " = 1"]) + self.expect("expr (int)[Foo bar:22]", substrs=["(int) ", " = 44"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m new file mode 100644 index 00000000000..b427971e7be --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m @@ -0,0 +1,17 @@ +#import + +@interface Foo : NSObject ++(int) bar: (int) string; +@end + +@implementation Foo ++(int) bar: (int) x +{ + return x + x; +} +@end + +int main() { + NSLog(@"Hello World"); + return 0; // break here +} diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile new file mode 100644 index 00000000000..3d0b98f13f3 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile @@ -0,0 +1,2 @@ +CXX_SOURCES := main.cpp +include Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py new file mode 100644 index 00000000000..613fb95658b --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py @@ -0,0 +1,21 @@ +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class BasicModernTypeLookup(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def test(self): + self.build() + + # Activate modern-type-lookup. + self.runCmd("settings set target.experimental.use-modern-type-lookup true") + + lldbutil.run_to_source_breakpoint(self, + "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) + + # Test a few simple expressions that should still work with modern-type-lookup. + self.expect("expr 1", substrs=["(int) ", " = 1\n"]) + self.expect("expr f.x", substrs=["(int) ", " = 44\n"]) + self.expect("expr f", substrs=["(Foo) ", "x = 44"]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp new file mode 100644 index 00000000000..e0c3ead7f75 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp @@ -0,0 +1,7 @@ +struct Foo { int x; }; + +int main(int argc, char **argv) { + Foo f; + f.x = 44; + return f.x; // Set break point at this line. +} -- cgit v1.2.3