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: |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 6 | // RUN: %env_tsan_opts=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 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 11 | // REQUIRES: stable-runtime |
| 12 | |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 13 | #ifndef LIB |
| 14 | |
| 15 | #include <dlfcn.h> |
| 16 | #include <stdlib.h> |
| 17 | #include <stdio.h> |
| 18 | #include <errno.h> |
| 19 | #include <libgen.h> |
| 20 | #include <string> |
| 21 | |
| 22 | int main(int argc, char **argv) { |
| 23 | std::string lib = std::string(dirname(argv[0])) + "/libignore_lib1.so"; |
| 24 | void *h = dlopen(lib.c_str(), RTLD_GLOBAL | RTLD_NOW); |
| 25 | if (h == 0) |
| 26 | exit(printf("failed to load the library (%d)\n", errno)); |
| 27 | void (*f)() = (void(*)())dlsym(h, "libfunc"); |
| 28 | if (f == 0) |
| 29 | exit(printf("failed to find the func (%d)\n", errno)); |
| 30 | f(); |
| 31 | } |
| 32 | |
| 33 | #else // #ifdef LIB |
| 34 | |
| 35 | #include "ignore_lib_lib.h" |
| 36 | |
| 37 | #endif // #ifdef LIB |
| 38 | |
| 39 | // CHECK-NOSUPP: WARNING: ThreadSanitizer: data race |
| 40 | // CHECK-NOSUPP: OK |
| 41 | |
| 42 | // CHECK-WITHSUPP-NOT: WARNING: ThreadSanitizer: data race |
| 43 | // CHECK-WITHSUPP: OK |
| 44 | |