[CRIU] [PATCH v4 9/9] zdtm: improve tempfs_overmounted test

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Mon Dec 11 19:07:26 MSK 2017


Unchanged test provided by Andrew.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 test/zdtm/static/tempfs_overmounted.c | 36 +++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/test/zdtm/static/tempfs_overmounted.c b/test/zdtm/static/tempfs_overmounted.c
index 56c3d2ed8..29eca00f4 100644
--- a/test/zdtm/static/tempfs_overmounted.c
+++ b/test/zdtm/static/tempfs_overmounted.c
@@ -19,11 +19,38 @@ int main(int argc, char **argv)
 	test_init(argc, argv);
 
 	mkdir(dirname, 0700);
-	if (mount("none", dirname, "tmpfs", 0, "") < 0) {
+	if (chdir(dirname)) {
+		pr_perror("chdir");
+		return 1;
+	}
+
+	mkdir("a", 0777);
+	mkdir("a/b", 0777);
+
+	mount(NULL, "/", NULL, MS_PRIVATE, "");
+	if (mount("none", "a/b", "tmpfs", 0, "") < 0) {
+		fail("Can't mount tmpfs");
+		return 1;
+	}
+	if (mount("none", "a/b", "tmpfs", 0, "") < 0) {
+		fail("Can't mount tmpfs");
+		return 1;
+	}
+	mkdir("a/b/c", 0777);
+	if (mount("none", "a/b/c", "tmpfs", 0, "") < 0) {
 		fail("Can't mount tmpfs");
 		return 1;
 	}
-	if (mount("none", dirname, "tmpfs", 0, "") < 0) {
+	if (mount("none", "a", "tmpfs", 0, "") < 0) {
+		fail("Can't mount tmpfs");
+		return 1;
+	}
+	if (mount("none", "a", "tmpfs", 0, "") < 0) {
+		fail("Can't mount tmpfs");
+		return 1;
+	}
+	mkdir("a/b", 0777);
+	if (mount("none", "a/b", "tmpfs", 0, "") < 0) {
 		fail("Can't mount tmpfs");
 		return 1;
 	}
@@ -31,6 +58,11 @@ int main(int argc, char **argv)
 	test_daemon();
 	test_waitsig();
 
+	if (umount("a/b") || umount("a") || umount("a") || umount("a/b/c") || umount("a/b") || umount("a/b")) {
+		pr_err("umount");
+		return 1;
+	}
+
 	pass();
 	return 0;
 }
-- 
2.14.3



More information about the CRIU mailing list