[CRIU] [PATCH v2 1/2] zdtm: Add mntns_root_bind02 test

Kirill Tkhai ktkhai at virtuozzo.com
Fri Feb 12 06:26:25 PST 2016


It's an extension of mntns_root_bind, which is differ by one more bind mount.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 test/zdtm.sh                                 |    2 ++
 test/zdtm/.gitignore                         |    1 +
 test/zdtm/live/static/Makefile               |    2 ++
 test/zdtm/live/static/mntns_root_bind.c      |   25 ++++++++++++++++++++-----
 test/zdtm/live/static/mntns_root_bind02.c    |    1 +
 test/zdtm/live/static/mntns_root_bind02.desc |    1 +
 6 files changed, 27 insertions(+), 5 deletions(-)
 create mode 120000 test/zdtm/live/static/mntns_root_bind02.c
 create mode 120000 test/zdtm/live/static/mntns_root_bind02.desc

diff --git a/test/zdtm.sh b/test/zdtm.sh
index 4a57cd3..8b8faf5 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -229,6 +229,7 @@ generate_test_list()
 		ns/static/mntns_shared_bind
 		ns/static/mntns_shared_bind02
 		ns/static/mntns_root_bind
+		ns/static/mntns_root_bind02
 		ns/static/mntns_deleted
 		ns/static/inotify01
 		ns/static/mntns_rw_ro_rw
@@ -368,6 +369,7 @@ mntns_link_ghost
 mntns_shared_bind
 mntns_shared_bind02
 mntns_root_bind
+mntns_root_bind02
 mntns_rw_ro_rw
 mntns_deleted
 mount_paths
diff --git a/test/zdtm/.gitignore b/test/zdtm/.gitignore
index 3e6c7e2..7722ae7 100644
--- a/test/zdtm/.gitignore
+++ b/test/zdtm/.gitignore
@@ -206,6 +206,7 @@
 /live/static/file_locks05
 /live/static/mlock_setuid
 /live/static/mntns_root_bind
+/live/static/mntns_root_bind02
 /live/static/mntns-deleted-dst
 /live/static/socket-tcp-local
 /live/static/socket-tcp6-local
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index d3ff2c0..fa280a1 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -222,6 +222,7 @@ TST_DIR		=				\
 		mntns_shared_bind		\
 		mntns_shared_bind02		\
 		mntns_root_bind			\
+		mntns_root_bind02		\
 		mnt_ext_auto			\
 		mnt_ext_master			\
 		mntns_deleted			\
@@ -366,6 +367,7 @@ sigpending:		override LDLIBS += -lrt
 vdso01:			override LDLIBS += -lrt
 mntns_link_remap:	override CFLAGS += -DZDTM_LINK_REMAP
 mntns_shared_bind02:		override CFLAGS += -DSHARED_BIND02
+mntns_root_bind02:	override CFLAGS += -DROOT_BIND02
 maps02:		get_smaps_bits.o
 mlock_setuid:		get_smaps_bits.o
 inotify01:		override CFLAGS += -DINOTIFY01
diff --git a/test/zdtm/live/static/mntns_root_bind.c b/test/zdtm/live/static/mntns_root_bind.c
index 72d8800..3bd0bec 100644
--- a/test/zdtm/live/static/mntns_root_bind.c
+++ b/test/zdtm/live/static/mntns_root_bind.c
@@ -27,7 +27,8 @@ TEST_OPTION(dirname, string, "directory name", 1);
 
 int main(int argc, char **argv)
 {
-	char path[PATH_MAX], bpath[PATH_MAX], spath[PATH_MAX], bspath[PATH_MAX];
+	char subdir1[PATH_MAX], path[PATH_MAX], bpath[PATH_MAX], spath[PATH_MAX], bspath[PATH_MAX];
+	char subdir2[PATH_MAX], bsubdir2[PATH_MAX];
 	pid_t pid;
 	int status;
 	task_waiter_t t;
@@ -38,12 +39,19 @@ int main(int argc, char **argv)
 
 	mount(NULL, "/", NULL, MS_SHARED, NULL);
 
-	snprintf(path, sizeof(path), "%s/test", dirname);
-	snprintf(bpath, sizeof(bpath), "%s/test.bind", dirname);
-	snprintf(spath, sizeof(spath), "%s/test/sub", dirname);
-	snprintf(bspath, sizeof(bspath), "%s/test.bind/sub", dirname);
+	snprintf(subdir1, sizeof(subdir1), "%s/subdir1", dirname);
+	snprintf(path, sizeof(path), "%s/test", subdir1);
+	snprintf(bpath, sizeof(bpath), "%s/test.bind", subdir1);
+	snprintf(spath, sizeof(spath), "%s/test/sub", subdir1);
+	snprintf(bspath, sizeof(bspath), "%s/test.bind/sub", subdir1);
+
+	snprintf(subdir2, sizeof(subdir2), "%s/subdir2", dirname);
+	snprintf(bsubdir2, sizeof(bsubdir2), "%s/bsubdir2", dirname);
 
 	if (mkdir(dirname, 0700) ||
+	    mkdir(subdir1, 0777) ||
+	    mkdir(subdir2, 0777) ||
+	    mkdir(bsubdir2, 0777) ||
 	    mkdir(path, 0700) ||
 	    mkdir(spath, 0700) ||
 	    mkdir(bpath, 0700)) {
@@ -87,6 +95,13 @@ int main(int argc, char **argv)
 		return 1;
 	}
 
+#ifdef ROOT_BIND02
+	if (mount(subdir2, bsubdir2, NULL, MS_BIND, NULL)) {
+		pr_perror("Unable to mount %s to %s", subdir2, bsubdir2);
+		return 1;
+	}
+#endif
+
 	test_daemon();
 	test_waitsig();
 
diff --git a/test/zdtm/live/static/mntns_root_bind02.c b/test/zdtm/live/static/mntns_root_bind02.c
new file mode 120000
index 0000000..4957c1f
--- /dev/null
+++ b/test/zdtm/live/static/mntns_root_bind02.c
@@ -0,0 +1 @@
+mntns_root_bind.c
\ No newline at end of file
diff --git a/test/zdtm/live/static/mntns_root_bind02.desc b/test/zdtm/live/static/mntns_root_bind02.desc
new file mode 120000
index 0000000..cd4ed51
--- /dev/null
+++ b/test/zdtm/live/static/mntns_root_bind02.desc
@@ -0,0 +1 @@
+mntns_root_bind.desc
\ No newline at end of file



More information about the CRIU mailing list