Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / ignore_lib3.cpp
blobb1a3940d03b615a24b143a140eb2ec76e47742e1
1 // RUN: rm -rf %t-dir
2 // RUN: mkdir %t-dir
4 // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib3.so
5 // RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t-dir/executable
6 // RUN: %env_tsan_opts=suppressions='%s.supp' %deflake %run %t-dir/executable | FileCheck %s
8 // Tests that unloading of a library matched against called_from_lib suppression
9 // causes program crash (this is not supported).
11 // Some aarch64 kernels do not support non executable write pages
12 // REQUIRES: stable-runtime
14 #ifndef LIB
16 #include <dlfcn.h>
17 #include <stdlib.h>
18 #include <stdio.h>
19 #include <errno.h>
20 #include <libgen.h>
21 #include <string>
23 int main(int argc, char **argv) {
24 std::string lib = std::string(dirname(argv[0])) + "/libignore_lib3.so";
25 void *h = dlopen(lib.c_str(), RTLD_GLOBAL | RTLD_NOW);
26 dlclose(h);
27 fprintf(stderr, "OK\n");
30 #else // #ifdef LIB
32 extern "C" void libfunc() {
35 #endif // #ifdef LIB
37 // CHECK: ThreadSanitizer: library {{.*}} that was matched against called_from_lib suppression 'ignore_lib3.so' is unloaded
38 // CHECK-NOT: OK