[CRIU] [PATCH 4/4] join-ns: add join-ns zdtm test

Dengguangxing dengguangxing at huawei.com
Sun Apr 3 23:42:17 PDT 2016


join-ns zdtm test will skip ns and uns flavors, and
some socket related test, too. Because join-ns test will
try to join an existing network namespace.

Signed-off-by: Deng Guangxing <dengguangxing at huawei.com>
---
 test/zdtm.py | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/test/zdtm.py b/test/zdtm.py
index 27e938b..05a50e5 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -601,6 +601,7 @@ test_classes = { 'zdtm': zdtm_test, 'inhfd': inhfd_test, 'groups': groups_test }
 #

 criu_bin = "../criu/criu"
+join_ns_file = '/run/netns/zdtm_netns'
 class criu_cli:
 	def __init__(self, opts):
 		self.__test = None
@@ -609,6 +610,7 @@ class criu_cli:
 		self.__prev_dump_iter = None
 		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.__fault = (opts['fault'])
 		self.__sat = (opts['sat'] and True or False)
 		self.__dedup = (opts['dedup'] and True or False)
@@ -741,6 +743,9 @@ class criu_cli:
 			r_opts = ["--restore-sibling"]
 			self.__test.auto_reap = False
 		r_opts += self.__test.getropts()
+		if self.__join_ns:
+			r_opts.append("--join-ns")
+			r_opts.append("net:%s" % join_ns_file)

 		self.__prev_dump_iter = None
 		criu_dir = os.path.dirname(os.getcwd())
@@ -1057,7 +1062,7 @@ class launcher:
 		self.__nr += 1
 		self.__show_progress()

-		nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', \
+		nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', 'join_ns', \
 				'fault', 'keep_img', 'report', 'snaps', 'sat', \
 				'dedup', 'sbs', 'freezecg', 'user', 'dry_run')
 		arg = repr((name, desc, flavor, { d: self.__opts[d] for d in nd }))
@@ -1226,6 +1231,14 @@ def run_tests(opts):
 		print "Parallel launch with freezer not supported"
 		opts['parallel'] = None

+	if opts['join_ns']:
+		print "[WARNING] Option --join-ns will skip ns and uns flavors, and some socket related tests."
+		r = re.compile('^(?!.*sock).*$')
+		torun = filter(lambda x: r.match(x), torun)
+		opts['keep_going'] = True
+		run_all = True
+		subprocess.Popen(["ip", "netns", "add", "zdtm_netns"])
+
 	l = launcher(opts, len(torun))
 	try:
 		for t in torun:
@@ -1290,13 +1303,25 @@ def run_tests(opts):
 				except KeyError:
 					pass

+			#remove ns and uns flavor in join_ns
+			if opts['join_ns']:
+				try:
+					run_flavs.remove("ns")
+				except KeyError:
+					pass
+				try:
+					run_flavs.remove("uns")
+				except KeyError:
+					pass
+
 			if run_flavs:
 				l.run_test(t, tdesc, run_flavs)
 			else:
 				l.skip(t, "no flavors")
 	finally:
 		l.finish()
-
+		if opts['join_ns']:
+			subprocess.Popen(["ip", "netns", "delete", "zdtm_netns"])

 sti_fmt = "%-40s%-10s%s"

@@ -1476,6 +1501,7 @@ rp.add_argument("-f", "--flavor", help = "Flavor to run")
 rp.add_argument("-x", "--exclude", help = "Exclude tests from --all run", action = 'append')

 rp.add_argument("--sibling", help = "Restore tests as siblings", action = 'store_true')
+rp.add_argument("--join-ns", help = "Restore tests and join existing namespace", action = 'store_true')
 rp.add_argument("--pre", help = "Do some pre-dumps before dump (n[:pause])")
 rp.add_argument("--snaps", help = "Instead of pre-dumps do full dumps", action = 'store_true')
 rp.add_argument("--dedup", help = "Auto-deduplicate images on iterations", action = 'store_true')
-- 
2.5.0



More information about the CRIU mailing list