brintos

brintos / llvm-project-archived public Read only

0
0
Text · 846 B · 7c6c771 Raw
35 lines · cpp
1// RUN: mkdir -p %t.dir && cd %t.dir2// RUN: %clang_tsan -O1 %s -DBUILD_LIB=1 -fno-sanitize=thread -shared -fPIC -o %dynamiclib %ld_flags_rpath_so3// RUN: %clang_tsan -O1 %s -o %t.dir/exe %ld_flags_rpath_exe4// RUN: %run %t.dir/exe | FileCheck %s5 6// Test that initialization/finalization hooks are called, even when they are7// not defined in the main executable, but by another another library that8// doesn't directly link against the TSan runtime.9 10#include <stdio.h>11 12#if BUILD_LIB13 14extern "C" void __tsan_on_initialize() {15  printf("__tsan_on_initialize()\n");16}17 18extern "C" int __tsan_on_finalize(int failed) {19  printf("__tsan_on_finalize()\n");20  return failed;21}22 23#else // BUILD_LIB24 25int main() {26  printf("main()\n");27  return 0;28}29 30#endif // BUILD_LIB31 32// CHECK: __tsan_on_initialize()33// CHECK: main()34// CHECK: __tsan_on_finalize()35