Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 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: |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 4 | // RUN: %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOSUPP |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 5 | // RUN: echo running with suppressions: |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 6 | // RUN: TSAN_OPTIONS="$TSAN_OPTIONS suppressions='%s.supp'" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 7 | |
| 8 | // Tests that interceptors coming from a dynamically loaded library specified |
| 9 | // in called_from_lib suppression are ignored. |
| 10 | |
| 11 | #ifndef LIB |
| 12 | |
| 13 | #include <dlfcn.h> |
| 14 | #include <stdlib.h> |
| 15 | #include <stdio.h> |
| 16 | #include <errno.h> |
| 17 | #include <libgen.h> |
| 18 | #include <string> |
| 19 | |
| 20 | int main(int argc, char **argv) { |
| 21 | std::string lib = std::string(dirname(argv[0])) + "/libignore_lib1.so"; |
| 22 | void *h = dlopen(lib.c_str(), RTLD_GLOBAL | RTLD_NOW); |
| 23 | if (h == 0) |
| 24 | exit(printf("failed to load the library (%d)\n", errno)); |
| 25 | void (*f)() = (void(*)())dlsym(h, "libfunc"); |
| 26 | if (f == 0) |
| 27 | exit(printf("failed to find the func (%d)\n", errno)); |
| 28 | f(); |
| 29 | } |
| 30 | |
| 31 | #else // #ifdef LIB |
| 32 | |
| 33 | #include "ignore_lib_lib.h" |
| 34 | |
| 35 | #endif // #ifdef LIB |
| 36 | |
| 37 | // CHECK-NOSUPP: WARNING: ThreadSanitizer: data race |
| 38 | // CHECK-NOSUPP: OK |
| 39 | |
| 40 | // CHECK-WITHSUPP-NOT: WARNING: ThreadSanitizer: data race |
| 41 | // CHECK-WITHSUPP: OK |
| 42 | |