1*7c3d14c8STreehugger Robot // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %T/libignore_lib1.so 2*7c3d14c8STreehugger Robot // RUN: %clangxx_tsan -O1 %s -o %t 3*7c3d14c8STreehugger Robot // RUN: echo running w/o suppressions: 4*7c3d14c8STreehugger Robot // RUN: %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOSUPP 5*7c3d14c8STreehugger Robot // RUN: echo running with suppressions: 6*7c3d14c8STreehugger Robot // RUN: %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP 7*7c3d14c8STreehugger Robot 8*7c3d14c8STreehugger Robot // Tests that interceptors coming from a dynamically loaded library specified 9*7c3d14c8STreehugger Robot // in called_from_lib suppression are ignored. 10*7c3d14c8STreehugger Robot 11*7c3d14c8STreehugger Robot // REQUIRES: stable-runtime 12*7c3d14c8STreehugger Robot 13*7c3d14c8STreehugger Robot #ifndef LIB 14*7c3d14c8STreehugger Robot 15*7c3d14c8STreehugger Robot #include <dlfcn.h> 16*7c3d14c8STreehugger Robot #include <stdlib.h> 17*7c3d14c8STreehugger Robot #include <stdio.h> 18*7c3d14c8STreehugger Robot #include <errno.h> 19*7c3d14c8STreehugger Robot #include <libgen.h> 20*7c3d14c8STreehugger Robot #include <string> 21*7c3d14c8STreehugger Robot main(int argc,char ** argv)22*7c3d14c8STreehugger Robotint main(int argc, char **argv) { 23*7c3d14c8STreehugger Robot std::string lib = std::string(dirname(argv[0])) + "/libignore_lib1.so"; 24*7c3d14c8STreehugger Robot void *h = dlopen(lib.c_str(), RTLD_GLOBAL | RTLD_NOW); 25*7c3d14c8STreehugger Robot if (h == 0) 26*7c3d14c8STreehugger Robot exit(printf("failed to load the library (%d)\n", errno)); 27*7c3d14c8STreehugger Robot void (*f)() = (void(*)())dlsym(h, "libfunc"); 28*7c3d14c8STreehugger Robot if (f == 0) 29*7c3d14c8STreehugger Robot exit(printf("failed to find the func (%d)\n", errno)); 30*7c3d14c8STreehugger Robot f(); 31*7c3d14c8STreehugger Robot } 32*7c3d14c8STreehugger Robot 33*7c3d14c8STreehugger Robot #else // #ifdef LIB 34*7c3d14c8STreehugger Robot 35*7c3d14c8STreehugger Robot #include "ignore_lib_lib.h" 36*7c3d14c8STreehugger Robot 37*7c3d14c8STreehugger Robot #endif // #ifdef LIB 38*7c3d14c8STreehugger Robot 39*7c3d14c8STreehugger Robot // CHECK-NOSUPP: WARNING: ThreadSanitizer: data race 40*7c3d14c8STreehugger Robot // CHECK-NOSUPP: OK 41*7c3d14c8STreehugger Robot 42*7c3d14c8STreehugger Robot // CHECK-WITHSUPP-NOT: WARNING: ThreadSanitizer: data race 43*7c3d14c8STreehugger Robot // CHECK-WITHSUPP: OK 44*7c3d14c8STreehugger Robot 45