1 //===-- asan_test_main.cpp ------------------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file is a part of AddressSanitizer, an address sanity checker. 10 // 11 //===----------------------------------------------------------------------===// 12 #include "asan_test_utils.h" 13 #include "sanitizer_common/sanitizer_platform.h" 14 15 // Default ASAN_OPTIONS for the unit tests. 16 extern "C" const char* __asan_default_options() { 17 #if SANITIZER_MAC 18 // On Darwin, we default to `abort_on_error=1`, which would make tests run 19 // much slower. Let's override this and run lit tests with 'abort_on_error=0' 20 // and make sure we do not overwhelm the syslog while testing. Also, let's 21 // turn symbolization off to speed up testing, especially when not running 22 // with llvm-symbolizer but with atos. 23 return "symbolize=false:abort_on_error=0:log_to_syslog=0"; 24 #elif SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT 25 // On PowerPC and ARM Thumb, a couple tests involving pthread_exit fail due to 26 // leaks detected by LSan. Symbolized leak report is required to apply a 27 // suppression for this known problem. 28 return ""; 29 #else 30 // Let's turn symbolization off to speed up testing (more than 3 times speedup 31 // observed). 32 return "symbolize=false"; 33 #endif 34 } 35 36 namespace __sanitizer { 37 bool ReexecDisabled() { 38 #if __has_feature(address_sanitizer) && SANITIZER_MAC 39 // Allow re-exec in instrumented unit tests on Darwin. Technically, we only 40 // need this for 10.10 and below, where re-exec is required for the 41 // interceptors to work, but to avoid duplicating the version detection logic, 42 // let's just allow re-exec for all Darwin versions. On newer OS versions, 43 // returning 'false' doesn't do anything anyway, because we don't re-exec. 44 return false; 45 #else 46 return true; 47 #endif 48 } 49 } // namespace __sanitizer 50 51 int main(int argc, char **argv) { 52 testing::GTEST_FLAG(death_test_style) = "threadsafe"; 53 testing::InitGoogleTest(&argc, argv); 54 return RUN_ALL_TESTS(); 55 } 56