Index: lib/sanitizer_common/tests/CMakeLists.txt =================================================================== --- lib/sanitizer_common/tests/CMakeLists.txt +++ lib/sanitizer_common/tests/CMakeLists.txt @@ -2,6 +2,9 @@ clang_compiler_add_cxx_check() +# FIXME: use SANITIZER_COMMON_SUPPORTED_ARCH here +filter_available_targets(SANITIZER_UNITTEST_SUPPORTED_ARCH x86_64 i386 mips64 mips64el) + set(SANITIZER_UNITTESTS sanitizer_allocator_test.cc sanitizer_atomic_test.cc @@ -157,24 +160,18 @@ $) else() if(CAN_TARGET_x86_64) - add_sanitizer_common_lib("RTSanitizerCommon.test.x86_64" - $ - $) add_sanitizer_common_lib("RTSanitizerCommon.test.nolibc.x86_64" $) endif() - if(CAN_TARGET_i386) - add_sanitizer_common_lib("RTSanitizerCommon.test.i386" - $ - $) - endif() - endif() - if(CAN_TARGET_x86_64) - add_sanitizer_tests_for_arch(x86_64) - endif() - if(CAN_TARGET_i386) - add_sanitizer_tests_for_arch(i386) + foreach(arch ${SANITIZER_UNITTEST_SUPPORTED_ARCH}) + add_sanitizer_common_lib("RTSanitizerCommon.test.${arch}" + $ + $) + endforeach() endif() + foreach(arch ${SANITIZER_UNITTEST_SUPPORTED_ARCH}) + add_sanitizer_tests_for_arch(${arch}) + endforeach() endif() if(ANDROID) Index: lib/sanitizer_common/tests/sanitizer_allocator_test.cc =================================================================== --- lib/sanitizer_common/tests/sanitizer_allocator_test.cc +++ lib/sanitizer_common/tests/sanitizer_allocator_test.cc @@ -29,7 +29,7 @@ // Too slow for debug build #if TSAN_DEBUG == 0 -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 static const uptr kAllocatorSpace = 0x700000000000ULL; static const uptr kAllocatorSize = 0x010000000000ULL; // 1T. static const u64 kAddressSpaceSize = 1ULL << 47; @@ -39,6 +39,8 @@ typedef SizeClassAllocator64< kAllocatorSpace, kAllocatorSize, 16, CompactSizeClassMap> Allocator64Compact; +#elif defined(__mips64) +static const u64 kAddressSpaceSize = 1ULL << 40; #else static const u64 kAddressSpaceSize = 1ULL << 32; #endif @@ -140,7 +142,7 @@ delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64) { TestSizeClassAllocator(); } @@ -184,7 +186,7 @@ delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64MetadataStress) { SizeClassAllocatorMetadataStress(); } @@ -192,7 +194,7 @@ TEST(SanitizerCommon, SizeClassAllocator64CompactMetadataStress) { SizeClassAllocatorMetadataStress(); } -#endif // SANITIZER_WORDSIZE == 64 +#endif // SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator32CompactMetadataStress) { SizeClassAllocatorMetadataStress(); } @@ -221,7 +223,7 @@ delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64GetBlockBegin) { SizeClassAllocatorGetBlockBeginStress(); } @@ -231,7 +233,7 @@ TEST(SanitizerCommon, SizeClassAllocator32CompactGetBlockBegin) { SizeClassAllocatorGetBlockBeginStress(); } -#endif // SANITIZER_WORDSIZE == 64 +#endif // SANITIZER_CAN_USE_ALLOCATOR64 struct TestMapUnmapCallback { static int map_count, unmap_count; @@ -241,7 +243,7 @@ int TestMapUnmapCallback::map_count; int TestMapUnmapCallback::unmap_count; -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64MapUnmapCallback) { TestMapUnmapCallback::map_count = 0; TestMapUnmapCallback::unmap_count = 0; @@ -322,7 +324,7 @@ a.TestOnlyUnmap(); } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64Overflow) { EXPECT_DEATH(FailInAssertionOnOOM(), "Out of memory"); } @@ -465,7 +467,7 @@ a->TestOnlyUnmap(); } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, CombinedAllocator64) { TestCombinedAllocator, @@ -521,7 +523,7 @@ delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64LocalCache) { TestSizeClassAllocatorLocalCache< SizeClassAllocatorLocalCache >(); @@ -538,7 +540,7 @@ SizeClassAllocatorLocalCache >(); } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 typedef SizeClassAllocatorLocalCache AllocatorCache; static AllocatorCache static_allocator_cache; @@ -694,7 +696,7 @@ delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64Iteration) { TestSizeClassAllocatorIteration(); } @@ -769,7 +771,7 @@ } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 // Regression test for out-of-memory condition in PopulateFreeList(). TEST(SanitizerCommon, SizeClassAllocator64PopulateFreeListOOM) { // In a world where regions are small and chunks are huge... Index: lib/sanitizer_common/tests/sanitizer_printf_test.cc =================================================================== --- lib/sanitizer_common/tests/sanitizer_printf_test.cc +++ lib/sanitizer_common/tests/sanitizer_printf_test.cc @@ -28,14 +28,11 @@ (unsigned)10, (unsigned long)11, // NOLINT (void*)0x123, "_string_"); EXPECT_EQ(len, strlen(buf)); - void *ptr; - if (sizeof(ptr) == 4) { - EXPECT_STREQ("a-1b-2c4294967292e5fahbq" - "0x00000123e_string_r", buf); - } else { - EXPECT_STREQ("a-1b-2c4294967292e5fahbq" - "0x000000000123e_string_r", buf); - } + + std::string expectedString = "a-1b-2c4294967292e5fahbq0x"; + expectedString += std::string(SANITIZER_POINTER_FORMAT_LENGTH - 3, '0'); + expectedString += "123e_string_r"; + EXPECT_STREQ(expectedString.c_str(), buf); } TEST(Printf, OverflowStr) {