aboutsummaryrefslogtreecommitdiff
path: root/tests/run_tests.py
diff options
context:
space:
mode:
authorDavid Gibson <dwg@au1.ibm.com>2009-11-19 19:11:28 +1100
committerEric B Munson <ebmunson@us.ibm.com>2009-11-19 08:35:07 +0000
commitc5f56f187505f039ebb692a615fefe766830b210 (patch)
tree6dbb1040a4e28e7524f6e09e800d7bc2d167f3b6 /tests/run_tests.py
parent018405308d9e8d77430ff38b5dfb3c7aa227fb15 (diff)
downloadlibhugetlbfs-c5f56f187505f039ebb692a615fefe766830b210.tar.gz
Don't try to test multiple pagesizes for SysV shm
Currently, run_tests.py attempts to run each test case for each available page size and word size. It does this by setting the HUGETLB_DEFAULT_PAGE_SIZE environment variable to instruct the testcase's instance of libhugetlbfs to use the specified pagesize. However some of the testcases use shmget() with the SHM_HUGETLB flag to obtain hugepage backed memory, rather than mmap() or the libhugetlbfs interfaces. This means of obtaining hugepage memory has no way to specify the pagesize, and will always use the system default huge page size. Therefore, running the test multiple times when it won't actually use a different pagesize is silly. Furthermore in some of the cases, using the non-default sizes results in test failures (because we don't allocate as much memory as we expect) which have to be suppressed with a wrapper script which turns them into expected failures. This patch, therefore, alters run_tests.py to run the shm only tests with only the default page size. This is accomplished with a new helper function 'do_shm_test', which also folds in the setting and restoring of the shmmax limit for added convenience. The no longer necessary wrappers for shm-fork and shm-getraw are removed. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
Diffstat (limited to 'tests/run_tests.py')
-rwxr-xr-xtests/run_tests.py44
1 files changed, 30 insertions, 14 deletions
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 547dd72..e53b71c 100755
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -460,6 +460,20 @@ def restore_shm_sysctl(sysctls):
fh.write(val)
fh.close()
+def do_shm_test(cmd, limit=None, bits=None, **env):
+ """
+ Run a test case with temporarily expanded SysV shm limits, testing
+ each indicated word size.
+ """
+ if bits == None:
+ bits = wordsizes
+ if limit != None:
+ tmp = setup_shm_sysctl(limit)
+ for b in bits:
+ run_test(system_default_hpage_size, b, cmd, **env)
+ if limit != None:
+ restore_shm_sysctl(tmp)
+
def functional_tests():
"""
Run the set of functional tests.
@@ -510,9 +524,7 @@ def functional_tests():
do_test("readahead_reserve.sh")
do_test("madvise_reserve.sh")
do_test("fadvise_reserve.sh")
- sysctls = setup_shm_sysctl(64*1048576)
- do_test("shm-perms")
- restore_shm_sysctl(sysctls)
+ do_shm_test("shm-perms", 64*1024*1024)
# Tests requiring an active mount and hugepage COW
do_test("private")
@@ -562,8 +574,8 @@ def functional_tests():
do_test("get_huge_pages")
# Test overriding of shmget()
- do_test("shmoverride_linked")
- do_test("shmoverride_unlinked", LD_PRELOAD="libhugetlbfs.so")
+ do_shm_test("shmoverride_linked")
+ do_shm_test("shmoverride_unlinked", LD_PRELOAD="libhugetlbfs.so")
# Test hugetlbfs filesystem quota accounting
do_test("quota.sh")
@@ -589,23 +601,20 @@ def stress_tests():
do_test(("mmap-cow", repr(nr_pages-1), repr(nr_pages)))
(rc, tot_pages) = total_hpages()
- (rc, size) = hpage_size()
- sysctls = setup_shm_sysctl(tot_pages * size)
+ limit = system_default_hpage_size * tot_pages
threads = 10 # Number of threads for shm-fork
+
# Run shm-fork once using half available hugepages, then once using all
# This is to catch off-by-ones or races in the kernel allocated that
# can make allocating all hugepages a problem
if nr_pages > 1:
- do_test(("shm-fork.sh", repr(threads), repr(nr_pages / 2)))
- do_test(("shm-fork.sh", repr(threads), repr(nr_pages)))
-
- do_test(("shm-getraw.sh", repr(nr_pages), "/dev/full"))
- restore_shm_sysctl(sysctls)
-
+ do_shm_test(("shm-fork", repr(threads), repr(nr_pages / 2)), limit)
+ do_shm_test(("shm-fork", repr(threads), repr(nr_pages)), limit)
+ do_shm_test(("shm-getraw", repr(nr_pages), "/dev/full"), limit)
def main():
- global wordsizes, pagesizes, dangerous, paranoid_pool_check
+ global wordsizes, pagesizes, dangerous, paranoid_pool_check, system_default_hpage_size
testsets = set()
env_override = {"QUIET_TEST": "1", "HUGETLBFS_MOUNTS": "",
"HUGETLB_ELFMAP": None, "HUGETLB_MORECORE": None}
@@ -647,6 +656,13 @@ def main():
setup_env(env_override, env_defaults)
init_results()
+
+ (rc, system_default_hpage_size) = hpage_size()
+ if rc != 0:
+ print "Unable to find system default hugepage size."
+ print "Is hugepage supported included in this kernel?"
+ return 1
+
check_hugetlbfs_path()
if "func" in testsets: functional_tests()