Index: lib/sanitizer_common/tests/CMakeLists.txt =================================================================== --- lib/sanitizer_common/tests/CMakeLists.txt +++ lib/sanitizer_common/tests/CMakeLists.txt @@ -2,6 +2,8 @@ clang_compiler_add_cxx_check() +filter_available_targets(SANITIZER_TEST_SUPPORTED_ARCH x86_64 i386 mips64 mips64el) + set(SANITIZER_UNITTESTS sanitizer_allocator_test.cc sanitizer_atomic_test.cc @@ -157,24 +159,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_TEST_SUPPORTED_ARCH}) + add_sanitizer_common_lib("RTSanitizerCommon.test.${arch}" + $ + $) + endforeach() endif() + foreach(arch ${SANITIZER_TEST_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 == 64 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 == 64 TEST(SanitizerCommon, SizeClassAllocator64) { TestSizeClassAllocator(); } @@ -184,7 +186,7 @@ delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 == 64 TEST(SanitizerCommon, SizeClassAllocator64MetadataStress) { SizeClassAllocatorMetadataStress(); } @@ -192,7 +194,7 @@ TEST(SanitizerCommon, SizeClassAllocator64CompactMetadataStress) { SizeClassAllocatorMetadataStress(); } -#endif // SANITIZER_WORDSIZE == 64 +#endif // SANITIZER_CAN_USE_ALLOCATOR64 == 64 TEST(SanitizerCommon, SizeClassAllocator32CompactMetadataStress) { SizeClassAllocatorMetadataStress(); } @@ -221,7 +223,7 @@ delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 == 64 TEST(SanitizerCommon, SizeClassAllocator64GetBlockBegin) { SizeClassAllocatorGetBlockBeginStress(); } @@ -231,7 +233,7 @@ TEST(SanitizerCommon, SizeClassAllocator32CompactGetBlockBegin) { SizeClassAllocatorGetBlockBeginStress(); } -#endif // SANITIZER_WORDSIZE == 64 +#endif // SANITIZER_CAN_USE_ALLOCATOR64 == 64 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 == 64 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 == 64 TEST(SanitizerCommon, SizeClassAllocator64Overflow) { EXPECT_DEATH(FailInAssertionOnOOM(), "Out of memory"); } @@ -379,7 +381,8 @@ CHECK_EQ(a.TotalMemoryUsed(), 0); // Test alignments. - uptr max_alignment = SANITIZER_WORDSIZE == 64 ? (1 << 28) : (1 << 24); + uptr max_alignment = SANITIZER_CAN_USE_ALLOCATOR64 == 64 ? (1 << 28) : + (1 << 24); for (uptr alignment = 8; alignment <= max_alignment; alignment *= 2) { const uptr kNumAlignedAllocs = 100; for (uptr i = 0; i < kNumAlignedAllocs; i++) { @@ -465,7 +468,7 @@ a->TestOnlyUnmap(); } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 == 64 TEST(SanitizerCommon, CombinedAllocator64) { TestCombinedAllocator, @@ -521,7 +524,7 @@ delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 == 64 TEST(SanitizerCommon, SizeClassAllocator64LocalCache) { TestSizeClassAllocatorLocalCache< SizeClassAllocatorLocalCache >(); @@ -538,7 +541,7 @@ SizeClassAllocatorLocalCache >(); } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 == 64 typedef SizeClassAllocatorLocalCache AllocatorCache; static AllocatorCache static_allocator_cache; @@ -694,7 +697,7 @@ delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 == 64 TEST(SanitizerCommon, SizeClassAllocator64Iteration) { TestSizeClassAllocatorIteration(); } @@ -769,7 +772,7 @@ } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 == 64 // 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,10 +28,12 @@ (unsigned)10, (unsigned long)11, // NOLINT (void*)0x123, "_string_"); EXPECT_EQ(len, strlen(buf)); - void *ptr; - if (sizeof(ptr) == 4) { + if (SANITIZER_POINTER_FORMAT_LENGTH == 8) { EXPECT_STREQ("a-1b-2c4294967292e5fahbq" "0x00000123e_string_r", buf); + } else if (SANITIZER_POINTER_FORMAT_LENGTH == 10) { + EXPECT_STREQ("a-1b-2c4294967292e5fahbq" + "0x0000000123e_string_r", buf); } else { EXPECT_STREQ("a-1b-2c4294967292e5fahbq" "0x000000000123e_string_r", buf);