diff options
Diffstat (limited to 'compiler-rt/lib/sanitizer_common')
3 files changed, 31 insertions, 35 deletions
diff --git a/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt index bb7a399b0ec..75008db3b6c 100644 --- a/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt +++ b/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt @@ -2,6 +2,9 @@ include(CompilerRTCompile) 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 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT ANDROID) $<TARGET_OBJECTS:RTSanitizerCommon.osx>) else() if(CAN_TARGET_x86_64) - add_sanitizer_common_lib("RTSanitizerCommon.test.x86_64" - $<TARGET_OBJECTS:RTSanitizerCommon.x86_64> - $<TARGET_OBJECTS:RTSanitizerCommonLibc.x86_64>) add_sanitizer_common_lib("RTSanitizerCommon.test.nolibc.x86_64" $<TARGET_OBJECTS:RTSanitizerCommon.x86_64>) endif() - if(CAN_TARGET_i386) - add_sanitizer_common_lib("RTSanitizerCommon.test.i386" - $<TARGET_OBJECTS:RTSanitizerCommon.i386> - $<TARGET_OBJECTS:RTSanitizerCommonLibc.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}" + $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> + $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>) + endforeach() endif() + foreach(arch ${SANITIZER_UNITTEST_SUPPORTED_ARCH}) + add_sanitizer_tests_for_arch(${arch}) + endforeach() endif() if(ANDROID) diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc index f61d58dea7d..a571f3674ba 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc +++ b/compiler-rt/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< 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 @@ void TestSizeClassAllocator() { delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64) { TestSizeClassAllocator<Allocator64>(); } @@ -184,7 +186,7 @@ void SizeClassAllocatorMetadataStress() { delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64MetadataStress) { SizeClassAllocatorMetadataStress<Allocator64>(); } @@ -192,7 +194,7 @@ TEST(SanitizerCommon, SizeClassAllocator64MetadataStress) { TEST(SanitizerCommon, SizeClassAllocator64CompactMetadataStress) { SizeClassAllocatorMetadataStress<Allocator64Compact>(); } -#endif // SANITIZER_WORDSIZE == 64 +#endif // SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator32CompactMetadataStress) { SizeClassAllocatorMetadataStress<Allocator32Compact>(); } @@ -221,7 +223,7 @@ void SizeClassAllocatorGetBlockBeginStress() { delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64GetBlockBegin) { SizeClassAllocatorGetBlockBeginStress<Allocator64>(); } @@ -231,7 +233,7 @@ TEST(SanitizerCommon, SizeClassAllocator64CompactGetBlockBegin) { TEST(SanitizerCommon, SizeClassAllocator32CompactGetBlockBegin) { SizeClassAllocatorGetBlockBeginStress<Allocator32Compact>(); } -#endif // SANITIZER_WORDSIZE == 64 +#endif // SANITIZER_CAN_USE_ALLOCATOR64 struct TestMapUnmapCallback { static int map_count, unmap_count; @@ -241,7 +243,7 @@ struct TestMapUnmapCallback { 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 @@ void FailInAssertionOnOOM() { a.TestOnlyUnmap(); } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64Overflow) { EXPECT_DEATH(FailInAssertionOnOOM<Allocator64>(), "Out of memory"); } @@ -465,7 +467,7 @@ void TestCombinedAllocator() { a->TestOnlyUnmap(); } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, CombinedAllocator64) { TestCombinedAllocator<Allocator64, LargeMmapAllocator<>, @@ -521,7 +523,7 @@ void TestSizeClassAllocatorLocalCache() { delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64LocalCache) { TestSizeClassAllocatorLocalCache< SizeClassAllocatorLocalCache<Allocator64> >(); @@ -538,7 +540,7 @@ TEST(SanitizerCommon, SizeClassAllocator32CompactLocalCache) { SizeClassAllocatorLocalCache<Allocator32Compact> >(); } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 typedef SizeClassAllocatorLocalCache<Allocator64> AllocatorCache; static AllocatorCache static_allocator_cache; @@ -694,7 +696,7 @@ void TestSizeClassAllocatorIteration() { delete a; } -#if SANITIZER_WORDSIZE == 64 +#if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, SizeClassAllocator64Iteration) { TestSizeClassAllocatorIteration<Allocator64>(); } @@ -769,7 +771,7 @@ TEST(SanitizerCommon, LargeMmapAllocatorBlockBegin) { } -#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... diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cc index d0b46ac94ff..5e39e0a591d 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cc @@ -28,14 +28,11 @@ TEST(Printf, Basic) { (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) { |

