[CRIU] [PATCH 2/2] zdtm: allow to execute ipc_namespace and utsname tests in userns

Andrey Vagin avagin at openvz.org
Fri Oct 23 07:51:58 PDT 2015


From: Andrew Vagin <avagin at openvz.org>

Signed-off-by: Andrew Vagin <avagin at openvz.org>
---
 test/zdtm.sh                             | 10 +++++++---
 test/zdtm/live/static/ipc_namespace.c    | 10 +++-------
 test/zdtm/live/static/ipc_namespace.desc |  2 +-
 test/zdtm/live/static/sem.c              | 15 +++------------
 test/zdtm/live/static/sem.desc           |  2 +-
 test/zdtm/live/static/utsname.c          | 10 +++-------
 test/zdtm/live/static/utsname.desc       |  2 +-
 7 files changed, 19 insertions(+), 32 deletions(-)

diff --git a/test/zdtm.sh b/test/zdtm.sh
index 46fbbc6..eced1a9 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -196,11 +196,11 @@ generate_test_list()
 		ns/static/mnt_ro_bind
 		ns/static/mount_paths
 		ns/static/bind-mount
-		static/utsname
-		static/ipc_namespace
+		ns/static/utsname
+		ns/static/ipc_namespace
 		static/shm
 		static/msgque
-		static/sem
+		ns/static/sem
 		transition/ipc
 		static/netns-nf
 		static/netns
@@ -295,6 +295,8 @@ generate_test_list()
 		ns/static/rtc
 		ns/static/cow01
 		ns/static/tempfs_ro
+		ns/static/ipc_namespace
+		ns/static/utsname
 	"
 
 	# Add tests which can be executed in an user namespace
@@ -363,6 +365,8 @@ apparmor
 seccomp_strict
 different_creds
 inotify01
+ipc_namespace
+utsname
 "
 
 TEST_EXPECTED_FAILURE="
diff --git a/test/zdtm/live/static/ipc_namespace.c b/test/zdtm/live/static/ipc_namespace.c
index 6237309..99c25a7 100644
--- a/test/zdtm/live/static/ipc_namespace.c
+++ b/test/zdtm/live/static/ipc_namespace.c
@@ -327,10 +327,12 @@ static void show_ipc_entry(struct ipc_ns *old, struct ipc_ns *new)
 			old->mq_msgsize_max, new->mq_msgsize_max);
 }
 
-static int test_fn(int argc, char **argv)
+int main(int argc, char **argv)
 {
 	int ret;
 
+	test_init(argc, argv);
+
 	ret = rand_ipc_ns();
 	if (ret) {
 		pr_perror("Failed to randomize ipc ns before migration");
@@ -361,9 +363,3 @@ static int test_fn(int argc, char **argv)
 	pass();
 	return 0;
 }
-
-int main(int argc, char **argv)
-{
-	test_init_ns(argc, argv, CLONE_NEWIPC, test_fn);
-	return -1;
-}
diff --git a/test/zdtm/live/static/ipc_namespace.desc b/test/zdtm/live/static/ipc_namespace.desc
index 63df42a..6c4afe5 100644
--- a/test/zdtm/live/static/ipc_namespace.desc
+++ b/test/zdtm/live/static/ipc_namespace.desc
@@ -1 +1 @@
-{'flavor': 'h'}
+{'flavor': 'ns uns'}
diff --git a/test/zdtm/live/static/sem.c b/test/zdtm/live/static/sem.c
index 3bbbfdd..2d5dac3 100644
--- a/test/zdtm/live/static/sem.c
+++ b/test/zdtm/live/static/sem.c
@@ -105,11 +105,13 @@ static int check_sem_by_id(int id, int val)
 			sizeof(unlock)/sizeof(struct sembuf));
 }
 
-static int test_fn(int argc, char **argv)
+int main(int argc, char **argv)
 {
 	int id, key, val;
 	int ret, fail_count = 0;
 
+	test_init(argc, argv);
+
 	key = ftok(argv[0], 89063453);
 	if (key == -1) {
 		pr_perror("Can't make key");
@@ -168,14 +170,3 @@ out:
 		pass();
 	return fail_count;
 }
-
-int main(int argc, char **argv)
-{
-#ifdef NEW_IPC_NS
-	test_init_ns(argc, argv, CLONE_NEWIPC, test_fn);
-#else
-	test_init(argc, argv);
-	test_fn(argc, argv);
-#endif
-	return 0;
-}
diff --git a/test/zdtm/live/static/sem.desc b/test/zdtm/live/static/sem.desc
index 63df42a..6c4afe5 100644
--- a/test/zdtm/live/static/sem.desc
+++ b/test/zdtm/live/static/sem.desc
@@ -1 +1 @@
-{'flavor': 'h'}
+{'flavor': 'ns uns'}
diff --git a/test/zdtm/live/static/utsname.c b/test/zdtm/live/static/utsname.c
index eb4518f..5fedb02 100644
--- a/test/zdtm/live/static/utsname.c
+++ b/test/zdtm/live/static/utsname.c
@@ -13,11 +13,13 @@ static struct utsname after;
 #define ZDTM_NODE "zdtm.nodename.ru"
 #define ZDTM_DOMAIN "zdtm.nodename.ru"
 
-static int test_fn(int argc, char **argv)
+int main(int argc, char **argv)
 {
 	int ret;
 	int fd;
 
+	test_init(argc, argv);
+
 	fd = open("/proc/sys/kernel/hostname", O_WRONLY);
 	if (fd < 0) {
 		pr_perror("Can't open hostname");
@@ -63,9 +65,3 @@ static int test_fn(int argc, char **argv)
 	pass();
 	return 0;
 }
-
-int main(int argc, char **argv)
-{
-	test_init_ns(argc, argv, CLONE_NEWUTS, test_fn);
-	return 0;
-}
diff --git a/test/zdtm/live/static/utsname.desc b/test/zdtm/live/static/utsname.desc
index 63df42a..6c4afe5 100644
--- a/test/zdtm/live/static/utsname.desc
+++ b/test/zdtm/live/static/utsname.desc
@@ -1 +1 @@
-{'flavor': 'h'}
+{'flavor': 'ns uns'}
-- 
2.4.3



More information about the CRIU mailing list