[CRIU] [PATCH 3/4] zdtm: check mounts of external devices

Andrey Vagin avagin at openvz.org
Thu Apr 14 15:19:55 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 test/zdtm.py                      |  4 +--
 test/zdtm/static/Makefile         |  1 +
 test/zdtm/static/mnt_ext_dev.c    | 69 +++++++++++++++++++++++++++++++++++++++
 test/zdtm/static/mnt_ext_dev.desc |  6 ++++
 4 files changed, 78 insertions(+), 2 deletions(-)
 create mode 100644 test/zdtm/static/mnt_ext_dev.c
 create mode 100644 test/zdtm/static/mnt_ext_dev.desc

diff --git a/test/zdtm.py b/test/zdtm.py
index 23dd234..26bab3f 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -414,10 +414,10 @@ class zdtm_test:
 		return opts
 
 	def getdopts(self):
-		return self.__getcropts() + self.__freezer.getdopts()
+		return self.__getcropts() + self.__freezer.getdopts() + self.__desc.get('dopts', '').split()
 
 	def getropts(self):
-		return self.__getcropts() + self.__freezer.getropts()
+		return self.__getcropts() + self.__freezer.getropts() + self.__desc.get('ropts', '').split()
 
 	def gone(self, force = True):
 		if not self.auto_reap:
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index 9021320..58d093b 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -235,6 +235,7 @@ TST_DIR		=				\
 		binfmt_misc			\
 		unlink_regular00		\
 		autofs				\
+		mnt_ext_dev			\
 
 TST_DIR_FILE	=				\
 		chroot				\
diff --git a/test/zdtm/static/mnt_ext_dev.c b/test/zdtm/static/mnt_ext_dev.c
new file mode 100644
index 0000000..6d91113
--- /dev/null
+++ b/test/zdtm/static/mnt_ext_dev.c
@@ -0,0 +1,69 @@
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+#include <linux/limits.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc	= "Check mounts of external devices";
+const char *test_author	= "Andrei Vagin <avagin at virtuozzo.com";
+
+char *dirname;
+TEST_OPTION(dirname, string, "directory name", 1);
+
+int main(int argc, char **argv)
+{
+	char *loop, fd, dfd;
+	test_init(argc, argv);
+	struct stat st, st2;
+
+	mkdir(dirname, 0777);
+	loop = getenv("ZDTM_MNT_EXT_DEV");
+	if (loop == NULL)
+		return 1;
+
+	if (mount(loop, dirname, "ext4", 0, NULL) == -1) {
+		pr_perror("mount");
+		return -1;
+	}
+
+	dfd = open(dirname, O_RDONLY);
+	if (dfd < 0) {
+		pr_perror("open");
+		return -1;
+	}
+
+	fd = openat(dfd, "test_file", O_RDWR | O_CREAT, 0666);
+	if (fd < 0) {
+		pr_perror("open");
+		return -1;
+	}
+
+	if (fstat(fd, &st) < 0) {
+		pr_perror("stat");
+		return 1;
+	}
+
+	test_daemon();
+	test_waitsig();
+
+	if (fstat(fd, &st2) < 0) {
+		pr_perror("stat");
+		return 1;
+	}
+
+	if (st.st_ino != st2.st_ino) {
+		fail();
+		return 1;
+	}
+
+	pass();
+
+	return 0;
+}
diff --git a/test/zdtm/static/mnt_ext_dev.desc b/test/zdtm/static/mnt_ext_dev.desc
new file mode 100644
index 0000000..bbc557a
--- /dev/null
+++ b/test/zdtm/static/mnt_ext_dev.desc
@@ -0,0 +1,6 @@
+os.getenv("ZDTM_MNT_EXT_DEV") and \
+( lambda dev, rdev:
+{'flavor': 'ns', 'feature': 'mnt_id', "flags": "suid",
+"dopts": "--external mnt[%d/%d]" % (os.major(rdev), os.minor(rdev)),
+"ropts": "--ext-mount-map mnt[%d/%d]:%s" % (os.major(rdev), os.minor(rdev), dev),
+} ) (os.getenv("ZDTM_MNT_EXT_DEV"), os.stat(os.getenv("ZDTM_MNT_EXT_DEV")).st_rdev) or {'flags': 'noauto'}
-- 
2.5.0



More information about the CRIU mailing list