aboutsummaryrefslogtreecommitdiff
path: root/tests/run_tests.py
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2009-11-19 14:54:48 +1100
committerEric B Munson <ebmunson@us.ibm.com>2009-11-19 08:35:03 +0000
commit018405308d9e8d77430ff38b5dfb3c7aa227fb15 (patch)
treee1b26a3613fce9b01dbdc9f30b21725b364604ae /tests/run_tests.py
parentc77742d80f4a17be14046239c763b52298663c57 (diff)
downloadlibhugetlbfs-018405308d9e8d77430ff38b5dfb3c7aa227fb15.tar.gz
Add paranoid checking of hugepage pool sizes
This patch adds code to the run_tests.py script to check the state of all the hugepage pools before and after each testcase. When turned on (with the new '-c' option to run_tests.py), it will report an error if the pool sizes are different after the test than before. Obviously this can report bogus errors if other programs are using hugepages on the system, or if dynamic pools are enabled. Nonetheless it can be useful it can be useful for detecting and tracking down subtle kernel bugs which result in misaccounting of the pool state (I've used it to debug such problems in a new hugepage port). 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.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/tests/run_tests.py b/tests/run_tests.py
index ac87703..547dd72 100755
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -48,7 +48,19 @@ def bash(cmd):
out = p.stdout.read().strip()
return (rc, out)
+def snapshot_pool_state():
+ l = []
+ for d in os.listdir("/sys/kernel/mm/hugepages"):
+ substate = [(f, int(open("/sys/kernel/mm/hugepages/%s/%s" % (d, f)).read()))
+ for f in os.listdir("/sys/kernel/mm/hugepages/%s" % d)]
+ l.append((d, tuple(substate)))
+ return tuple(l)
+
def run_test_prog(bits, pagesize, cmd, **env):
+ if paranoid_pool_check:
+ beforepool = snapshot_pool_state()
+ print "Pool state: %s" % str(beforepool)
+
local_env = os.environ.copy()
local_env.update(env)
local_env["PATH"] = "./obj%d:../obj%d:%s" \
@@ -64,6 +76,15 @@ def run_test_prog(bits, pagesize, cmd, **env):
# Abort and mark this a strange test result
return (None, "")
out = p.stdout.read().strip()
+
+ if paranoid_pool_check:
+ afterpool = snapshot_pool_state()
+ if afterpool != beforepool:
+ print >>sys.stderr, "Hugepage pool state not preserved!"
+ print >>sys.stderr, "BEFORE: %s" % str(beforepool)
+ print >>sys.stderr, "AFTER: %s" % str(afterpool)
+ sys.exit(98)
+
return (rc, out)
def setup_env(override, defaults):
@@ -584,15 +605,16 @@ def stress_tests():
def main():
- global wordsizes, pagesizes, dangerous
+ global wordsizes, pagesizes, dangerous, paranoid_pool_check
testsets = set()
env_override = {"QUIET_TEST": "1", "HUGETLBFS_MOUNTS": "",
"HUGETLB_ELFMAP": None, "HUGETLB_MORECORE": None}
env_defaults = {"HUGETLB_VERBOSE": "0"}
dangerous = 0
+ paranoid_pool_check = False
try:
- opts, args = getopt.getopt(sys.argv[1:], "vVfdt:b:p:")
+ opts, args = getopt.getopt(sys.argv[1:], "vVfdt:b:p:c")
except getopt.GetoptError, err:
print str(err)
sys.exit(1)
@@ -610,6 +632,8 @@ def main():
for b in arg.split(): wordsizes.add(int(b))
elif opt == "-p":
for p in arg.split(): pagesizes.add(int(p))
+ elif opt == '-c':
+ paranoid_pool_check = True
else:
assert False, "unhandled option"
if len(testsets) == 0: testsets = set(["func", "stress"])