1// RUN: rm -rf %t-dir
2// RUN: mkdir %t-dir
3
4// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib2_0.so
5// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib2_1.so
6// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t-dir/executable
7// RUN: %env_tsan_opts=suppressions='%s.supp' %deflake %run %t-dir/executable | FileCheck %s
8
9// Tests that called_from_lib suppression matched against 2 libraries
10// causes program crash (this is not supported).
11
12#ifndef LIB
13
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 LIB
28
29extern "C" void libfunc() {
30}
31
32#endif // #ifdef LIB
33
34// CHECK: ThreadSanitizer: called_from_lib suppression 'ignore_lib2' is matched against 2 libraries
35// CHECK-NOT: OK
36
37