diff options
Diffstat (limited to 'test/lsan/TestCases/Linux')
| -rw-r--r-- | test/lsan/TestCases/Linux/fork_with_threads.cc | 35 | ||||
| -rw-r--r-- | test/lsan/TestCases/Linux/log-path_test.cc | 26 | ||||
| -rw-r--r-- | test/lsan/TestCases/Linux/use_tls_dynamic.cc | 2 |
3 files changed, 62 insertions, 1 deletions
diff --git a/test/lsan/TestCases/Linux/fork_with_threads.cc b/test/lsan/TestCases/Linux/fork_with_threads.cc new file mode 100644 index 0000000000000..221c5d249d772 --- /dev/null +++ b/test/lsan/TestCases/Linux/fork_with_threads.cc @@ -0,0 +1,35 @@ +// 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 diff --git a/test/lsan/TestCases/Linux/log-path_test.cc b/test/lsan/TestCases/Linux/log-path_test.cc new file mode 100644 index 0000000000000..a31b4f64acc5d --- /dev/null +++ b/test/lsan/TestCases/Linux/log-path_test.cc @@ -0,0 +1,26 @@ +// RUN: %clangxx_lsan %s -o %t +// The globs below do not work in the lit shell. + +// Regular run. +// RUN: %env_lsan_opts="use_stacks=0" not %run %t > %t.out 2>&1 +// RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.out + +// Good log_path. +// RUN: rm -f %t.log.* +// RUN: %env_lsan_opts="use_stacks=0:log_path='"%t.log"'" not %run %t > %t.out 2>&1 +// RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.* + +#include <stdio.h> +#include <stdlib.h> +#include "sanitizer_common/print_address.h" + +int main() { + void *stack_var = malloc(1337); + print_address("Test alloc: ", 1, stack_var); + // Do not return from main to prevent the pointer from going out of scope. + exit(0); +} + +// CHECK-ERROR: LeakSanitizer: detected memory leaks +// CHECK-ERROR: Direct leak of 1337 byte(s) in 1 object(s) allocated from +// CHECK-ERROR: SUMMARY: {{(Leak|Address)}}Sanitizer: diff --git a/test/lsan/TestCases/Linux/use_tls_dynamic.cc b/test/lsan/TestCases/Linux/use_tls_dynamic.cc index f5df231ba9a6b..4d70a46f8183f 100644 --- a/test/lsan/TestCases/Linux/use_tls_dynamic.cc +++ b/test/lsan/TestCases/Linux/use_tls_dynamic.cc @@ -5,7 +5,7 @@ // RUN: %env_lsan_opts=$LSAN_BASE:"use_tls=0" not %run %t 2>&1 | FileCheck %s // RUN: %env_lsan_opts=$LSAN_BASE:"use_tls=1" %run %t 2>&1 // RUN: %env_lsan_opts="" %run %t 2>&1 -// UNSUPPORTED: i386-linux,arm +// UNSUPPORTED: i386-linux,arm,powerpc #ifndef BUILD_DSO #include <assert.h> |
