summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-10-26 12:10:24 +0000
committerAlexey Samsonov <samsonov@google.com>2012-10-26 12:10:24 +0000
commitf70848decb000cc0e4c05a27eed78865d2f38555 (patch)
tree3a80e82845fa1980c00f0df5027a70d0a597682f
parent71578faf4eb8e61aefb3121e1945cc47f07cea0d (diff)
downloadcompiler-rt-f70848decb000cc0e4c05a27eed78865d2f38555.tar.gz
[ASan] don't run hacky test for __asan_get_free_bytes() on 32-bits
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@166771 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/asan/tests/asan_noinst_test.cc33
1 files changed, 18 insertions, 15 deletions
diff --git a/lib/asan/tests/asan_noinst_test.cc b/lib/asan/tests/asan_noinst_test.cc
index 5c9608fc3..2fb5eb7ef 100644
--- a/lib/asan/tests/asan_noinst_test.cc
+++ b/lib/asan/tests/asan_noinst_test.cc
@@ -460,25 +460,28 @@ static void DoLargeMallocForGetFreeBytesTestAndDie() {
}
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};