aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric B Munson <emunson@mgebm.net>2010-11-23 08:52:15 -0700
committerEric B Munson <emunson@mgebm.net>2010-11-29 13:41:38 -0700
commit2da40576d002aceaf3d281ebfed62982ea6c3b60 (patch)
tree35da0043c132fdee8fe672dcb266cd4ada4fae07
parentfe0b1c2c4223448dddace59e159eed80d0d8f875 (diff)
downloadlibhugetlbfs-2da40576d002aceaf3d281ebfed62982ea6c3b60.tar.gz
Convert the get_huge_pages tests to use new smaps test
If get_huge_pages uses MAP_HUGETLB to create a new huge page region, the old test_addr_huge function will claim the mapping is not on a huge page. This patch changes the test to use the new get_mapping_page_size method. Signed-off-by: Eric B Munson <emunson@mgebm.net>
-rw-r--r--tests/get_huge_pages.c12
-rw-r--r--tests/get_hugepage_region.c4
2 files changed, 10 insertions, 6 deletions
diff --git a/tests/get_huge_pages.c b/tests/get_huge_pages.c
index 5687699..2dc4e3d 100644
--- a/tests/get_huge_pages.c
+++ b/tests/get_huge_pages.c
@@ -45,20 +45,22 @@ void free_and_confirm_region_free(void *p, int line) {
void test_get_huge_pages(int num_hugepages)
{
- int err;
+ unsigned long long mapping_size;
void *p = get_huge_pages(num_hugepages * hpage_size, GHP_DEFAULT);
if (p == NULL)
FAIL("get_huge_pages() for %d hugepages", num_hugepages);
memset(p, 1, hpage_size);
- err = test_addr_huge(p + (num_hugepages -1) * hpage_size);
- if (err != 1)
+ mapping_size = get_mapping_page_size(
+ (void *)p + (num_hugepages -1) * hpage_size);
+ if (mapping_size != hpage_size)
FAIL("Returned page is not hugepage");
free_and_confirm_region_free(p, __LINE__);
- err = test_addr_huge(p);
- if (err == 1)
+ mapping_size = get_mapping_page_size(
+ (void *)p + (num_hugepages -1) * hpage_size);
+ if (mapping_size)
FAIL("hugepage was not correctly freed");
}
diff --git a/tests/get_hugepage_region.c b/tests/get_hugepage_region.c
index 2fb5b23..292d201 100644
--- a/tests/get_hugepage_region.c
+++ b/tests/get_hugepage_region.c
@@ -45,8 +45,10 @@ void free_and_confirm_region_free(void *p, int line) {
int test_unaligned_addr_huge(void *p)
{
+ unsigned long long mapping_size;
p = (void *)((unsigned long)p & ~((gethugepagesize()) - 1));
- return test_addr_huge(p);
+ mapping_size = get_mapping_page_size(p);
+ return (mapping_size == hpage_size);
}
#define TESTLEN ((num_hugepages - 1) * hpage_size + hpage_size / 2)