[CRIU] [PATCH 4/4] zdtm: Test unshare pid and mount namespaces

Pavel Emelyanov xemul at virtuozzo.com
Wed Apr 27 05:23:47 PDT 2016


This completes the --unshare feature (except for userns).

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 test/zdtm.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/test/zdtm.py b/test/zdtm.py
index b54669b..e11e688 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -612,6 +612,7 @@ class criu_cli:
 		self.__page_server = (opts['page_server'] and True or False)
 		self.__restore_sibling = (opts['sibling'] and True or False)
 		self.__join_ns = (opts['join_ns'] and True or False)
+		self.__unshare = (opts['unshare'] and True or False)
 		self.__fault = (opts['fault'])
 		self.__sat = (opts['sat'] and True or False)
 		self.__dedup = (opts['dedup'] and True or False)
@@ -747,6 +748,9 @@ class criu_cli:
 		if self.__join_ns:
 			r_opts.append("--join-ns")
 			r_opts.append("net:%s" % join_ns_file)
+		if self.__unshare:
+			r_opts.append("--unshare")
+			r_opts.append("pid,mnt,proc")
 
 		self.__prev_dump_iter = None
 		criu_dir = os.path.dirname(os.getcwd())
@@ -966,6 +970,10 @@ def cmp_ns(ns1, match, ns2, msg):
 def check_joinns_state(t):
 	cmp_ns("/proc/%s/ns/net" % t.getpid(), "!=", join_ns_file, "join-ns")
 
+def check_unshare_state(t):
+	cmp_ns("/proc/%s/ns/pid" % t.getpid(), '==', "/proc/self/ns/pid", "unshare pid")
+	cmp_ns("/proc/%s/ns/mnt" % t.getpid(), '==', "/proc/self/ns/mnt", "unshare mnt")
+	cmp_ns("/proc/%s/ns/net" % t.getpid(), '!=', "/proc/self/ns/net", "unshare net")
 
 def do_run_test(tname, tdesc, flavs, opts):
 	tcname = tname.split('/')[0]
@@ -1002,6 +1010,8 @@ def do_run_test(tname, tdesc, flavs, opts):
 				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:
@@ -1077,7 +1087,7 @@ class launcher:
 		self.__show_progress()
 
 		nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', 'join_ns', \
-				'fault', 'keep_img', 'report', 'snaps', 'sat', \
+				'fault', 'keep_img', 'report', 'snaps', 'sat', 'unshare', \
 				'dedup', 'sbs', 'freezecg', 'user', 'dry_run')
 		arg = repr((name, desc, flavor, { d: self.__opts[d] for d in nd }))
 
@@ -1313,6 +1323,8 @@ def run_tests(opts):
 			#remove ns and uns flavor in join_ns
 			if opts['join_ns']:
 				run_flavs -= set(['ns', 'uns'])
+			if opts['unshare']:
+				run_flavs -= set(['ns', 'uns'])
 
 			if run_flavs:
 				l.run_test(t, tdesc, run_flavs)
@@ -1511,6 +1523,7 @@ rp.add_argument("--iters", help = "Do CR cycle several times before check (n[:pa
 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("--unshare", help = "Restore tests into unshared context", action = 'store_true')
 rp.add_argument("--freezecg", help = "Use freeze cgroup (path:state)")
 rp.add_argument("--user", help = "Run CRIU as regular user", action = 'store_true')
 
-- 
2.5.0



More information about the CRIU mailing list