diff options
Diffstat (limited to 'compiler-rt/lib/tsan/lit_tests')
-rw-r--r-- | compiler-rt/lib/tsan/lit_tests/thread_leak3.c | 2 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/lit_tests/thread_leak4.c | 16 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/lit_tests/thread_leak5.c | 19 |
3 files changed, 37 insertions, 0 deletions
diff --git a/compiler-rt/lib/tsan/lit_tests/thread_leak3.c b/compiler-rt/lib/tsan/lit_tests/thread_leak3.c index a39c93c5a5f..3577164cad4 100644 --- a/compiler-rt/lib/tsan/lit_tests/thread_leak3.c +++ b/compiler-rt/lib/tsan/lit_tests/thread_leak3.c @@ -1,5 +1,6 @@ // RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s #include <pthread.h> +#include <unistd.h> void *Thread(void *x) { return 0; @@ -8,6 +9,7 @@ void *Thread(void *x) { int main() { pthread_t t; pthread_create(&t, 0, Thread, 0); + sleep(1); return 0; } diff --git a/compiler-rt/lib/tsan/lit_tests/thread_leak4.c b/compiler-rt/lib/tsan/lit_tests/thread_leak4.c new file mode 100644 index 00000000000..3909c0a8d4a --- /dev/null +++ b/compiler-rt/lib/tsan/lit_tests/thread_leak4.c @@ -0,0 +1,16 @@ +// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s +#include <pthread.h> +#include <unistd.h> + +void *Thread(void *x) { + sleep(10); + return 0; +} + +int main() { + pthread_t t; + pthread_create(&t, 0, Thread, 0); + return 0; +} + +// CHECK-NOT: WARNING: ThreadSanitizer: thread leak diff --git a/compiler-rt/lib/tsan/lit_tests/thread_leak5.c b/compiler-rt/lib/tsan/lit_tests/thread_leak5.c new file mode 100644 index 00000000000..fc72b149ec2 --- /dev/null +++ b/compiler-rt/lib/tsan/lit_tests/thread_leak5.c @@ -0,0 +1,19 @@ +// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s +#include <pthread.h> +#include <unistd.h> + +void *Thread(void *x) { + return 0; +} + +int main() { + for (int i = 0; i < 5; i++) { + pthread_t t; + pthread_create(&t, 0, Thread, 0); + } + sleep(1); + return 0; +} + +// CHECK: WARNING: ThreadSanitizer: thread leak +// CHECK: And 4 more similar thread leaks |