aboutsummaryrefslogtreecommitdiff
path: root/lib/asan/tests
diff options
context:
space:
mode:
Diffstat (limited to 'lib/asan/tests')
-rw-r--r--lib/asan/tests/CMakeLists.txt11
-rw-r--r--lib/asan/tests/asan_asm_test.cc10
-rw-r--r--lib/asan/tests/asan_interface_test.cc10
-rw-r--r--lib/asan/tests/asan_mac_test.cc4
-rw-r--r--lib/asan/tests/asan_noinst_test.cc2
-rw-r--r--lib/asan/tests/asan_test.cc19
-rw-r--r--lib/asan/tests/asan_test_main.cc14
7 files changed, 43 insertions, 27 deletions
diff --git a/lib/asan/tests/CMakeLists.txt b/lib/asan/tests/CMakeLists.txt
index afdd2adf0887..7a8d8f7f106b 100644
--- a/lib/asan/tests/CMakeLists.txt
+++ b/lib/asan/tests/CMakeLists.txt
@@ -106,7 +106,7 @@ append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread
# TODO(eugenis): move all -l flags above to _LIBS?
set(ASAN_UNITTEST_NOINST_LIBS)
-append_list_if(ANDROID log ASAN_UNITTEST_NOINST_LIBS)
+append_list_if(COMPILER_RT_HAS_LIBLOG log ASAN_UNITTEST_NOINST_LIBS)
# NDK r10 requires -latomic almost always.
append_list_if(ANDROID atomic ASAN_UNITTEST_NOINST_LIBS)
@@ -217,9 +217,10 @@ macro(add_asan_tests_for_arch_and_kind arch kind)
set(ASAN_TEST_RUNTIME RTAsanTest.${arch}${kind})
if(APPLE)
set(ASAN_TEST_RUNTIME_OBJECTS
- $<TARGET_OBJECTS:RTAsan.osx>
+ $<TARGET_OBJECTS:RTAsan_dynamic.osx>
$<TARGET_OBJECTS:RTInterception.osx>
$<TARGET_OBJECTS:RTSanitizerCommon.osx>
+ $<TARGET_OBJECTS:RTSanitizerCommonLibc.osx>
$<TARGET_OBJECTS:RTLSanCommon.osx>
$<TARGET_OBJECTS:RTUbsan.osx>)
else()
@@ -261,7 +262,11 @@ macro(add_asan_tests_for_arch_and_kind arch kind)
endmacro()
if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT ANDROID)
- foreach(arch ${ASAN_SUPPORTED_ARCH})
+ set(ASAN_TEST_ARCH ${ASAN_SUPPORTED_ARCH})
+ if(APPLE)
+ darwin_filter_host_archs(ASAN_SUPPORTED_ARCH ASAN_TEST_ARCH)
+ endif()
+ foreach(arch ${ASAN_TEST_ARCH})
add_asan_tests_for_arch_and_kind(${arch} "-inline")
add_asan_tests_for_arch_and_kind(${arch} "-with-calls"
-mllvm -asan-instrumentation-with-call-threshold=0)
diff --git a/lib/asan/tests/asan_asm_test.cc b/lib/asan/tests/asan_asm_test.cc
index 200de2c137a5..09af5c386079 100644
--- a/lib/asan/tests/asan_asm_test.cc
+++ b/lib/asan/tests/asan_asm_test.cc
@@ -14,7 +14,10 @@
#if defined(__linux__)
-#if defined(__x86_64__) || (defined(__i386__) && defined(__SSE2__))
+// Assembly instrumentation is broken on x86 Android (x86 + PIC + shared runtime
+// library). See https://github.com/google/sanitizers/issues/353
+#if defined(__x86_64__) || \
+ (defined(__i386__) && defined(__SSE2__) && !defined(__ANDROID__))
#include <emmintrin.h>
@@ -70,7 +73,7 @@ DECLARE_ASM_REP_MOVS(U8, "movsq");
#endif // defined(__x86_64__)
-#if defined(__i386__) && defined(__SSE2__)
+#if defined(__i386__) && defined(__SSE2__) && !defined(__ANDROID__)
namespace {
@@ -108,7 +111,8 @@ template<> Type asm_read<Type>(Type *ptr) { \
#endif // defined(__i386__) && defined(__SSE2__)
-#if defined(__x86_64__) || (defined(__i386__) && defined(__SSE2__))
+#if defined(__x86_64__) || \
+ (defined(__i386__) && defined(__SSE2__) && !defined(__ANDROID__))
namespace {
diff --git a/lib/asan/tests/asan_interface_test.cc b/lib/asan/tests/asan_interface_test.cc
index a34c8528eae0..f5bfb8046b0a 100644
--- a/lib/asan/tests/asan_interface_test.cc
+++ b/lib/asan/tests/asan_interface_test.cc
@@ -140,16 +140,6 @@ static void DoDoubleFree() {
delete Ident(x);
}
-TEST(AddressSanitizerInterface, ExitCode) {
- int original_exit_code = __asan_set_error_exit_code(7);
- EXPECT_EXIT(DoDoubleFree(), ::testing::ExitedWithCode(7), "");
- EXPECT_EQ(7, __asan_set_error_exit_code(8));
- EXPECT_EXIT(DoDoubleFree(), ::testing::ExitedWithCode(8), "");
- EXPECT_EQ(8, __asan_set_error_exit_code(original_exit_code));
- EXPECT_EXIT(DoDoubleFree(),
- ::testing::ExitedWithCode(original_exit_code), "");
-}
-
static void MyDeathCallback() {
fprintf(stderr, "MyDeathCallback\n");
fflush(0); // On Windows, stderr doesn't flush on crash.
diff --git a/lib/asan/tests/asan_mac_test.cc b/lib/asan/tests/asan_mac_test.cc
index cabdfd711ea2..dfa6d7596d74 100644
--- a/lib/asan/tests/asan_mac_test.cc
+++ b/lib/asan/tests/asan_mac_test.cc
@@ -216,12 +216,12 @@ TEST(AddressSanitizerMac, NSObjectOOB) {
// Make sure that correct pointer is passed to free() when deallocating a
// NSURL object.
-// See http://code.google.com/p/address-sanitizer/issues/detail?id=70.
+// See https://github.com/google/sanitizers/issues/70.
TEST(AddressSanitizerMac, NSURLDeallocation) {
TestNSURLDeallocation();
}
-// See http://code.google.com/p/address-sanitizer/issues/detail?id=109.
+// See https://github.com/google/sanitizers/issues/109.
TEST(AddressSanitizerMac, Mstats) {
malloc_statistics_t stats1, stats2;
malloc_zone_statistics(/*all zones*/NULL, &stats1);
diff --git a/lib/asan/tests/asan_noinst_test.cc b/lib/asan/tests/asan_noinst_test.cc
index 6a428fbbc2b9..5f5354f92caf 100644
--- a/lib/asan/tests/asan_noinst_test.cc
+++ b/lib/asan/tests/asan_noinst_test.cc
@@ -34,7 +34,7 @@
// Make sure __asan_init is called before any test case is run.
struct AsanInitCaller {
AsanInitCaller() {
- __asan::DisableReexec();
+ DisableReexec();
__asan_init();
}
};
diff --git a/lib/asan/tests/asan_test.cc b/lib/asan/tests/asan_test.cc
index 07d59e09a72f..71fb27a0ca11 100644
--- a/lib/asan/tests/asan_test.cc
+++ b/lib/asan/tests/asan_test.cc
@@ -250,12 +250,12 @@ TEST(AddressSanitizer, BitFieldNegativeTest) {
#if ASAN_NEEDS_SEGV
namespace {
-const char kUnknownCrash[] = "AddressSanitizer: SEGV on unknown address";
+const char kSEGVCrash[] = "AddressSanitizer: SEGV on unknown address";
const char kOverriddenHandler[] = "ASan signal handler has been overridden\n";
TEST(AddressSanitizer, WildAddressTest) {
char *c = (char*)0x123;
- EXPECT_DEATH(*c = 0, kUnknownCrash);
+ EXPECT_DEATH(*c = 0, kSEGVCrash);
}
void my_sigaction_sighandler(int, siginfo_t*, void*) {
@@ -279,10 +279,10 @@ TEST(AddressSanitizer, SignalTest) {
EXPECT_EQ(0, sigaction(SIGBUS, &sigact, 0));
#endif
char *c = (char*)0x123;
- EXPECT_DEATH(*c = 0, kUnknownCrash);
+ EXPECT_DEATH(*c = 0, kSEGVCrash);
// ... and signal().
EXPECT_EQ(0, signal(SIGSEGV, my_signal_sighandler));
- EXPECT_DEATH(*c = 0, kUnknownCrash);
+ EXPECT_DEATH(*c = 0, kSEGVCrash);
}
} // namespace
#endif
@@ -335,6 +335,8 @@ void *ManyThreadsWorker(void *a) {
return 0;
}
+#if !defined(__aarch64__)
+// FIXME: Infinite loop in AArch64 (PR24389).
TEST(AddressSanitizer, ManyThreadsTest) {
const size_t kNumThreads =
(SANITIZER_WORDSIZE == 32 || ASAN_AVOID_EXPENSIVE_TESTS) ? 30 : 1000;
@@ -346,6 +348,7 @@ TEST(AddressSanitizer, ManyThreadsTest) {
PTHREAD_JOIN(t[i], 0);
}
}
+#endif
TEST(AddressSanitizer, ReallocTest) {
const int kMinElem = 5;
@@ -607,7 +610,7 @@ NOINLINE void BuiltinLongJmpFunc1(jmp_buf buf) {
}
// Does not work on Power and ARM:
-// https://code.google.com/p/address-sanitizer/issues/detail?id=185
+// https://github.com/google/sanitizers/issues/185
TEST(AddressSanitizer, BuiltinLongJmpTest) {
static jmp_buf buf;
if (!__builtin_setjmp((void**)buf)) {
@@ -1153,9 +1156,9 @@ TEST(AddressSanitizer, AttributeNoSanitizeAddressTest) {
// The new/delete/etc mismatch checks don't work on Android,
// as calls to new/delete go through malloc/free.
// OS X support is tracked here:
-// https://code.google.com/p/address-sanitizer/issues/detail?id=131
+// https://github.com/google/sanitizers/issues/131
// Windows support is tracked here:
-// https://code.google.com/p/address-sanitizer/issues/detail?id=309
+// https://github.com/google/sanitizers/issues/309
#if !defined(__ANDROID__) && \
!defined(__APPLE__) && \
!defined(_WIN32)
@@ -1252,7 +1255,7 @@ TEST(AddressSanitizer, DISABLED_DemoTooMuchMemoryTest) {
}
}
-// http://code.google.com/p/address-sanitizer/issues/detail?id=66
+// https://github.com/google/sanitizers/issues/66
TEST(AddressSanitizer, BufferOverflowAfterManyFrees) {
for (int i = 0; i < 1000000; i++) {
delete [] (Ident(new char [8644]));
diff --git a/lib/asan/tests/asan_test_main.cc b/lib/asan/tests/asan_test_main.cc
index 1746c5f4837b..cdaf801d914b 100644
--- a/lib/asan/tests/asan_test_main.cc
+++ b/lib/asan/tests/asan_test_main.cc
@@ -11,6 +11,20 @@
//
//===----------------------------------------------------------------------===//
#include "asan_test_utils.h"
+#include "sanitizer_common/sanitizer_platform.h"
+
+// Default ASAN_OPTIONS for the unit tests. Let's turn symbolication off to
+// speed up testing (unit tests don't use it anyway).
+extern "C" const char* __asan_default_options() {
+#if SANITIZER_MAC
+ // On Darwin, we default to `abort_on_error=1`, which would make tests run
+ // much slower. Let's override this and run lit tests with 'abort_on_error=0'.
+ // Also, make sure we do not overwhelm the syslog while testing.
+ return "symbolize=false:abort_on_error=0:log_to_syslog=0";
+#else
+ return "symbolize=false";
+#endif
+}
int main(int argc, char **argv) {
testing::GTEST_FLAG(death_test_style) = "threadsafe";