[llvm-commits] [compiler-rt] r166771 - /compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc

Alexey Samsonov samsonov at google.com
Fri Oct 26 05:10:24 PDT 2012


Author: samsonov
Date: Fri Oct 26 07:10:24 2012
New Revision: 166771

URL: http://llvm.org/viewvc/llvm-project?rev=166771&view=rev
Log:
[ASan] don't run hacky test for __asan_get_free_bytes() on 32-bits

Modified:
    compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc

Modified: compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc?rev=166771&r1=166770&r2=166771&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc Fri Oct 26 07:10:24 2012
@@ -460,25 +460,28 @@
 }
 
 TEST(AddressSanitizerInterface, GetFreeBytesTest) {
-  static const size_t kNumOfChunks = 100;
-  static const size_t kChunkSize = 100;
-  char *chunks[kNumOfChunks];
-  size_t i;
-  size_t old_free_bytes, new_free_bytes;
   // Allocate a small chunk. Now allocator probably has a lot of these
   // chunks to fulfill future requests. So, future requests will decrease
-  // the number of free bytes.
-  chunks[0] = Ident((char*)malloc(kChunkSize));
-  old_free_bytes = __asan_get_free_bytes();
-  for (i = 1; i < kNumOfChunks; i++) {
-    chunks[i] = Ident((char*)malloc(kChunkSize));
-    new_free_bytes = __asan_get_free_bytes();
-    EXPECT_LT(new_free_bytes, old_free_bytes);
-    old_free_bytes = new_free_bytes;
+  // the number of free bytes. Do this only on systems where there
+  // is enough memory for such assumptions.
+  if (__WORDSIZE == 64 && !ASAN_LOW_MEMORY) {
+    static const size_t kNumOfChunks = 100;
+    static const size_t kChunkSize = 100;
+    char *chunks[kNumOfChunks];
+    size_t i;
+    size_t old_free_bytes, new_free_bytes;
+    chunks[0] = Ident((char*)malloc(kChunkSize));
+    old_free_bytes = __asan_get_free_bytes();
+    for (i = 1; i < kNumOfChunks; i++) {
+      chunks[i] = Ident((char*)malloc(kChunkSize));
+      new_free_bytes = __asan_get_free_bytes();
+      EXPECT_LT(new_free_bytes, old_free_bytes);
+      old_free_bytes = new_free_bytes;
+    }
+    for (i = 0; i < kNumOfChunks; i++)
+      free(chunks[i]);
   }
   EXPECT_DEATH(DoLargeMallocForGetFreeBytesTestAndDie(), "double-free");
-  for (i = 0; i < kNumOfChunks; i++)
-    free(chunks[i]);
 }
 
 static const size_t kManyThreadsMallocSizes[] = {5, 1UL<<10, 1UL<<20, 357};





More information about the llvm-commits mailing list