[CRIU] [PATCH v4 10/12] zdtm: extract cr and state checking logic into function

Eugene Batalov eabatalov89 at gmail.com
Sun Sep 11 10:14:49 PDT 2016


We're going to make this place more complicated so it's a good
time to simplify it using extract method refactoring.

Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
---
 test/zdtm.py | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/test/zdtm.py b/test/zdtm.py
index 1630b03..6490b4c 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -1294,6 +1294,17 @@ def pstree_signal(root_pid, signal):
 			pass  # process is dead
 
 
+def do_run_test_cr(cr_api, test, opts):
+	state = get_visible_state(test)
+	cr(cr_api, test, opts)
+	check_visible_state(test, state, opts)
+	if opts['join_ns']:
+		check_joinns_state(test)
+	if opts['unshare']:
+		check_unshare_state(test)
+	test.stop()
+
+
 def do_run_test(tname, tdesc, flavs, opts):
 	tcname = tname.split('/')[0]
 	tclass = test_classes.get(tcname, None)
@@ -1319,20 +1330,12 @@ def do_run_test(tname, tdesc, flavs, opts):
 
 		try:
 			t.start()
-			s = get_visible_state(t)
 			try:
-				cr(cr_api, t, opts)
+				do_run_test_cr(cr_api, t, opts)
+				try_run_hook(t, ["--clean"])
 			except test_fail_expected_exc as e:
 				if e.cr_action == "dump":
 					t.stop()
-			else:
-				check_visible_state(t, s, opts)
-				if opts['join_ns']:
-					check_joinns_state(t)
-				if opts['unshare']:
-					check_unshare_state(t)
-				t.stop()
-				try_run_hook(t, ["--clean"])
 		except test_fail_exc as e:
 			print_sep("Test %s FAIL at %s" % (tname, e.step), '#')
 			t.print_output()
-- 
1.9.1



More information about the CRIU mailing list