aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Android.mk9
-rw-r--r--tests/malloc_test.cpp9
-rw-r--r--tests/string_test.cpp7
3 files changed, 22 insertions, 3 deletions
diff --git a/tests/Android.mk b/tests/Android.mk
index c2e76b6bc..ce0c5f211 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -115,9 +115,18 @@ libBionicStandardTests_src_files := \
libBionicStandardTests_cflags := \
$(test_cflags) \
+ifeq ($(MALLOC_IMPL),jemalloc)
+ libBionicStandardTests_cflags += -DUSE_JEMALLOC
+else
+ libBionicStandardTests_cflags += -DUSE_DLMALLOC
+endif
+
libBionicStandardTests_cppflags := \
$(test_cppflags) \
+libBionicStandardTests_c_includes := \
+ bionic/libc \
+
libBionicStandardTests_ldlibs_host := \
-lrt \
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index ed98f15d3..d70136496 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -22,6 +22,10 @@
#include <malloc.h>
#include <unistd.h>
+#if defined(__BIONIC__)
+#include <libc/bionic/malloc_debug_common.h>
+#endif
+
TEST(malloc, malloc_std) {
// Simple malloc test.
void *ptr = malloc(100);
@@ -291,6 +295,10 @@ TEST(malloc, realloc_overflow) {
free(ptr);
}
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
+extern "C" void* pvalloc(size_t);
+extern "C" void* valloc(size_t);
+
TEST(malloc, pvalloc_std) {
size_t pagesize = sysconf(_SC_PAGESIZE);
void* ptr = pvalloc(100);
@@ -315,3 +323,4 @@ TEST(malloc, valloc_std) {
TEST(malloc, valloc_overflow) {
ASSERT_EQ(NULL, valloc(SIZE_MAX));
}
+#endif
diff --git a/tests/string_test.cpp b/tests/string_test.cpp
index a468b97fc..2ab60d771 100644
--- a/tests/string_test.cpp
+++ b/tests/string_test.cpp
@@ -17,6 +17,7 @@
#include <gtest/gtest.h>
#include <errno.h>
+#include <malloc.h>
#include <math.h>
#include <string.h>
@@ -143,9 +144,9 @@ struct StringTestState {
int max_alignment = 64;
// TODO: fix the tests to not sometimes use twice their specified "MAX_LEN".
- glob_ptr = reinterpret_cast<Character*>(valloc(2 * sizeof(Character) * MAX_LEN + max_alignment));
- glob_ptr1 = reinterpret_cast<Character*>(valloc(2 * sizeof(Character) * MAX_LEN + max_alignment));
- glob_ptr2 = reinterpret_cast<Character*>(valloc(2 * sizeof(Character) * MAX_LEN + max_alignment));
+ glob_ptr = reinterpret_cast<Character*>(memalign(sysconf(_SC_PAGESIZE), 2 * sizeof(Character) * MAX_LEN + max_alignment));
+ glob_ptr1 = reinterpret_cast<Character*>(memalign(sysconf(_SC_PAGESIZE), 2 * sizeof(Character) * MAX_LEN + max_alignment));
+ glob_ptr2 = reinterpret_cast<Character*>(memalign(sysconf(_SC_PAGESIZE), 2 * sizeof(Character) * MAX_LEN + max_alignment));
InitLenArray();