[RFC,v2,5/5] zdtm: also dump and restore tests with --check-only

Submitted by Adrian Reber on March 23, 2017, 7:59 p.m.

Details

Message ID 1490299158-12933-6-git-send-email-adrian@lisas.de
State Rejected
Series "zdtm: also dump and restore tests with --check-only"
Headers show

Commit Message

Adrian Reber March 23, 2017, 7:59 p.m.
From: Adrian Reber <areber@redhat.com>

This adds the option '--check-only' to zdtm.py. If specified each test
cases is first dumped with the '--check-only' option enabled before the
real dump. Also during restore the test case is first restored with
--check-only before doing the real restore.

Signed-off-by: Adrian Reber <areber@redhat.com>
---
 test/zdtm.py | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm.py b/test/zdtm.py
index 7177347..ccf95d3 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -797,6 +797,7 @@  class criu:
 		self.__leave_stopped = (opts['stop'] and True or False)
 		self.__remote = (opts['remote'] and True or False)
 		self.__criu = (opts['rpc'] and criu_rpc or criu_cli)
+		self.__check_only = (opts['check_only'] and True or False)
 		self.__lazy_pages_p = None
 		self.__page_server_p = None
 
@@ -841,7 +842,10 @@  class criu:
 
 		with open(os.path.join(self.__ddir(), action + '.cropt'), 'w') as f:
 			f.write(' '.join(s_args) + '\n')
-		print "Run criu " + action
+		if '--check-only' in opts:
+			print "Run criu " + action + " in check-only mode"
+		else:
+			print "Run criu " + action
 
 		strace = []
 		if self.__sat:
@@ -877,6 +881,13 @@  class criu:
 			os.close(status_fds[0])
 			return ret
 
+		if '--check-only' in opts and action == "restore":
+			# Although the restored process never starts
+			# running in check-only mode, it sometimes takes
+			# some time for the process to disappear.
+			# Wait until it is gone.
+			self.__test.gone()
+
 		grep_errors(os.path.join(__ddir, log))
 		if ret != 0:
 			if self.__fault and int(self.__fault) < 128:
@@ -958,6 +969,9 @@  class criu:
 		if self.__empty_ns:
 			a_opts += ['--empty-ns', 'net']
 
+		if self.__check_only:
+			self.__criu_act(action, opts = a_opts + opts + ['--check-only'])
+
 		self.__criu_act(action, opts = a_opts + opts)
 		if self.__mdedup and self.__iter > 1:
 			self.__criu_act("dedup", opts = [])
@@ -1007,6 +1021,11 @@  class criu:
 		if self.__leave_stopped:
 			r_opts += ['--leave-stopped']
 
+		if self.__check_only:
+			self.__criu_act("restore", opts = r_opts + ["--restore-detached"] + ['--check-only'])
+			# sometimes the real restore fails with PID conflicts without this
+			reset_pid()
+
 		self.__criu_act("restore", opts = r_opts + ["--restore-detached"])
 
 		if self.__lazy_pages_p:
@@ -1463,7 +1482,7 @@  class launcher:
 		nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', 'stop', 'empty_ns',
 				'fault', 'keep_img', 'report', 'snaps', 'sat', 'script', 'rpc', 'lazy_pages',
 				'join_ns', 'dedup', 'sbs', 'freezecg', 'user', 'dry_run', 'noauto_dedup',
-				'remote_lazy_pages', 'remote')
+				'remote_lazy_pages', 'remote', 'check_only')
 		arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
 
 		if self.__use_log:
@@ -1956,6 +1975,7 @@  rp.add_argument("--report", help = "Generate summary report in directory")
 rp.add_argument("--keep-going", help = "Keep running tests in spite of failures", action = 'store_true')
 rp.add_argument("--lazy-pages", help = "restore pages on demand", action = 'store_true')
 rp.add_argument("--remote-lazy-pages", help = "simulate lazy migration", action = 'store_true')
+rp.add_argument("--check-only", help = "Additionally try to dump/restore in --check-only mode", action = 'store_true')
 
 lp = sp.add_parser("list", help = "List tests")
 lp.set_defaults(action = list_tests)