[compiler-rt] r224101 - [mips] [test] Enable COMPILER_RT_INCLUDE_TESTS for MIPS

Kumar Sukhani kumarsukhani at gmail.com
Thu Dec 11 23:08:13 PST 2014


Author: sdkie
Date: Fri Dec 12 01:08:12 2014
New Revision: 224101

URL: http://llvm.org/viewvc/llvm-project?rev=224101&view=rev
Log:
[mips] [test] Enable COMPILER_RT_INCLUDE_TESTS for MIPS

Enabling COMPILER_RT_INCLUDE_TESTS and updating tests/sanitizer_allocator_test.cc to remove Allocator64 related tests for MIPS.

Reviewed By: samsonov

Modified:
    compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt
    compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
    compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt?rev=224101&r1=224100&r2=224101&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt Fri Dec 12 01:08:12 2014
@@ -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
                              $<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)

Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc?rev=224101&r1=224100&r2=224101&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc Fri Dec 12 01:08:12 2014
@@ -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, SizeClassAllocator
 TEST(SanitizerCommon, SizeClassAllocator64CompactMetadataStress) {
   SizeClassAllocatorMetadataStress<Allocator64Compact>();
 }
-#endif  // SANITIZER_WORDSIZE == 64
+#endif  // SANITIZER_CAN_USE_ALLOCATOR64
 TEST(SanitizerCommon, SizeClassAllocator32CompactMetadataStress) {
   SizeClassAllocatorMetadataStress<Allocator32Compact>();
 }
@@ -221,7 +223,7 @@ void SizeClassAllocatorGetBlockBeginStre
   delete a;
 }
 
-#if SANITIZER_WORDSIZE == 64
+#if SANITIZER_CAN_USE_ALLOCATOR64
 TEST(SanitizerCommon, SizeClassAllocator64GetBlockBegin) {
   SizeClassAllocatorGetBlockBeginStress<Allocator64>();
 }
@@ -231,7 +233,7 @@ TEST(SanitizerCommon, SizeClassAllocator
 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, SizeClassAllocator
       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, LargeMmapAllocator
 }
 
 
-#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...

Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc?rev=224101&r1=224100&r2=224101&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc Fri Dec 12 01:08:12 2014
@@ -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) {





More information about the llvm-commits mailing list