[CRIU] [PATCH 2/4] test: add a test for mounts with external master peers

Tycho Andersen tycho.andersen at canonical.com
Wed May 6 07:07:52 PDT 2015


Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 test/zdtm/live/static/Makefile            |  1 +
 test/zdtm/live/static/mnt_ext_master.c    | 78 +++++++++++++++++++++++++++++++
 test/zdtm/live/static/mnt_ext_master.opts |  1 +
 3 files changed, 80 insertions(+)
 create mode 100644 test/zdtm/live/static/mnt_ext_master.c
 create mode 100644 test/zdtm/live/static/mnt_ext_master.opts

diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index eb3567d..6e5ffb3 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -188,6 +188,7 @@ TST_DIR		=				\
 		mntns_shared_bind02		\
 		mntns_root_bind			\
 		mnt_ext_auto			\
+		mnt_ext_master			\
 
 TST_DIR_FILE	=				\
 		chroot				\
diff --git a/test/zdtm/live/static/mnt_ext_master.c b/test/zdtm/live/static/mnt_ext_master.c
new file mode 100644
index 0000000..98f7d35
--- /dev/null
+++ b/test/zdtm/live/static/mnt_ext_master.c
@@ -0,0 +1,78 @@
+#include <sys/mount.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <linux/limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc	= "Check that mounts with external master peers are c/r'd";
+const char *test_author	= "Tycho Andersen <tycho.andersen at canonical.com>"
+
+char *dirname = "mnt_ext_auto.test";
+TEST_OPTION(dirname, string, "directory name", 1);
+
+int main(int argc, char ** argv)
+{
+	char src[PATH_MAX], dst[PATH_MAX], *root;
+	char *dname = "/tmp/zdtm_ext_auto.XXXXXX";
+	int status;
+	pid_t pid;
+
+	root = getenv("ZDTM_ROOT");
+	if (root == NULL) {
+		err("root");
+		return 1;
+	}
+
+	sprintf(dst, "%s/ext_mounts", getenv("ZDTM_ROOT"));
+
+	if (strcmp(getenv("ZDTM_NEWNS"), "1"))
+		goto test;
+
+	pid = fork();
+	if (pid < 0)
+		return 1;
+	if (pid == 0) {
+		test_ext_init(argc, argv);
+
+		mkdir(dname, 755);
+		sprintf(src, "%s/test", dname);
+		if (mount("zdtm_auto_ext_mnt", dname, "tmpfs", 0, NULL)) {
+			err("mount");
+			return 1;
+		}
+
+		mkdir(src, 755);
+		mkdir(dst, 755);
+		if (mount(src, dst, NULL, MS_BIND, NULL)) {
+			err("bind");
+			return 1;
+		}
+
+		if (mount(src, dst, NULL, MS_SLAVE, NULL)) {
+			err("slave");
+			return 1;
+		}
+
+		return 0;
+	}
+
+	wait(&status);
+	if (status != 0)
+		return 1;
+
+test:
+	test_init(argc, argv);
+
+	test_daemon();
+	test_waitsig();
+
+
+	pass();
+
+	return 0;
+}
diff --git a/test/zdtm/live/static/mnt_ext_master.opts b/test/zdtm/live/static/mnt_ext_master.opts
new file mode 100644
index 0000000..bbcdf9f
--- /dev/null
+++ b/test/zdtm/live/static/mnt_ext_master.opts
@@ -0,0 +1 @@
+--ext-mount-map auto --enable-external-masters
-- 
2.1.4



More information about the CRIU mailing list