summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-09-25 13:33:50 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-09-25 13:33:50 +0000
commit6f9f8f411fe7f0fd6cf7fd39b259ba1c56569421 (patch)
treed6869fe89825304ab6ec58be3e325d1d5e542a46 /lldb/packages/Python/lldbsuite/test
parent2cec4b58f5ce7d5c843dbfb753b0acb29c81cfc0 (diff)
downloadbcm5719-llvm-6f9f8f411fe7f0fd6cf7fd39b259ba1c56569421.tar.gz
bcm5719-llvm-6f9f8f411fe7f0fd6cf7fd39b259ba1c56569421.zip
[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
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile4
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py18
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m17
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile2
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py21
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp7
6 files changed, 69 insertions, 0 deletions
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 <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
+}
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.
+}
OpenPOWER on IntegriCloud