37 lines · cpp
1// RUN: rm -rf %t-dir2// RUN: mkdir %t-dir3 4// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib2_0.so5// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib2_1.so6// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t-dir/executable7// RUN: %env_tsan_opts=suppressions='%s.supp' %deflake %run %t-dir/executable | FileCheck %s8 9// Tests that called_from_lib suppression matched against 2 libraries10// causes program crash (this is not supported).11 12#ifndef LIB13 14#include <dlfcn.h>15#include <stdio.h>16#include <libgen.h>17#include <string>18 19int main(int argc, char **argv) {20 std::string lib0 = std::string(dirname(argv[0])) + "/libignore_lib2_0.so";21 std::string lib1 = std::string(dirname(argv[0])) + "/libignore_lib2_1.so";22 dlopen(lib0.c_str(), RTLD_GLOBAL | RTLD_NOW);23 dlopen(lib1.c_str(), RTLD_GLOBAL | RTLD_NOW);24 fprintf(stderr, "OK\n");25}26 27#else // #ifdef LIB28 29extern "C" void libfunc() {30}31 32#endif // #ifdef LIB33 34// CHECK: ThreadSanitizer: called_from_lib suppression 'ignore_lib2' is matched against 2 libraries35// CHECK-NOT: OK36 37