From 2d1083303dfeb4f7d2696408056f841f14cf4188 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 9 Dec 2015 19:05:57 +0300 Subject: [PATCH] zdtm.py: Add step-by-step execution When debugging it's useful to stop zdtm.py at certain points and check what's going on out there. For this the --sbs (step-by-step) option is introduced. It will make zdtm.py stop and wait for user keypress before dump, before restore and after restore. Signed-off-by: Pavel Emelyanov Acked-by: Andrew Vagin --- test/zdtm.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/test/zdtm.py b/test/zdtm.py index 4dc381858..c3e44be47 100755 --- a/test/zdtm.py +++ b/test/zdtm.py @@ -663,6 +663,23 @@ def try_run_hook(test, args): if hook.wait() != 0: raise test_fail_exc("hook " + " ".join(args)) +# +# Step by step execution +# + +do_sbs = False + +def init_sbs(): + if sys.stdout.isatty(): + global do_sbs + do_sbs = True + else: + print "Can't do step-by-step in this runtime" + +def sbs(what): + if do_sbs: + raw_input("Pause at %s. Press any key to continue." % what) + # # Main testing entity -- dump (probably with pre-dumps) and restore # @@ -687,13 +704,17 @@ def cr(cr_api, test, opts): cr_api.dump("pre-dump") time.sleep(pres[1]) + sbs('pre-dump') + if opts['norst']: cr_api.dump("dump", opts = ["--leave-running"]) else: cr_api.dump("dump") test.gone() + sbs('pre-restore') try_run_hook(test, ["--pre-restore"]) cr_api.restore() + sbs('post-restore') time.sleep(iters[1]) @@ -751,6 +772,8 @@ def do_run_test(tname, tdesc, flavs, opts): if opts['report']: init_report(opts['report']) + if opts['sbs']: + init_sbs() for f in flavs: print @@ -816,7 +839,7 @@ class launcher: self.__show_progress() nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', \ - 'fault', 'keep_img', 'report', 'snaps', 'sat', 'dedup') + 'fault', 'keep_img', 'report', 'snaps', 'sat', 'dedup', 'sbs') arg = repr((name, desc, flavor, { d: self.__opts[d] for d in nd })) if self.__max > 1 and self.__total > 1: @@ -1160,6 +1183,7 @@ rp.add_argument("--norst", help = "Don't restore tasks, leave them running after rp.add_argument("--iters", help = "Do CR cycle several times before check (n[:pause])") rp.add_argument("--fault", help = "Test fault injection") rp.add_argument("--sat", help = "Generate criu strace-s for sat tool (restore is fake, images are kept)", action = 'store_true') +rp.add_argument("--sbs", help = "Do step-by-step execution, asking user for keypress to continue", action = 'store_true') rp.add_argument("--page-server", help = "Use page server dump", action = 'store_true') rp.add_argument("-p", "--parallel", help = "Run test in parallel")