2013-01-18 20:06:45 +00:00
|
|
|
//===-- asan_test_main.cc -------------------------------------------------===//
|
2011-12-31 14:55:23 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of AddressSanitizer, an address sanity checker.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "asan_test_utils.h"
|
2015-12-30 11:52:19 +00:00
|
|
|
#include "sanitizer_common/sanitizer_platform.h"
|
|
|
|
|
2017-04-20 21:20:59 +00:00
|
|
|
// Default ASAN_OPTIONS for the unit tests.
|
2015-12-30 11:52:19 +00:00
|
|
|
extern "C" const char* __asan_default_options() {
|
|
|
|
#if SANITIZER_MAC
|
|
|
|
// On Darwin, we default to `abort_on_error=1`, which would make tests run
|
2017-04-20 21:20:59 +00:00
|
|
|
// much slower. Let's override this and run lit tests with 'abort_on_error=0'
|
|
|
|
// and make sure we do not overwhelm the syslog while testing. Also, let's
|
|
|
|
// turn symbolization off to speed up testing, especially when not running
|
|
|
|
// with llvm-symbolizer but with atos.
|
2015-12-30 11:52:19 +00:00
|
|
|
return "symbolize=false:abort_on_error=0:log_to_syslog=0";
|
2017-04-20 21:20:59 +00:00
|
|
|
#elif SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT
|
|
|
|
// On PowerPC and ARM Thumb, a couple tests involving pthread_exit fail due to
|
|
|
|
// leaks detected by LSan. Symbolized leak report is required to apply a
|
|
|
|
// suppression for this known problem.
|
|
|
|
return "";
|
2015-12-30 11:52:19 +00:00
|
|
|
#else
|
2017-04-20 21:20:59 +00:00
|
|
|
// Let's turn symbolization off to speed up testing (more than 3 times speedup
|
|
|
|
// observed).
|
2015-12-30 11:52:19 +00:00
|
|
|
return "symbolize=false";
|
|
|
|
#endif
|
|
|
|
}
|
2013-01-18 20:06:45 +00:00
|
|
|
|
2016-07-23 20:45:36 +00:00
|
|
|
namespace __sanitizer {
|
|
|
|
bool ReexecDisabled() {
|
2017-01-02 19:18:27 +00:00
|
|
|
#if __has_feature(address_sanitizer) && SANITIZER_MAC
|
|
|
|
// Allow re-exec in instrumented unit tests on Darwin. Technically, we only
|
|
|
|
// need this for 10.10 and below, where re-exec is required for the
|
|
|
|
// interceptors to work, but to avoid duplicating the version detection logic,
|
|
|
|
// let's just allow re-exec for all Darwin versions. On newer OS versions,
|
|
|
|
// returning 'false' doesn't do anything anyway, because we don't re-exec.
|
|
|
|
return false;
|
|
|
|
#else
|
2016-07-23 20:45:36 +00:00
|
|
|
return true;
|
2017-01-02 19:18:27 +00:00
|
|
|
#endif
|
2016-07-23 20:45:36 +00:00
|
|
|
}
|
2017-01-02 19:18:27 +00:00
|
|
|
} // namespace __sanitizer
|
2016-07-23 20:45:36 +00:00
|
|
|
|
2013-01-18 20:06:45 +00:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
testing::GTEST_FLAG(death_test_style) = "threadsafe";
|
|
|
|
testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
2011-12-31 14:55:23 +00:00
|
|
|
}
|