aboutsummaryrefslogtreecommitdiff
path: root/tests/heapshrink.c
diff options
context:
space:
mode:
authorEric B Munson <emunson@mgebm.net>2010-11-23 08:52:17 -0700
committerEric B Munson <emunson@mgebm.net>2010-11-29 13:41:49 -0700
commitc14a6c872d9806d98a1545ce7a117aaa5719af58 (patch)
treede8e9dc1c67b13e092d5c28499a0b3a600283d83 /tests/heapshrink.c
parent8a5425ed8255acc00dd5108d498329d5ef8b728f (diff)
downloadlibhugetlbfs-c14a6c872d9806d98a1545ce7a117aaa5719af58.tar.gz
Convert heap tests to use get_mapping_page_size
Convert all the heap based tests to use get_mapping_page_size to check if a mapping is backed by huge pages now that morecore uses MAP_HUGETLB. Signed-off-by: Eric B Munson <emunson@mgebm.net>
Diffstat (limited to 'tests/heapshrink.c')
-rw-r--r--tests/heapshrink.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/heapshrink.c b/tests/heapshrink.c
index 9c83210..0644c78 100644
--- a/tests/heapshrink.c
+++ b/tests/heapshrink.c
@@ -22,11 +22,20 @@
#include <string.h>
#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
+
#define SIZE (32 * 1024 * 1024)
int main(int argc, char **argv)
{
int is_huge, have_env, shrink_ok, have_helper;
+ unsigned long long mapping_size;
void *p;
test_init(argc, argv);
@@ -45,7 +54,8 @@ int main(int argc, char **argv)
FAIL("malloc(%d) failed\n", SIZE);
}
memset(p, 0, SIZE);
- is_huge = test_addr_huge(p+SIZE-1) == 1;
+ mapping_size = get_mapping_page_size(p);
+ is_huge = (mapping_size > MIN_PAGE_SIZE);
if (have_env && !is_huge) {
if (shrink_ok && have_helper) {
/* Hitting unexpected behavior in malloc() */
@@ -57,7 +67,8 @@ int main(int argc, char **argv)
FAIL("Heap unexpectedly on hugepages");
free(p);
- if (shrink_ok && test_addr_huge(p+SIZE-1) == 1)
+ mapping_size = get_mapping_page_size(p+SIZE-1);
+ if (shrink_ok && mapping_size > MIN_PAGE_SIZE)
FAIL("Heap did not shrink");
PASS();
}