1 //===-- tsan_test.cc ------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of ThreadSanitizer (TSan), a race detector.
12 //===----------------------------------------------------------------------===//
13 #include "tsan_interface.h"
14 #include "tsan_test_util.h"
15 #include "gtest/gtest.h"
20 TEST(ThreadSanitizer, FuncCall) {
31 // We use this function instead of main, as ISO C++ forbids taking the address
32 // of main, which we need to pass inside __tsan_func_entry.
33 int run_tests(int argc, char **argv) {
34 TestMutexBeforeInit(); // Mutexes must be usable before __tsan_init();
36 __tsan_func_entry(__builtin_return_address(0));
37 __tsan_func_entry((void*)((intptr_t)&run_tests + 1));
39 testing::GTEST_FLAG(death_test_style) = "threadsafe";
40 testing::InitGoogleTest(&argc, argv);
41 int res = RUN_ALL_TESTS();
51 // On Darwin, turns off symbolication and crash logs to make tests faster.
52 extern "C" const char* __tsan_default_options() {
53 return "symbolize=false:abort_on_error=0";
57 namespace __sanitizer {
58 bool ReexecDisabled() {
63 int main(int argc, char **argv) {
65 return run_tests(argc, argv);