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
9 // RUN: %clangxx_tsan %s -o %t.so -shared -DSHARED_LIB
10 // RUN: %clangxx_tsan -fno-sanitize=thread %s -o %t
12 // RUN: TSAN_DYLIB_PATH=`%clangxx_tsan %s -### 2>&1 \
13 // RUN: | grep "libclang_rt.tsan_osx_dynamic.dylib" \
14 // RUN: | sed -e 's/.*"\(.*libclang_rt.tsan_osx_dynamic.dylib\)".*/\1/'`
16 // Launching a non-instrumented binary that dlopen's an instrumented library should fail.
17 // RUN: not %run %t %t.so 2>&1 | FileCheck %s --check-prefix=CHECK-FAIL
18 // Launching a non-instrumented binary with an explicit DYLD_INSERT_LIBRARIES should work.
19 // RUN: DYLD_INSERT_LIBRARIES=$TSAN_DYLIB_PATH %run %t %t.so 2>&1 | FileCheck %s
25 #if defined(SHARED_LIB)
26 extern "C" void foo() {
27 fprintf(stderr
, "Hello world.\n");
29 #else // defined(SHARED_LIB)
30 int main(int argc
, char *argv
[]) {
31 void *handle
= dlopen(argv
[1], RTLD_NOW
);
32 fprintf(stderr
, "handle = %p\n", handle
);
33 void (*foo
)() = (void (*)())dlsym(handle
, "foo");
34 fprintf(stderr
, "foo = %p\n", foo
);
37 #endif // defined(SHARED_LIB)
39 // CHECK: Hello world.
40 // CHECK-NOT: ERROR: Interceptors are not working.
42 // CHECK-FAIL-NOT: Hello world.
43 // CHECK-FAIL: ERROR: Interceptors are not working.