aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-08-29 17:50:55 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-08-29 17:50:55 +0000
commitd6ad2d02b6234d03473f3874bbc0c129bb7586ee (patch)
tree275dab18d36076f02a13d4f5e52c5be5e6ff0028 /test
parent2a0cb7949b6072f45f5ddfd6fcd0d147ca2c2820 (diff)
downloadsrc-d6ad2d02b6234d03473f3874bbc0c129bb7586ee.tar.gz
src-d6ad2d02b6234d03473f3874bbc0c129bb7586ee.zip
Vendor import of compiler-rt release_70 branch r340910:vendor/compiler-rt/compiler-rt-release_70-r340910
Notes
Notes: svn path=/vendor/compiler-rt/dist-release_70/; revision=338382 svn path=/vendor/compiler-rt/compiler-rt-release_70-r340910/; revision=338383; tag=vendor/compiler-rt/compiler-rt-release_70-r340910
Diffstat (limited to 'test')
-rw-r--r--test/lsan/TestCases/Linux/fork_and_leak.cc23
-rw-r--r--test/lsan/TestCases/Linux/fork_with_threads.cc35
2 files changed, 23 insertions, 35 deletions
diff --git a/test/lsan/TestCases/Linux/fork_and_leak.cc b/test/lsan/TestCases/Linux/fork_and_leak.cc
new file mode 100644
index 000000000000..d7427ce3ed04
--- /dev/null
+++ b/test/lsan/TestCases/Linux/fork_and_leak.cc
@@ -0,0 +1,23 @@
+// Test that leaks detected after forking without exec().
+// RUN: %clangxx_lsan %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+int main() {
+ pid_t pid = fork();
+ assert(pid >= 0);
+ if (pid > 0) {
+ int status = 0;
+ waitpid(pid, &status, 0);
+ assert(WIFEXITED(status));
+ return WEXITSTATUS(status);
+ } else {
+ malloc(1337);
+ // CHECK: LeakSanitizer: detected memory leaks
+ }
+ return 0;
+}
+
diff --git a/test/lsan/TestCases/Linux/fork_with_threads.cc b/test/lsan/TestCases/Linux/fork_with_threads.cc
deleted file mode 100644
index 221c5d249d77..000000000000
--- a/test/lsan/TestCases/Linux/fork_with_threads.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Test forked process does not run lsan.
-// RUN: %clangxx_lsan %s -o %t && %run %t 2>&1 | FileCheck %s
-
-#include <pthread.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-static pthread_barrier_t barrier;
-
-// CHECK-NOT: SUMMARY: {{(Leak|Address)}}Sanitizer:
-static void *thread_func(void *arg) {
- void *buffer = malloc(1337);
- pthread_barrier_wait(&barrier);
- for (;;)
- pthread_yield();
- return 0;
-}
-
-int main() {
- pthread_barrier_init(&barrier, 0, 2);
- pthread_t tid;
- int res = pthread_create(&tid, 0, thread_func, 0);
- pthread_barrier_wait(&barrier);
- pthread_barrier_destroy(&barrier);
-
- pid_t pid = fork();
- if (pid > 0) {
- int status = 0;
- waitpid(pid, &status, 0);
- }
- return 0;
-}
-
-// CHECK: WARNING: LeakSanitizer is disabled in forked process