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

Submitted by Eugene Batalov on Sept. 11, 2016, 5:14 p.m.

Details

Message ID 1473614091-4734-11-git-send-email-eabatalov89@gmail.com
State Rejected
Series "Series without cover letter"
Headers show

Commit Message

Eugene Batalov Sept. 11, 2016, 5:14 p.m.
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@gmail.com>
---
 test/zdtm.py | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

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()