1//===-- tsan_test.cc ------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file is a part of ThreadSanitizer (TSan), a race detector. 11// 12//===----------------------------------------------------------------------===// 13#include "tsan_interface.h" 14#include "tsan_test_util.h" 15#include "gtest/gtest.h" 16 17static void foo() {} 18static void bar() {} 19 20TEST(ThreadSanitizer, FuncCall) { 21 ScopedThread t1, t2; 22 MemLoc l; 23 t1.Write1(l); 24 t2.Call(foo); 25 t2.Call(bar); 26 t2.Write1(l, true); 27 t2.Return(); 28 t2.Return(); 29} 30 31int main(int argc, char **argv) { 32 TestMutexBeforeInit(); // Mutexes must be usable before __tsan_init(); 33 __tsan_init(); 34 __tsan_func_entry(__builtin_return_address(0)); 35 __tsan_func_entry((char*)&main + 1); 36 37 testing::GTEST_FLAG(death_test_style) = "threadsafe"; 38 testing::InitGoogleTest(&argc, argv); 39 int res = RUN_ALL_TESTS(); 40 41 __tsan_func_exit(); 42 __tsan_func_exit(); 43 return res; 44} 45