1 //===-- tsan_test.cpp -----------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file is a part of ThreadSanitizer (TSan), a race detector.
11 //===----------------------------------------------------------------------===//
12 #include "tsan_interface.h"
13 #include "tsan_test_util.h"
14 #include "gtest/gtest.h"
19 TEST_F(ThreadSanitizer
, FuncCall
) {
30 // We use this function instead of main, as ISO C++ forbids taking the address
31 // of main, which we need to pass inside __tsan_func_entry.
32 int run_tests(int argc
, char **argv
) {
33 TestMutexBeforeInit(); // Mutexes must be usable before __tsan_init();
35 __tsan_func_entry(__builtin_return_address(0));
36 __tsan_func_entry((void*)((intptr_t)&run_tests
+ 1));
38 testing::GTEST_FLAG(death_test_style
) = "threadsafe";
39 testing::InitGoogleTest(&argc
, argv
);
40 int res
= RUN_ALL_TESTS();
50 // On Darwin, turns off symbolication and crash logs to make tests faster.
51 extern "C" const char* __tsan_default_options() {
52 return "symbolize=false:abort_on_error=0";
56 int main(int argc
, char **argv
) {
58 return run_tests(argc
, argv
);