diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/asan/TestCases/Darwin/atos-symbolizer.cc | 2 | ||||
-rw-r--r-- | test/asan/TestCases/Linux/asan_preload_test-3.cc | 33 | ||||
-rw-r--r-- | test/asan/TestCases/Posix/halt_on_error-torture.cc | 6 | ||||
-rw-r--r-- | test/msan/Linux/strerror_r.cc | 18 | ||||
-rw-r--r-- | test/profile/Linux/instrprof-alloc.test | 4 | ||||
-rw-r--r-- | test/profile/Linux/instrprof-value-prof-warn.test | 2 | ||||
-rw-r--r-- | test/sanitizer_common/TestCases/Linux/allocator_fork_no_hang.cc | 118 | ||||
-rw-r--r-- | test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc | 2 | ||||
-rw-r--r-- | test/tsan/strerror_r.cc | 29 |
9 files changed, 88 insertions, 126 deletions
diff --git a/test/asan/TestCases/Darwin/atos-symbolizer.cc b/test/asan/TestCases/Darwin/atos-symbolizer.cc index 7b091c4d681c..e7d7e7a17fb7 100644 --- a/test/asan/TestCases/Darwin/atos-symbolizer.cc +++ b/test/asan/TestCases/Darwin/atos-symbolizer.cc @@ -4,7 +4,7 @@ // RUN: %env_asan_opts=verbosity=2 ASAN_SYMBOLIZER_PATH=$(which atos) not %run %t 2>&1 | FileCheck %s // Path returned by `which atos` is invalid on iOS. -// UNSUPPORTED: ios +// UNSUPPORTED: ios, i386-darwin #include <stdlib.h> #include <string.h> diff --git a/test/asan/TestCases/Linux/asan_preload_test-3.cc b/test/asan/TestCases/Linux/asan_preload_test-3.cc new file mode 100644 index 000000000000..041669b56a45 --- /dev/null +++ b/test/asan/TestCases/Linux/asan_preload_test-3.cc @@ -0,0 +1,33 @@ +// Regression test for PR33206 +// +// RUN: %clang -DDYN=1 -DMALLOC=1 -fPIC -shared %s -o %t-dso1.so +// RUN: %clang -DDYN=1 -DMALLOC=1 -fPIC -shared %s -o %t-dso2.so %t-dso1.so +// RUN: %clang %s -o %t-1 %t-dso2.so +// RUN: env LD_PRELOAD=%shared_libasan %run %t-1 2>&1 | FileCheck %s +// RUN: %clang -DDYN=1 -DREALLOC=1 -fPIC -shared %s -o %t-dso3.so +// RUN: %clang -DDYN=1 -DREALLOC=1 -fPIC -shared %s -o %t-dso4.so %t-dso3.so +// RUN: %clang %s -o %t-2 %t-dso4.so +// RUN: env LD_PRELOAD=%shared_libasan %run %t-2 2>&1 | FileCheck %s +// REQUIRES: asan-dynamic-runtime + +#include <stdlib.h> +#include <stdio.h> + +#ifdef DYN +__attribute__((constructor)) void foo() { + void *p; +#ifdef MALLOC + p = malloc(1 << 20); +#endif +#ifdef REALLOC + p = realloc (0, 1 << 20); +#endif + free(p); +} +#else +int main() { + // CHECK: Success + printf("Success\n"); + return 0; +} +#endif diff --git a/test/asan/TestCases/Posix/halt_on_error-torture.cc b/test/asan/TestCases/Posix/halt_on_error-torture.cc index 1b26173d713f..829568e2682b 100644 --- a/test/asan/TestCases/Posix/halt_on_error-torture.cc +++ b/test/asan/TestCases/Posix/halt_on_error-torture.cc @@ -10,12 +10,12 @@ // // Collisions are unlikely but still possible so we need the ||. // RUN: rm -f 10.txt -// RUN: %env_asan_opts=halt_on_error=false:suppress_equal_pcs=false %run %t 10 20 >>10.txt 2>&1 || true +// RUN: %env_asan_opts=halt_on_error=false:suppress_equal_pcs=false:exitcode=0 %run %t 10 20 2>&1 | cat > 10.txt // RUN: FileCheck --check-prefix=CHECK-COLLISION %s < 10.txt || FileCheck --check-prefix=CHECK-NO-COLLISION %s < 10.txt // // Collisions are unlikely but still possible so we need the ||. // RUN: rm -f 20.txt -// RUN: %env_asan_opts=halt_on_error=false %run %t 10 20 >>20.txt 2>&1 || true +// RUN: %env_asan_opts=halt_on_error=false:exitcode=0 %run %t 10 20 2>&1 | cat > 20.txt // RUN: FileCheck --check-prefix=CHECK-COLLISION %s < 20.txt || FileCheck --check-prefix=CHECK-NO-COLLISION %s < 20.txt #include <stdio.h> @@ -38,7 +38,7 @@ void *run(void *arg) { unsigned seed = (unsigned)(size_t)arg; volatile char tmp[2]; - __asan_poison_memory_region(&tmp, sizeof(tmp)); + __asan_poison_memory_region(&tmp, sizeof(tmp)); for (size_t i = 0; i < niter; ++i) { random_delay(&seed); diff --git a/test/msan/Linux/strerror_r.cc b/test/msan/Linux/strerror_r.cc new file mode 100644 index 000000000000..aec653f9c025 --- /dev/null +++ b/test/msan/Linux/strerror_r.cc @@ -0,0 +1,18 @@ +// RUN: %clang_msan -O0 -g %s -o %t && %run %t + +#include <assert.h> +#include <errno.h> +#include <string.h> + +int main() { + char buf[1000]; + char *res = strerror_r(EINVAL, buf, sizeof(buf)); + assert(res); + volatile int z = strlen(res); + + res = strerror_r(-1, buf, sizeof(buf)); + assert(res); + z = strlen(res); + + return 0; +} diff --git a/test/profile/Linux/instrprof-alloc.test b/test/profile/Linux/instrprof-alloc.test index 752b10892170..4db764704adb 100644 --- a/test/profile/Linux/instrprof-alloc.test +++ b/test/profile/Linux/instrprof-alloc.test @@ -1,6 +1,6 @@ -// RUN: %clang_profgen -Xclang -fprofile-instrument=llvm -fuse-ld=gold -Wl,-wrap,malloc -Wl,-wrap,calloc -o %t -O3 %S/../Inputs/instrprof-alloc.c +// RUN: %clang_pgogen -fuse-ld=gold -Wl,-wrap,malloc -Wl,-wrap,calloc -o %t -O3 %S/../Inputs/instrprof-alloc.c // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t -// RUN: %clang_profgen -Xclang -fprofile-instrument=llvm -mllvm -vp-static-alloc=false -fuse-ld=gold -Wl,-wrap,malloc -Wl,-wrap,calloc -o %t.dyn -O3 %S/../Inputs/instrprof-alloc.c +// RUN: %clang_pgogen -mllvm -vp-static-alloc=false -fuse-ld=gold -Wl,-wrap,malloc -Wl,-wrap,calloc -o %t.dyn -O3 %S/../Inputs/instrprof-alloc.c // RUN: env LLVM_PROFILE_FILE=%t.profraw not %run %t.dyn diff --git a/test/profile/Linux/instrprof-value-prof-warn.test b/test/profile/Linux/instrprof-value-prof-warn.test index 26502cc900dc..6ca1603fb244 100644 --- a/test/profile/Linux/instrprof-value-prof-warn.test +++ b/test/profile/Linux/instrprof-value-prof-warn.test @@ -1,4 +1,4 @@ -RUN: %clang_profgen -O2 -mllvm -disable-vp=false -Xclang -fprofile-instrument=llvm -mllvm -vp-static-alloc=true -DSTRESS=1 -o %t.ir.warn %S/../Inputs/instrprof-value-prof-real.c +RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -DSTRESS=1 -o %t.ir.warn %S/../Inputs/instrprof-value-prof-real.c RUN: env LLVM_PROFILE_FILE=%t.ir.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir.warn 2>&1 |FileCheck --check-prefix=WARNING %s # Test that enough static counters have been allocated RUN: env LLVM_PROFILE_FILE=%t.ir.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=150 %run %t.ir.warn 2>&1 |FileCheck --check-prefix=NOWARNING --allow-empty %s diff --git a/test/sanitizer_common/TestCases/Linux/allocator_fork_no_hang.cc b/test/sanitizer_common/TestCases/Linux/allocator_fork_no_hang.cc deleted file mode 100644 index d159d85ee2d6..000000000000 --- a/test/sanitizer_common/TestCases/Linux/allocator_fork_no_hang.cc +++ /dev/null @@ -1,118 +0,0 @@ -// https://github.com/google/sanitizers/issues/774 -// Test that sanitizer allocator is fork-safe. -// Run a number of threads that perform memory allocation/deallocation, then fork -// and verify that malloc/free do not deadlock in the child process. - -// RUN: %clangxx -std=c++11 -O0 %s -o %t -// RUN: ASAN_OPTIONS=detect_leaks=0 %run %t 2>&1 | FileCheck %s - -// Fun fact: if test output is redirected to a file (as opposed to -// being piped directly to FileCheck), we may lose some "done"s due to -// a kernel bug: -// https://lkml.org/lkml/2014/2/17/324 - -// UNSUPPORTED: tsan - -// Flaky on PPC64. -// UNSUPPORTED: powerpc64-target-arch -// UNSUPPORTED: powerpc64le-target-arch - -#include <pthread.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/time.h> -#include <signal.h> -#include <errno.h> - -int done; - -void *worker(void *arg) { - while (true) { - void *p = malloc(4); - if (__atomic_load_n(&done, __ATOMIC_RELAXED)) - return 0; - } - return 0; -} - -// Run through malloc/free in the child process. -// This can deadlock on allocator cache refilling. -void child() { - for (int i = 0; i < 10000; ++i) { - void *p = malloc(4); - } - write(2, "done\n", 5); -} - -void test() { - const int kThreads = 10; - pthread_t t[kThreads]; - for (int i = 0; i < kThreads; ++i) - pthread_create(&t[i], NULL, worker, (void*)(long)i); - usleep(100000); - pid_t pid = fork(); - if (pid) { - // parent - __atomic_store_n(&done, 1, __ATOMIC_RELAXED); - pid_t p; - while ((p = wait(NULL)) == -1) { } - } else { - // child - child(); - } -} - -int main() { - const int kChildren = 30; - for (int i = 0; i < kChildren; ++i) { - pid_t pid = fork(); - if (pid) { - // parent - } else { - test(); - exit(0); - } - } - - for (int i = 0; i < kChildren; ++i) { - pid_t p; - while ((p = wait(NULL)) == -1) { } - } - - return 0; -} - -// Expect 30 (== kChildren) "done" messages. -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done -// CHECK: done diff --git a/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc b/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc index b7246ebf2751..1a4ad1f066d9 100644 --- a/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc +++ b/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc @@ -1,7 +1,7 @@ // Tests -fsanitize-coverage=inline-8bit-counters // // REQUIRES: has_sancovcc,stable-runtime -// UNSUPPORTED: i386-darwin +// UNSUPPORTED: i386-darwin, x86_64-darwin, x86_64h-darwin // // RUN: %clangxx -O0 %s -fsanitize-coverage=inline-8bit-counters 2>&1 diff --git a/test/tsan/strerror_r.cc b/test/tsan/strerror_r.cc new file mode 100644 index 000000000000..06c92d3bb641 --- /dev/null +++ b/test/tsan/strerror_r.cc @@ -0,0 +1,29 @@ +// RUN: %clangxx_tsan -O1 -DTEST_ERROR=ERANGE %s -o %t && %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-SYS %s +// RUN: %clangxx_tsan -O1 -DTEST_ERROR=-1 %s -o %t && not %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-USER %s +// UNSUPPORTED: darwin + +#include <assert.h> +#include <errno.h> +#include <pthread.h> +#include <stdio.h> +#include <string.h> + +char buffer[1000]; + +void *Thread(void *p) { + return strerror_r(TEST_ERROR, buffer, sizeof(buffer)); +} + +int main() { + pthread_t th[2]; + pthread_create(&th[0], 0, Thread, 0); + pthread_create(&th[1], 0, Thread, 0); + pthread_join(th[0], 0); + pthread_join(th[1], 0); + fprintf(stderr, "DONE\n"); +} + +// CHECK-USER: WARNING: ThreadSanitizer: data race +// CHECK-SYS-NOT: WARNING: ThreadSanitizer: data race + +// CHECK: DONE |