Author: teemperor Date: Wed Sep 25 06:33:50 2019 New Revision: 372869 URL: http://llvm.org/viewvc/llvm-project?rev=372869&view=rev Log: [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). Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/ lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/ lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/ lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile?rev=372869&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile Wed Sep 25 06:33:50 2019 @@ -0,0 +1,4 @@ +OBJC_SOURCES := main.m +LD_EXTRAS := -lobjc -framework Foundation + +include Makefile.rules Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py?rev=372869&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py Wed Sep 25 06:33:50 2019 @@ -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"]) Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m?rev=372869&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m Wed Sep 25 06:33:50 2019 @@ -0,0 +1,17 @@ +#import <Foundation/Foundation.h> + +@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 +} Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile?rev=372869&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile Wed Sep 25 06:33:50 2019 @@ -0,0 +1,2 @@ +CXX_SOURCES := main.cpp +include Makefile.rules Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py?rev=372869&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py Wed Sep 25 06:33:50 2019 @@ -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"]) Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp?rev=372869&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp Wed Sep 25 06:33:50 2019 @@ -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. +} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits