diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-07-13 19:26:17 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-07-13 19:26:17 +0000 |
commit | e75e363cb71a7339552b9d943e78ac62b737379b (patch) | |
tree | 29ec5bd173694acbbcbb8207114ef7ca189436ba /packages/Python/lldbsuite/test/functionalities | |
parent | 1b306c26ade71504511d2fa75b03dfaee77f9620 (diff) |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities')
9 files changed, 154 insertions, 2 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/mtc/simple/Makefile b/packages/Python/lldbsuite/test/functionalities/mtc/simple/Makefile new file mode 100644 index 0000000000000..5665652329dc0 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/mtc/simple/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +OBJC_SOURCES := main.m +LDFLAGS = $(CFLAGS) -lobjc -framework Foundation -framework AppKit + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py b/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py new file mode 100644 index 0000000000000..6a779ecfac5b2 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py @@ -0,0 +1,57 @@ +""" +Tests basic Main Thread Checker support (detecting a main-thread-only violation). +""" + +import os +import time +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbplatformutil import * +import json + + +class MTCSimpleTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessDarwin + def test(self): + self.mtc_dylib_path = findMainThreadCheckerDylib() + if self.mtc_dylib_path == "": + self.skipTest("This test requires libMainThreadChecker.dylib.") + + self.build() + self.mtc_tests() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + def mtc_tests(self): + # Load the test + exe = os.path.join(os.getcwd(), "a.out") + self.expect("file " + exe, patterns=["Current executable set to .*a.out"]) + + self.runCmd("env DYLD_INSERT_LIBRARIES=%s" % self.mtc_dylib_path) + self.runCmd("run") + + process = self.dbg.GetSelectedTarget().process + thread = process.GetSelectedThread() + frame = thread.GetSelectedFrame() + + self.expect("thread info", substrs=['stop reason = -[NSView superview] must be used from main thread only']) + + self.expect( + "thread info -s", + substrs=["instrumentation_class", "api_name", "class_name", "selector", "description"]) + self.assertEqual(thread.GetStopReason(), lldb.eStopReasonInstrumentation) + output_lines = self.res.GetOutput().split('\n') + json_line = '\n'.join(output_lines[2:]) + data = json.loads(json_line) + self.assertEqual(data["instrumentation_class"], "MainThreadChecker") + self.assertEqual(data["api_name"], "-[NSView superview]") + self.assertEqual(data["class_name"], "NSView") + self.assertEqual(data["selector"], "superview") + self.assertEqual(data["description"], "-[NSView superview] must be used from main thread only") diff --git a/packages/Python/lldbsuite/test/functionalities/mtc/simple/main.m b/packages/Python/lldbsuite/test/functionalities/mtc/simple/main.m new file mode 100644 index 0000000000000..651347cf74eeb --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/mtc/simple/main.m @@ -0,0 +1,15 @@ +#import <Foundation/Foundation.h> +#import <AppKit/AppKit.h> + +int main() { + NSView *view = [[NSView alloc] init]; + dispatch_group_t g = dispatch_group_create(); + dispatch_group_enter(g); + [NSThread detachNewThreadWithBlock:^{ + @autoreleasepool { + [view superview]; + } + dispatch_group_leave(g); + }]; + dispatch_group_wait(g, DISPATCH_TIME_FOREVER); +} diff --git a/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py b/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py index cf435a4aae911..1750bd31b3df6 100644 --- a/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py +++ b/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py @@ -31,8 +31,6 @@ class ReturnValueTestCase(TestBase): "<=", "3.6"], archs=["i386"]) - @expectedFailureAll(compiler="clang", compiler_version=["<=", "5.0.300080"], - triple='.*-android', archs=["i386"]) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") @add_test_categories(['pyapi']) def test_with_python(self): diff --git a/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py b/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py index efadea51f6696..79175562fe7ab 100644 --- a/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py +++ b/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py @@ -16,6 +16,7 @@ from lldbsuite.test import lldbutil class RaiseTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True def test_sigstop(self): self.build() @@ -29,6 +30,10 @@ class RaiseTestCase(TestBase): self.build() self.signal_test('SIGRTMIN', True) + def test_sigtrap(self): + self.build() + self.signal_test('SIGTRAP', True) + def launch(self, target, signal): # launch the process, do not stop at entry point. process = target.LaunchSimple( diff --git a/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c b/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c index 8827174e758e3..4203fe5d4c89e 100644 --- a/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c +++ b/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c @@ -10,6 +10,11 @@ void handler(int signo) int main (int argc, char *argv[]) { + if (signal(SIGTRAP, handler) == SIG_ERR) + { + perror("signal(SIGTRAP)"); + return 1; + } #ifndef __APPLE__ // Real time signals not supported on apple platforms. if (signal(SIGRTMIN, handler) == SIG_ERR) @@ -27,6 +32,8 @@ int main (int argc, char *argv[]) if (strcmp(argv[1], "SIGSTOP") == 0) raise(SIGSTOP); + else if (strcmp(argv[1], "SIGTRAP") == 0) + raise(SIGTRAP); #ifndef __APPLE__ else if (strcmp(argv[1], "SIGRTMIN") == 0) raise(SIGRTMIN); diff --git a/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/Makefile b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/Makefile new file mode 100644 index 0000000000000..6e7d19b6f48c2 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +C_SOURCES := main.c +CFLAGS_EXTRAS := -fsanitize=undefined -g + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py new file mode 100644 index 0000000000000..a5e5f572a9792 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py @@ -0,0 +1,49 @@ +""" +Test that hitting a UBSan issue while running user expression doesn't break the evaluation. +""" + +import os +import time +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil +import json + + +class UbsanUserExpressionTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessUndefinedBehaviorSanitizer + def test(self): + self.build() + self.ubsan_tests() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + self.line_breakpoint = line_number('main.c', '// breakpoint line') + + def ubsan_tests(self): + # Load the test + exe = os.path.join(os.getcwd(), "a.out") + self.expect( + "file " + exe, + patterns=["Current executable set to .*a.out"]) + + self.runCmd("breakpoint set -f main.c -l %d" % self.line_breakpoint) + + self.runCmd("run") + + process = self.dbg.GetSelectedTarget().process + thread = process.GetSelectedThread() + frame = thread.GetSelectedFrame() + + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', 'stop reason = breakpoint']) + + self.expect("p foo()", substrs=["(int) $0 = 42"]) + + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', 'stop reason = breakpoint']) diff --git a/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/main.c b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/main.c new file mode 100644 index 0000000000000..4786aaa89b27e --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/main.c @@ -0,0 +1,9 @@ +int foo() { + int data[4]; + int x = *(int *)(((char *)&data[0]) + 2); + return 42; +} + +int main() { + return 0; // breakpoint line +} |