blob: 4f584b14664ac9a1d629f4c71af44521b8aa0a55 [file] [log] [blame]
Stephen Hines2d1fdb22014-05-28 23:58:16 -07001// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %T/libignore_lib2_0.so
2// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %T/libignore_lib2_1.so
3// RUN: %clangxx_tsan -O1 %s -o %t
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08004// RUN: %env_tsan_opts=suppressions='%s.supp' %deflake %run %t | FileCheck %s
Stephen Hines2d1fdb22014-05-28 23:58:16 -07005
6// Tests that called_from_lib suppression matched against 2 libraries
7// causes program crash (this is not supported).
8
9#ifndef LIB
10
11#include <dlfcn.h>
12#include <stdio.h>
13#include <libgen.h>
14#include <string>
15
16int main(int argc, char **argv) {
17 std::string lib0 = std::string(dirname(argv[0])) + "/libignore_lib2_0.so";
18 std::string lib1 = std::string(dirname(argv[0])) + "/libignore_lib2_1.so";
19 dlopen(lib0.c_str(), RTLD_GLOBAL | RTLD_NOW);
20 dlopen(lib1.c_str(), RTLD_GLOBAL | RTLD_NOW);
21 fprintf(stderr, "OK\n");
22}
23
24#else // #ifdef LIB
25
26extern "C" void libfunc() {
27}
28
29#endif // #ifdef LIB
30
31// CHECK: ThreadSanitizer: called_from_lib suppression 'ignore_lib2' is matched against 2 libraries
32// CHECK-NOT: OK
33