2020-04-28 09:40:39 +00:00
|
|
|
From 85b75e22bf685948f417044676de42f2da66a902 Mon Sep 17 00:00:00 2001
|
|
|
|
Message-Id: <85b75e22bf685948f417044676de42f2da66a902.1566225007.git.aquini@redhat.com>
|
|
|
|
In-Reply-To: <d42f467a923dfc09309acb7a83b42e3285fbd8f4.1566225007.git.aquini@redhat.com>
|
|
|
|
References: <d42f467a923dfc09309acb7a83b42e3285fbd8f4.1566225007.git.aquini@redhat.com>
|
|
|
|
From: David Gibson <david@gibson.dropbear.id.au>
|
|
|
|
Date: Sat, 17 Aug 2019 20:59:44 +1000
|
|
|
|
Subject: [RHEL7 PATCH 20/31] Switch test runner script to print function
|
|
|
|
|
|
|
|
This is the more modern Python style, and reduces difference to Python3.
|
|
|
|
|
|
|
|
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
|
|
|
|
Signed-off-by: Eric B Munson <eric@munsonfam.org>
|
|
|
|
Signed-off-by: Rafael Aquini <aquini@redhat.com>
|
|
|
|
---
|
|
|
|
tests/run_tests.py | 84 ++++++++++++++++++++++++++++--------------------------
|
|
|
|
1 file changed, 44 insertions(+), 40 deletions(-)
|
|
|
|
|
2019-05-07 10:58:41 +00:00
|
|
|
diff --git a/tests/run_tests.py b/tests/run_tests.py
|
2020-04-28 09:40:39 +00:00
|
|
|
index 721c1af..47eb183 100755
|
2019-05-07 10:58:41 +00:00
|
|
|
--- a/tests/run_tests.py
|
|
|
|
+++ b/tests/run_tests.py
|
2020-04-28 09:40:39 +00:00
|
|
|
@@ -1,5 +1,7 @@
|
|
|
|
#! /usr/bin/python2
|
2019-05-07 10:58:41 +00:00
|
|
|
|
2020-04-28 09:40:39 +00:00
|
|
|
+from __future__ import print_function
|
|
|
|
+
|
2019-05-07 10:58:41 +00:00
|
|
|
import subprocess
|
|
|
|
import types
|
2020-04-28 09:40:39 +00:00
|
|
|
import os
|
|
|
|
@@ -60,7 +62,7 @@ def snapshot_pool_state():
|
2019-05-07 10:58:41 +00:00
|
|
|
def run_test_prog(bits, pagesize, cmd, **env):
|
|
|
|
if paranoid_pool_check:
|
|
|
|
beforepool = snapshot_pool_state()
|
|
|
|
- print "Pool state: %s" % str(beforepool)
|
|
|
|
+ print("Pool state: %s" % str(beforepool))
|
|
|
|
|
|
|
|
local_env = os.environ.copy()
|
|
|
|
local_env.update(env)
|
2020-04-28 09:40:39 +00:00
|
|
|
@@ -83,9 +85,9 @@ def run_test_prog(bits, pagesize, cmd, **env):
|
2019-05-07 10:58:41 +00:00
|
|
|
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)
|
|
|
|
+ print("Hugepage pool state not preserved!", file=sys.stderr)
|
|
|
|
+ print("BEFORE: %s" % str(beforepool), file=sys.stderr)
|
|
|
|
+ print("AFTER: %s" % str(afterpool), file=sys.stderr)
|
|
|
|
sys.exit(98)
|
|
|
|
|
2020-04-28 09:40:39 +00:00
|
|
|
return (rc, out)
|
|
|
|
@@ -143,22 +145,24 @@ def print_per_size(title, values):
|
2019-05-07 10:58:41 +00:00
|
|
|
Print the results of a given result type on one line. The results for all
|
|
|
|
page sizes and word sizes are written in a table format.
|
|
|
|
"""
|
|
|
|
- print "*%20s: " % title,
|
2020-04-28 09:40:39 +00:00
|
|
|
+ print("*%20s: " % title, end=" ")
|
2019-05-07 10:58:41 +00:00
|
|
|
for sz in pagesizes:
|
|
|
|
- print "%4s %4s " % (values[sz][32], values[sz][64]),
|
|
|
|
- print
|
2020-04-28 09:40:39 +00:00
|
|
|
+ print("%4s %4s " % (values[sz][32], values[sz][64]), end="")
|
2019-05-07 10:58:41 +00:00
|
|
|
+ print()
|
|
|
|
|
|
|
|
def results_summary():
|
|
|
|
"""
|
|
|
|
Display a summary of the test results
|
|
|
|
"""
|
|
|
|
- print "********** TEST SUMMARY"
|
|
|
|
- print "*%21s" % "",
|
|
|
|
- for p in pagesizes: print "%-13s " % pretty_page_size(p),
|
|
|
|
- print
|
|
|
|
- print "*%21s" % "",
|
|
|
|
- for p in pagesizes: print "32-bit 64-bit ",
|
|
|
|
- print
|
|
|
|
+ print("********** TEST SUMMARY")
|
2020-04-28 09:40:39 +00:00
|
|
|
+ print("*%21s" % "", end=" ")
|
|
|
|
+ for p in pagesizes:
|
|
|
|
+ print("%-13s " % pretty_page_size(p), end="")
|
2019-05-07 10:58:41 +00:00
|
|
|
+ print()
|
2020-04-28 09:40:39 +00:00
|
|
|
+ print("*%21s" % "", end=" ")
|
|
|
|
+ for p in pagesizes:
|
|
|
|
+ print("32-bit 64-bit ", end="")
|
2019-05-07 10:58:41 +00:00
|
|
|
+ print()
|
|
|
|
|
|
|
|
print_per_size("Total testcases", R["total"])
|
|
|
|
print_per_size("Skipped", R["skip"])
|
2020-04-28 09:40:39 +00:00
|
|
|
@@ -170,7 +174,7 @@ def results_summary():
|
2019-05-07 10:58:41 +00:00
|
|
|
print_per_size("Unexpected PASS", R["xpass"])
|
|
|
|
print_per_size("Test not present", R["nofile"])
|
|
|
|
print_per_size("Strange test result", R["strange"])
|
|
|
|
- print "**********"
|
|
|
|
+ print("**********")
|
|
|
|
|
2020-04-28 09:40:39 +00:00
|
|
|
def free_hpages(size=None):
|
2019-05-07 10:58:41 +00:00
|
|
|
"""
|
2020-04-28 09:40:39 +00:00
|
|
|
@@ -276,13 +280,13 @@ def check_hugetlbfs_path():
|
2019-05-07 10:58:41 +00:00
|
|
|
okbits.append(b)
|
|
|
|
mounts.append(out)
|
|
|
|
if len(okbits) == 0:
|
|
|
|
- print "run_tests.py: No mountpoints available for page size %s" % \
|
|
|
|
- pretty_page_size(p)
|
2020-04-28 09:40:39 +00:00
|
|
|
+ print("run_tests.py: No mountpoints available for page size %s" %
|
2019-05-07 10:58:41 +00:00
|
|
|
+ pretty_page_size(p))
|
|
|
|
wordsizes_by_pagesize[p] = set()
|
|
|
|
continue
|
|
|
|
for b in wordsizes - set(okbits):
|
|
|
|
- print "run_tests.py: The %i bit word size is not compatible with " \
|
|
|
|
- "%s pages" % (b, pretty_page_size(p))
|
|
|
|
+ print("run_tests.py: The %i bit word size is not compatible with " \
|
|
|
|
+ "%s pages" % (b, pretty_page_size(p)))
|
|
|
|
wordsizes_by_pagesize[p] = set(okbits)
|
|
|
|
|
|
|
|
def check_linkhuge_tests():
|
2020-04-28 09:40:39 +00:00
|
|
|
@@ -304,10 +308,10 @@ def check_linkhuge_tests():
|
2019-05-07 10:58:41 +00:00
|
|
|
|
|
|
|
def print_cmd(pagesize, bits, cmd, env):
|
|
|
|
if env:
|
|
|
|
- print ' '.join(['%s=%s' % (k, v) for k, v in env.items()]),
|
2020-04-28 09:40:39 +00:00
|
|
|
+ print(' '.join(['%s=%s' % (k, v) for k, v in env.items()]), end=" ")
|
|
|
|
if type(cmd) != types.StringType:
|
|
|
|
cmd = ' '.join(cmd)
|
2019-05-07 10:58:41 +00:00
|
|
|
- print "%s (%s: %i):\t" % (cmd, pretty_page_size(pagesize), bits),
|
2020-04-28 09:40:39 +00:00
|
|
|
+ print("%s (%s: %i):\t" % (cmd, pretty_page_size(pagesize), bits), end="")
|
2019-05-07 10:58:41 +00:00
|
|
|
sys.stdout.flush()
|
|
|
|
|
|
|
|
def run_test(pagesize, bits, cmd, **env):
|
2020-04-28 09:40:39 +00:00
|
|
|
@@ -327,7 +331,7 @@ def run_test(pagesize, bits, cmd, **env):
|
2019-05-07 10:58:41 +00:00
|
|
|
|
|
|
|
print_cmd(pagesize, bits, cmd, env)
|
|
|
|
(rc, out) = run_test_prog(bits, pagesize, cmd, **env)
|
|
|
|
- print out
|
|
|
|
+ print(out)
|
|
|
|
|
|
|
|
R["total"][pagesize][bits] += 1
|
|
|
|
if rc == 0: R["pass"][pagesize][bits] += 1
|
2020-04-28 09:40:39 +00:00
|
|
|
@@ -348,7 +352,7 @@ def skip_test(pagesize, bits, cmd, **env):
|
2019-05-07 10:58:41 +00:00
|
|
|
R["total"][pagesize][bits] += 1
|
|
|
|
R["skip"][pagesize][bits] += 1
|
|
|
|
print_cmd(pagesize, bits, cmd, env)
|
|
|
|
- print "SKIPPED"
|
|
|
|
+ print("SKIPPED")
|
|
|
|
|
|
|
|
def do_test(cmd, bits=None, **env):
|
|
|
|
"""
|
2020-04-28 09:40:39 +00:00
|
|
|
@@ -495,7 +499,7 @@ def setup_shm_sysctl(limit):
|
2019-05-07 10:58:41 +00:00
|
|
|
fh = open(f, "w")
|
2020-04-28 09:40:39 +00:00
|
|
|
fh.write(`limit`)
|
2019-05-07 10:58:41 +00:00
|
|
|
fh.close()
|
|
|
|
- print "set shmmax limit to %s" % limit
|
|
|
|
+ print("set shmmax limit to %s" % limit)
|
|
|
|
return sysctls
|
|
|
|
|
|
|
|
def restore_shm_sysctl(sysctls):
|
2020-04-28 09:40:39 +00:00
|
|
|
@@ -725,17 +729,17 @@ def stress_tests():
|
2019-05-07 10:58:41 +00:00
|
|
|
do_test("fallocate_stress.sh")
|
|
|
|
|
|
|
|
def print_help():
|
|
|
|
- print "Usage: %s [options]" % sys.argv[0]
|
|
|
|
- print "Options:"
|
|
|
|
- print " -v \t Verbose output."
|
|
|
|
- print " -V \t Highly verbose output."
|
|
|
|
- print " -f \t Force all tests."
|
|
|
|
- print " -t <set> Run test set, allowed are func and stress."
|
|
|
|
- print " -b <wordsize> Define wordsizes to be used. "
|
|
|
|
- print " -p <pagesize> Define the page sizes to be used."
|
|
|
|
- print " -c \t Do a paranoid pool check."
|
|
|
|
- print " -l \t Use custom ld scripts."
|
|
|
|
- print " -h \t This help."
|
|
|
|
+ print("Usage: %s [options]" % sys.argv[0])
|
|
|
|
+ print("Options:")
|
|
|
|
+ print(" -v \t Verbose output.")
|
|
|
|
+ print(" -V \t Highly verbose output.")
|
|
|
|
+ print(" -f \t Force all tests.")
|
|
|
|
+ print(" -t <set> Run test set, allowed are func and stress.")
|
|
|
|
+ print(" -b <wordsize> Define wordsizes to be used. ")
|
|
|
|
+ print(" -p <pagesize> Define the page sizes to be used.")
|
|
|
|
+ print(" -c \t Do a paranoid pool check.")
|
|
|
|
+ print(" -l \t Use custom ld scripts.")
|
|
|
|
+ print(" -h \t This help.")
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
def main():
|
2020-04-28 09:40:39 +00:00
|
|
|
@@ -752,7 +756,7 @@ def main():
|
2019-05-07 10:58:41 +00:00
|
|
|
try:
|
|
|
|
opts, args = getopt.getopt(sys.argv[1:], "vVft:b:p:c:lh")
|
2020-04-28 09:40:39 +00:00
|
|
|
except getopt.GetoptError, err:
|
2019-05-07 10:58:41 +00:00
|
|
|
- print str(err)
|
|
|
|
+ print(str(err))
|
|
|
|
sys.exit(1)
|
|
|
|
for opt, arg in opts:
|
|
|
|
if opt == "-v":
|
2020-04-28 09:40:39 +00:00
|
|
|
@@ -781,8 +785,8 @@ def main():
|
2019-05-07 10:58:41 +00:00
|
|
|
if len(pagesizes) == 0: pagesizes = get_pagesizes()
|
|
|
|
|
|
|
|
if len(pagesizes) == 0:
|
|
|
|
- print "Unable to find available page sizes, are you sure hugetlbfs"
|
|
|
|
- print "is mounted and there are available huge pages?"
|
|
|
|
+ print("Unable to find available page sizes, are you sure hugetlbfs")
|
|
|
|
+ print("is mounted and there are available huge pages?")
|
|
|
|
return 1
|
|
|
|
|
|
|
|
setup_env(env_override, env_defaults)
|
2020-04-28 09:40:39 +00:00
|
|
|
@@ -790,8 +794,8 @@ def main():
|
2019-05-07 10:58:41 +00:00
|
|
|
|
|
|
|
(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?"
|
|
|
|
+ print("Unable to find system default hugepage size.")
|
|
|
|
+ print("Is hugepage supported included in this kernel?")
|
|
|
|
return 1
|
|
|
|
|
|
|
|
check_hugetlbfs_path()
|
2020-04-28 09:40:39 +00:00
|
|
|
--
|
|
|
|
1.8.3.1
|
|
|
|
|