aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt/test/tsan
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/test/tsan')
-rw-r--r--compiler-rt/test/tsan/Darwin/dlopen.cpp7
-rw-r--r--compiler-rt/test/tsan/Darwin/external-ignore-noninstrumented.cpp6
-rw-r--r--compiler-rt/test/tsan/Darwin/external.cpp9
-rw-r--r--compiler-rt/test/tsan/Darwin/malloc-stack-logging.cpp2
-rw-r--r--compiler-rt/test/tsan/cxa_guard_acquire.cpp13
-rw-r--r--compiler-rt/test/tsan/target_clones_segfault.c11
6 files changed, 36 insertions, 12 deletions
diff --git a/compiler-rt/test/tsan/Darwin/dlopen.cpp b/compiler-rt/test/tsan/Darwin/dlopen.cpp
index 3d12b81..2ab052f 100644
--- a/compiler-rt/test/tsan/Darwin/dlopen.cpp
+++ b/compiler-rt/test/tsan/Darwin/dlopen.cpp
@@ -9,14 +9,15 @@
// RUN: %clangxx_tsan %s -o %t.so -shared -DSHARED_LIB
// RUN: %clangxx_tsan -fno-sanitize=thread %s -o %t
-// RUN: TSAN_DYLIB_PATH=`%clangxx_tsan %s -### 2>&1 \
+// RUN: %clangxx_tsan %s -### 2>&1 \
// RUN: | grep "libclang_rt.tsan_osx_dynamic.dylib" \
-// RUN: | sed -e 's/.*"\(.*libclang_rt.tsan_osx_dynamic.dylib\)".*/\1/'`
+// RUN: | sed -e 's/.*"\(.*libclang_rt.tsan_osx_dynamic.dylib\)".*/\1/' \
+// RUN: | tr -d '\n' > %t.tsan_dylib_path
// Launching a non-instrumented binary that dlopen's an instrumented library should fail.
// RUN: not %run %t %t.so 2>&1 | FileCheck %s --check-prefix=CHECK-FAIL
// Launching a non-instrumented binary with an explicit DYLD_INSERT_LIBRARIES should work.
-// RUN: DYLD_INSERT_LIBRARIES=$TSAN_DYLIB_PATH %run %t %t.so 2>&1 | FileCheck %s
+// RUN: env DYLD_INSERT_LIBRARIES="%{readfile:%t.tsan_dylib_path}" %run %t %t.so 2>&1 | FileCheck %s
#include <dlfcn.h>
#include <pthread.h>
diff --git a/compiler-rt/test/tsan/Darwin/external-ignore-noninstrumented.cpp b/compiler-rt/test/tsan/Darwin/external-ignore-noninstrumented.cpp
index 916b0b8..cfa46e0 100644
--- a/compiler-rt/test/tsan/Darwin/external-ignore-noninstrumented.cpp
+++ b/compiler-rt/test/tsan/Darwin/external-ignore-noninstrumented.cpp
@@ -1,8 +1,10 @@
+// RUN: basename %t-lib.dylib | tr -d '\n' > %t.basename
// RUN: %clangxx_tsan -shared %p/external-lib.cpp -fno-sanitize=thread -DUSE_TSAN_CALLBACKS \
-// RUN: -o %t-lib.dylib -install_name @rpath/`basename %t-lib.dylib`
+// RUN: -o %t-lib.dylib -install_name @rpath/%{readfile:%t.basename}
+// RUN: basename %t-module.dylib | tr -d '\n' > %t.basename
// RUN: %clangxx_tsan -shared %p/external-noninstrumented-module.cpp %t-lib.dylib -fno-sanitize=thread \
-// RUN: -o %t-module.dylib -install_name @rpath/`basename %t-module.dylib`
+// RUN: -o %t-module.dylib -install_name @rpath/%{readfile:%t.basename}
// RUN: %clangxx_tsan %s %t-module.dylib -o %t
// RUN: %run %t 2>&1 | FileCheck %s
diff --git a/compiler-rt/test/tsan/Darwin/external.cpp b/compiler-rt/test/tsan/Darwin/external.cpp
index bf189eb..52fae36 100644
--- a/compiler-rt/test/tsan/Darwin/external.cpp
+++ b/compiler-rt/test/tsan/Darwin/external.cpp
@@ -1,14 +1,17 @@
+// RUN: basename %t-lib-instrumented.dylib | tr -d '\n' > %t.basename
// RUN: %clangxx_tsan %p/external-lib.cpp -shared \
// RUN: -o %t-lib-instrumented.dylib \
-// RUN: -install_name @rpath/`basename %t-lib-instrumented.dylib`
+// RUN: -install_name @rpath/%{readfile:%t.basename}
+// RUN: basename %t-lib-noninstrumented.dylib | tr -d '\n' > %t.basename
// RUN: %clangxx_tsan %p/external-lib.cpp -shared -fno-sanitize=thread \
// RUN: -o %t-lib-noninstrumented.dylib \
-// RUN: -install_name @rpath/`basename %t-lib-noninstrumented.dylib`
+// RUN: -install_name @rpath/%{readfile:%t.basename}
+// RUN: basename %t-lib-noninstrumented-callbacks.dylib | tr -d '\n' > %t.basename
// RUN: %clangxx_tsan %p/external-lib.cpp -shared -fno-sanitize=thread -DUSE_TSAN_CALLBACKS \
// RUN: -o %t-lib-noninstrumented-callbacks.dylib \
-// RUN: -install_name @rpath/`basename %t-lib-noninstrumented-callbacks.dylib`
+// RUN: -install_name @rpath/%{readfile:%t.basename}
// RUN: %clangxx_tsan %s %t-lib-instrumented.dylib -o %t-lib-instrumented
// RUN: %clangxx_tsan %s %t-lib-noninstrumented.dylib -o %t-lib-noninstrumented
diff --git a/compiler-rt/test/tsan/Darwin/malloc-stack-logging.cpp b/compiler-rt/test/tsan/Darwin/malloc-stack-logging.cpp
index 8d9c212..0a96e34 100644
--- a/compiler-rt/test/tsan/Darwin/malloc-stack-logging.cpp
+++ b/compiler-rt/test/tsan/Darwin/malloc-stack-logging.cpp
@@ -4,7 +4,7 @@
// use syscalls directly) to make sure other interceptors aren't called.
// RUN: %clangxx_tsan -O1 %s -o %t
-// RUN: MallocStackLogging=1 %run %t 2>&1 | FileCheck %s
+// RUN: env MallocStackLogging=1 %run %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/compiler-rt/test/tsan/cxa_guard_acquire.cpp b/compiler-rt/test/tsan/cxa_guard_acquire.cpp
index fc40725..6050c24 100644
--- a/compiler-rt/test/tsan/cxa_guard_acquire.cpp
+++ b/compiler-rt/test/tsan/cxa_guard_acquire.cpp
@@ -66,10 +66,17 @@ int main(int argc, char **argv) {
printf("Enter main\n");
// If initialization is contended, the blocked thread should enter a
- // potentially blocking region.
+ // potentially blocking region. Note that we use a DAG check because it is
+ // possible for Thread 1 to acquire the guard, then Thread 2 fail to acquire
+ // the guard then call `OnPotentiallyBlockingRegionBegin` and print "Enter
+ // potentially blocking region\n", before Thread 1 manages to reach "Enter
+ // constructor\n". This is exceptionally rare, but can be replicated by
+ // inserting a `sleep(1)` between `LazyInit() {` and `printf("Enter
+ // constructor\n");`. Due to the barrier it is not possible for the exit logs
+ // to be inverted.
//
- // CHECK-NEXT: Enter constructor
- // CHECK-NEXT: Enter potentially blocking region
+ // CHECK-DAG: Enter constructor
+ // CHECK-DAG: Enter potentially blocking region
// CHECK-NEXT: Exit constructor
// CHECK-NEXT: Exit potentially blocking region
barrier_init(&barrier, 2);
diff --git a/compiler-rt/test/tsan/target_clones_segfault.c b/compiler-rt/test/tsan/target_clones_segfault.c
new file mode 100644
index 0000000..b8847ec
--- /dev/null
+++ b/compiler-rt/test/tsan/target_clones_segfault.c
@@ -0,0 +1,11 @@
+// https://github.com/llvm/llvm-project/issues/163369
+// RUN: %clang_tsan %s -o %t && %run %t
+
+#if __x86_64__
+__attribute__((target_clones("avx,default")))
+#endif
+static int has_target_clones(void) {
+ return 0;
+}
+
+int main(void) { has_target_clones(); }