1246149Ssjg//===-- asan_test_main.cc -------------------------------------------------===//
2246149Ssjg//
3246149Ssjg//                     The LLVM Compiler Infrastructure
4246149Ssjg//
5246149Ssjg// This file is distributed under the University of Illinois Open Source
6246149Ssjg// License. See LICENSE.TXT for details.
7246149Ssjg//
8246149Ssjg//===----------------------------------------------------------------------===//
9246149Ssjg//
10246149Ssjg// This file is a part of AddressSanitizer, an address sanity checker.
11246149Ssjg//
12246149Ssjg//===----------------------------------------------------------------------===//
13246149Ssjg#include "asan_test_utils.h"
14246149Ssjg#include "sanitizer_common/sanitizer_platform.h"
15246149Ssjg
16246149Ssjg// Default ASAN_OPTIONS for the unit tests.
17246149Ssjgextern "C" const char* __asan_default_options() {
18246149Ssjg#if SANITIZER_MAC
19246149Ssjg  // On Darwin, we default to `abort_on_error=1`, which would make tests run
20246149Ssjg  // much slower. Let's override this and run lit tests with 'abort_on_error=0'
21246149Ssjg  // and make sure we do not overwhelm the syslog while testing. Also, let's
22246149Ssjg  // turn symbolization off to speed up testing, especially when not running
23246149Ssjg  // with llvm-symbolizer but with atos.
24246149Ssjg  return "symbolize=false:abort_on_error=0:log_to_syslog=0";
25246149Ssjg#elif SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT
26246149Ssjg  // On PowerPC and ARM Thumb, a couple tests involving pthread_exit fail due to
27246149Ssjg  // leaks detected by LSan. Symbolized leak report is required to apply a
28246149Ssjg  // suppression for this known problem.
29246149Ssjg  return "";
30246149Ssjg#else
31246149Ssjg  // Let's turn symbolization off to speed up testing (more than 3 times speedup
32246149Ssjg  // observed).
33246149Ssjg  return "symbolize=false";
34246149Ssjg#endif
35246149Ssjg}
36246149Ssjg
37246149Ssjgnamespace __sanitizer {
38246149Ssjgbool ReexecDisabled() {
39246149Ssjg#if __has_feature(address_sanitizer) && SANITIZER_MAC
40246149Ssjg  // Allow re-exec in instrumented unit tests on Darwin.  Technically, we only
41246149Ssjg  // need this for 10.10 and below, where re-exec is required for the
42246149Ssjg  // interceptors to work, but to avoid duplicating the version detection logic,
43246149Ssjg  // let's just allow re-exec for all Darwin versions.  On newer OS versions,
44246149Ssjg  // returning 'false' doesn't do anything anyway, because we don't re-exec.
45246149Ssjg  return false;
46246149Ssjg#else
47246149Ssjg  return true;
48246149Ssjg#endif
49246149Ssjg}
50246149Ssjg}  // namespace __sanitizer
51246149Ssjg
52246149Ssjgint main(int argc, char **argv) {
53246149Ssjg  testing::GTEST_FLAG(death_test_style) = "threadsafe";
54246149Ssjg  testing::InitGoogleTest(&argc, argv);
55246149Ssjg  return RUN_ALL_TESTS();
56246149Ssjg}
57246149Ssjg