[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
This commit is contained in:
Raphael Isemann 2019-09-25 13:33:50 +00:00
parent 2cec4b58f5
commit 6f9f8f411f
6 changed files with 69 additions and 0 deletions
lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup

View File

@ -0,0 +1,4 @@
OBJC_SOURCES := main.m
LD_EXTRAS := -lobjc -framework Foundation
include Makefile.rules

View File

@ -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"])

View File

@ -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
}

View File

@ -0,0 +1,2 @@
CXX_SOURCES := main.cpp
include Makefile.rules

View File

@ -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"])

View File

@ -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.
}