diff options
author | Christopher Ferris <cferris@google.com> | 2014-05-08 11:14:03 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2014-05-20 14:47:33 -0700 |
commit | 72bbd423579bb971dc06cdd3c06201faf3fe95e6 (patch) | |
tree | 222c460d45ac120ae45940628c501d6cfb50f84b /tests/malloc_test.cpp | |
parent | afb89c2a01089bb247456634a15a58f111bb55a6 (diff) | |
download | android_bionic-72bbd423579bb971dc06cdd3c06201faf3fe95e6.tar.gz android_bionic-72bbd423579bb971dc06cdd3c06201faf3fe95e6.tar.bz2 android_bionic-72bbd423579bb971dc06cdd3c06201faf3fe95e6.zip |
Support for jemalloc to replace dlmalloc.
To use jemalloc, add MALLOC_IMPL = jemalloc in a board config file
and you get the new version automatically.
Update the pthread_create_key tests since jemalloc uses a few keys.
Add a new test to verify memalign works as expected.
Bug: 981363
Change-Id: I16eb152b291a95bd2499e90492fc6b4bd7053836
Diffstat (limited to 'tests/malloc_test.cpp')
-rw-r--r-- | tests/malloc_test.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp index 259853dca..12a5ffab8 100644 --- a/tests/malloc_test.cpp +++ b/tests/malloc_test.cpp @@ -46,7 +46,7 @@ TEST(malloc, memalign_multiple) { for (size_t i = 0; i <= 12; i++) { for (size_t alignment = 1 << i; alignment < (1U << (i+1)); alignment++) { char *ptr = (char*)memalign(alignment, 100); - ASSERT_TRUE(ptr != NULL); + ASSERT_TRUE(ptr != NULL) << alignment; ASSERT_LE(100U, malloc_usable_size(ptr)); ASSERT_EQ(0, (intptr_t)ptr % (1 << i)); @@ -233,3 +233,18 @@ TEST(malloc, calloc_multiple_realloc) { free(ptr); } + +TEST(malloc, posix_memalign_non_power2) { + void* ptr; + + ASSERT_EQ(EINVAL, posix_memalign(&ptr, 17, 1024)); +} + +TEST(malloc, memalign_non_power2) { + void* ptr; + for (size_t align = 0; align <= 256; align++) { + ptr = memalign(align, 1024); + ASSERT_TRUE(ptr != NULL) << "Failed at align " << align; + free(ptr); + } +} |