aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Stancek <jstancek@redhat.com>2012-09-07 15:54:49 +0200
committerEric B Munson <emunson@mgebm.net>2012-09-07 18:48:30 -0400
commit7a0f6c08192ffe93f44fffb4d0327746a61acd77 (patch)
tree509be6b3337f2e9b3fb4c7c96e68c480bebb2caa
parentcdd2fa336d9980eb268a775b7cf9c49e3b698cd7 (diff)
downloadlibhugetlbfs-7a0f6c08192ffe93f44fffb4d0327746a61acd77.tar.gz
dont include base_size in fake hugepagesizes
What is fake on one platform can be actual page_size on some other platform. This testcase failed on ppc64 with 64K pagesize: gethugepagesizes (16M: 32): FAIL Line 397: Duplicate size 65536 at 0/2 gethugepagesizes (16M: 64): FAIL Line 397: Duplicate size 65536 at 0/2 Reason is that getpagesizes() adds pagesize to page sizes from gethugetpagesizes(). This testcase fakes sysfs data, so there is 64K hugepage size and then getpagesizes() adds base_size to that, which is also 64K. Signed-off-by: Jan Stancek <jstancek@redhat.com> Signed-off-by: Eric B Munson <emunson@mgebm.net>
-rw-r--r--tests/gethugepagesizes.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/tests/gethugepagesizes.c b/tests/gethugepagesizes.c
index 860b9a5..9551b38 100644
--- a/tests/gethugepagesizes.c
+++ b/tests/gethugepagesizes.c
@@ -320,7 +320,8 @@ void validate_sizes(int line, long actual_sizes[], int actual,
int main(int argc, char *argv[])
{
- long expected_sizes[MAX], actual_sizes[MAX];
+ int i, fakes_no;
+ long expected_sizes[MAX], actual_sizes[MAX], fake_sizes[MAX];
long base_size = sysconf(_SC_PAGESIZE);
test_init(argc, argv);
@@ -351,7 +352,14 @@ int main(int argc, char *argv[])
*/
INIT_LIST(expected_sizes, HPAGE_KB * 1024, 1024 * 1024, 64 * 1024);
- setup_fake_data(expected_sizes, 3);
+ fakes_no = 0;
+ for (i = 0; i < 3; i++)
+ /* don't include base_size in 'fake' hugepagesizes */
+ if (base_size != expected_sizes[i]) {
+ fake_sizes[fakes_no] = expected_sizes[i];
+ fakes_no++;
+ }
+ setup_fake_data(fake_sizes, fakes_no);
/*
* Check handling when /proc/meminfo indicates no huge page support
@@ -382,30 +390,30 @@ int main(int argc, char *argv[])
sysfs_state = OVERRIDE_ON;
kernel_default_hugepage_size_reset();
- INIT_LIST(expected_sizes, HPAGE_KB * 1024, 1024 * 1024, 64 * 1024);
+ memcpy(expected_sizes, fake_sizes, sizeof(fake_sizes));
/* ... make sure all sizes are returned without duplicates */
/* ... while making sure we do not overstep our limit */
- EXPECT_SIZES(gethugepagesizes, MAX, 3, expected_sizes);
- EXPECT_SIZES(gethugepagesizes, 1, 3, expected_sizes);
- EXPECT_SIZES(gethugepagesizes, 2, 3, expected_sizes);
- EXPECT_SIZES(gethugepagesizes, 3, 3, expected_sizes);
- EXPECT_SIZES(gethugepagesizes, 4, 3, expected_sizes);
-
- INIT_LIST(expected_sizes,
- base_size, HPAGE_KB * 1024, 1024 * 1024, 64 * 1024);
- EXPECT_SIZES(getpagesizes, MAX, 4, expected_sizes);
- EXPECT_SIZES(getpagesizes, 1, 4, expected_sizes);
- EXPECT_SIZES(getpagesizes, 2, 4, expected_sizes);
- EXPECT_SIZES(getpagesizes, 3, 4, expected_sizes);
- EXPECT_SIZES(getpagesizes, 4, 4, expected_sizes);
- EXPECT_SIZES(getpagesizes, 5, 4, expected_sizes);
+ EXPECT_SIZES(gethugepagesizes, MAX, fakes_no, expected_sizes);
+ EXPECT_SIZES(gethugepagesizes, 1, fakes_no, expected_sizes);
+ EXPECT_SIZES(gethugepagesizes, 2, fakes_no, expected_sizes);
+ EXPECT_SIZES(gethugepagesizes, 3, fakes_no, expected_sizes);
+ EXPECT_SIZES(gethugepagesizes, 4, fakes_no, expected_sizes);
+
+ memcpy(expected_sizes, fake_sizes, sizeof(fake_sizes));
+ expected_sizes[fakes_no] = base_size;
+ EXPECT_SIZES(getpagesizes, MAX, fakes_no + 1, expected_sizes);
+ EXPECT_SIZES(getpagesizes, 1, fakes_no + 1, expected_sizes);
+ EXPECT_SIZES(getpagesizes, 2, fakes_no + 1, expected_sizes);
+ EXPECT_SIZES(getpagesizes, 3, fakes_no + 1, expected_sizes);
+ EXPECT_SIZES(getpagesizes, 4, fakes_no + 1, expected_sizes);
+ EXPECT_SIZES(getpagesizes, 5, fakes_no + 1, expected_sizes);
/* ... we can check how many sizes are supported. */
- if (gethugepagesizes(NULL, 0) != 3)
+ if (gethugepagesizes(NULL, 0) != fakes_no)
FAIL("Unable to check the number of supported sizes");
- if (getpagesizes(NULL, 0) != 4)
+ if (getpagesizes(NULL, 0) != fakes_no + 1)
FAIL("Unable to check the number of supported sizes");
PASS();