[CRIU] [RFC PATCHv2 03/32] zdtm: zdtm.py: add --list-failures option
Ivan Shapovalov
intelfx at intelfx.name
Sat Mar 12 00:42:02 PST 2016
--list-failures accepts a filename prefix and makes zdtm.py log each failed
test name to the file "<prefix>.<flavors>" (where <prefix> is passed as
argument value, and <flavors> is the list of failed flavors or "all").
If --keep-going is not passed, but --list-failures is, then only the first
failed flavor is logged (because testing is then aborted).
Signed-off-by: Ivan Shapovalov <intelfx at intelfx.name>
---
test/zdtm.py | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/test/zdtm.py b/test/zdtm.py
index c704acf..d84e1cc 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -948,6 +948,8 @@ def do_run_test(tname, tdesc, flavs, opts):
fcg = get_freezer(opts['freezecg'])
+ failed_flavs = []
+
for f in flavs:
print
print_sep("Run %s in %s" % (tname, f))
@@ -976,15 +978,34 @@ def do_run_test(tname, tdesc, flavs, opts):
add_to_report(cr_api.logs(), "cr_logs")
if opts['keep_img'] == 'never':
cr_api.cleanup()
- # This exit does two things -- exits from subprocess and
- # aborts the main script execution on the 1st error met
+ failed_flavs.append(f)
if not opts['keep_going']:
- sys.exit(1)
+ break
else:
if opts['keep_img'] != 'always':
cr_api.cleanup()
print_sep("Test %s PASS" % tname)
+ if failed_flavs:
+ if opts['list_failures']:
+ if cmp(failed_flavs, flavs):
+ list_failures_suffix = "all"
+ else:
+ list_failures_suffix = ",".join(failed_flavs)
+
+ try:
+ failures = open("%s.%s" % (opts['list_failures'], list_failures_suffix), "a")
+ fcntl.flock(failures, fcntl.LOCK_EX)
+ print >>failures, tname
+ failures.close()
+ except e:
+ print "Cannot write to failed tests log: %s" % str(e)
+
+ # This exit does two things -- exits from subprocess and
+ # aborts the main script execution on the 1st error met
+ if not opts['keep_going']:
+ sys.exit(1)
+
class launcher:
def __init__(self, opts, nr_tests):
self.__opts = opts
@@ -1022,7 +1043,7 @@ class launcher:
nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', \
'fault', 'keep_img', 'report', 'snaps', 'sat', \
'dedup', 'sbs', 'freezecg', 'user', 'dry_run', \
- 'keep_going')
+ 'keep_going', "list_failures")
arg = repr((name, desc, flavor, { d: self.__opts[d] for d in nd }))
if self.__use_log:
@@ -1402,6 +1423,7 @@ rp.add_argument("--freezecg", help = "Use freeze cgroup (path:state)")
rp.add_argument("--user", help = "Run CRIU as regular user", action = 'store_true')
rp.add_argument("--keep-going", help = "Keep running tests in spite of failures", action = 'store_true')
+rp.add_argument("--list-failures", help = "Log failed tests' names in plain text to file \"<argument>.<flavors>\"")
rp.add_argument("--page-server", help = "Use page server dump", action = 'store_true')
rp.add_argument("-p", "--parallel", help = "Run test in parallel")
--
2.7.2
More information about the CRIU
mailing list