aboutsummaryrefslogtreecommitdiff
path: root/tests/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/malloc.c')
-rw-r--r--tests/malloc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/malloc.c b/tests/malloc.c
index 98635d4..a50c99b 100644
--- a/tests/malloc.c
+++ b/tests/malloc.c
@@ -25,6 +25,14 @@
#include "hugetests.h"
+/*
+ * We cannot test mapping size against huge page size because we are not linked
+ * against libhugetlbfs so gethugepagesize() won't work. So instead we define
+ * our MIN_PAGE_SIZE as 64 kB (the largest base page available) and make sure
+ * the mapping page size is larger than this.
+ */
+#define MIN_PAGE_SIZE 65536
+
static int block_sizes[] = {
sizeof(int), 1024, 128*1024, 1024*1024, 16*1024*1024,
32*1024*1024,
@@ -47,6 +55,7 @@ int main(int argc, char *argv[])
for (i = 0; i < NUM_SIZES; i++) {
int size = block_sizes[i];
+ unsigned long long mapping_size;
p = malloc(size);
if (! p)
@@ -56,9 +65,11 @@ int main(int argc, char *argv[])
memset(p, 0, size);
- if (expect_hugepage && (test_addr_huge(p) != 1))
+ mapping_size = get_mapping_page_size(p);
+
+ if (expect_hugepage && (mapping_size <= MIN_PAGE_SIZE))
FAIL("Address is not hugepage");
- if (!expect_hugepage && (test_addr_huge(p) == 1))
+ if (!expect_hugepage && (mapping_size > MIN_PAGE_SIZE))
FAIL("Address is unexpectedly huge");
free(p);