[CRIU] [PATCH 2/2] zdtm: add a new test case for growdown vma-s

Andrey Vagin avagin at openvz.org
Mon May 5 03:50:28 PDT 2014


This test case creates two consecutive grows down vmas with a hole
between them.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm.sh                       |  1 +
 test/zdtm/live/static/Makefile     |  1 +
 test/zdtm/live/static/grow_map03.c | 40 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+)
 create mode 100644 test/zdtm/live/static/grow_map03.c

diff --git a/test/zdtm.sh b/test/zdtm.sh
index 4de131d..b4f9282 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -100,6 +100,7 @@ static/sk-netlink
 static/proc-self
 static/grow_map
 static/grow_map02
+static/grow_map03
 static/stopped
 static/chroot
 static/chroot-file
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index b0f7807..39ffe0b 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -102,6 +102,7 @@ TST_NOFILE	=				\
 		mem-touch			\
 		grow_map			\
 		grow_map02			\
+		grow_map03			\
 		tun				\
 		stopped				\
 		rtc				\
diff --git a/test/zdtm/live/static/grow_map03.c b/test/zdtm/live/static/grow_map03.c
new file mode 100644
index 0000000..1507b6e
--- /dev/null
+++ b/test/zdtm/live/static/grow_map03.c
@@ -0,0 +1,40 @@
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc	= "Check that VMA-s with MAP_GROWSDOWN are restored correctly";
+const char *test_author	= "Andrew Vagin <avagin at openvz.org>";
+
+/*
+* This test case creates two consecutive grows down vmas with a hole
+* between them.
+*/
+
+int main(int argc, char **argv)
+{
+	char *start_addr, *addr1, *addr2;
+
+	test_init(argc, argv);
+
+	start_addr = mmap(NULL, PAGE_SIZE * 10, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+	if (start_addr == MAP_FAILED) {
+		err("Can't mal a new region");
+		return 1;
+	}
+	munmap(start_addr, PAGE_SIZE * 10);
+
+	addr1 = mmap(start_addr + PAGE_SIZE * 5, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_GROWSDOWN, -1, 0);
+	addr2 = mmap(start_addr + PAGE_SIZE * 3, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_GROWSDOWN, -1, 0);
+
+	err("%p %p\n", addr1, addr2);
+
+	test_daemon();
+	test_waitsig();
+
+	pass();
+
+	return 0;
+}
-- 
1.8.5.3



More information about the CRIU mailing list