]> git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/tsan/ignore_lib1.cc
New upstream version 1.25.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / tsan / ignore_lib1.cc
1 // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %T/libignore_lib1.so
2 // RUN: %clangxx_tsan -O1 %s -o %t
3 // RUN: echo running w/o suppressions:
4 // RUN: %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOSUPP
5 // RUN: echo running with suppressions:
6 // RUN: %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP
7
8 // Tests that interceptors coming from a dynamically loaded library specified
9 // in called_from_lib suppression are ignored.
10
11 // REQUIRES: stable-runtime
12 // UNSUPPORTED: powerpc64le
13 // FIXME: This test regularly fails on powerpc64 LE possibly starting with
14 // r279664. Re-enable the test once the problem(s) have been fixed.
15
16 #ifndef LIB
17
18 #include <dlfcn.h>
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <errno.h>
22 #include <libgen.h>
23 #include <string>
24
25 int main(int argc, char **argv) {
26 std::string lib = std::string(dirname(argv[0])) + "/libignore_lib1.so";
27 void *h = dlopen(lib.c_str(), RTLD_GLOBAL | RTLD_NOW);
28 if (h == 0)
29 exit(printf("failed to load the library (%d)\n", errno));
30 void (*f)() = (void(*)())dlsym(h, "libfunc");
31 if (f == 0)
32 exit(printf("failed to find the func (%d)\n", errno));
33 f();
34 }
35
36 #else // #ifdef LIB
37
38 #include "ignore_lib_lib.h"
39
40 #endif // #ifdef LIB
41
42 // CHECK-NOSUPP: WARNING: ThreadSanitizer: data race
43 // CHECK-NOSUPP: OK
44
45 // CHECK-WITHSUPP-NOT: WARNING: ThreadSanitizer: data race
46 // CHECK-WITHSUPP: OK
47