]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/tsan/Darwin/dlopen.cc
1 // Checks that on OS X 10.11+ (where we do not re-exec anymore, because
2 // interceptors work automatically), dlopen'ing a TSanified library from a
3 // non-instrumented program exits with a user-friendly message.
5 // REQUIRES: osx-autointerception
7 // RUN: %clangxx_tsan %s -o %t.so -shared -DSHARED_LIB
8 // RUN: %clangxx_tsan -fno-sanitize=thread %s -o %t
10 // RUN: TSAN_DYLIB_PATH=`%clangxx_tsan %s -### 2>&1 \
11 // RUN: | grep "libclang_rt.tsan_osx_dynamic.dylib" \
12 // RUN: | sed -e 's/.*"\(.*libclang_rt.tsan_osx_dynamic.dylib\)".*/\1/'`
14 // Launching a non-instrumented binary that dlopen's an instrumented library should fail.
15 // RUN: not %run %t %t.so 2>&1 | FileCheck %s --check-prefix=CHECK-FAIL
16 // Launching a non-instrumented binary with an explicit DYLD_INSERT_LIBRARIES should work.
17 // RUN: DYLD_INSERT_LIBRARIES=$TSAN_DYLIB_PATH %run %t %t.so 2>&1 | FileCheck %s
23 #if defined(SHARED_LIB)
24 extern "C" void foo() {
25 fprintf(stderr
, "Hello world.\n");
27 #else // defined(SHARED_LIB)
28 int main(int argc
, char *argv
[]) {
29 void *handle
= dlopen(argv
[1], RTLD_NOW
);
30 fprintf(stderr
, "handle = %p\n", handle
);
31 void (*foo
)() = (void (*)())dlsym(handle
, "foo");
32 fprintf(stderr
, "foo = %p\n", foo
);
35 #endif // defined(SHARED_LIB)
37 // CHECK: Hello world.
38 // CHECK-NOT: ERROR: Interceptors are not working.
40 // CHECK-FAIL-NOT: Hello world.
41 // CHECK-FAIL: ERROR: Interceptors are not working.