[CRIU] [PATCH] zdtm: Add mmap03 test case

Cyrill Gorcunov gorcunov at openvz.org
Wed Feb 6 11:33:43 EST 2013


To be able to test it one need indeed enough
physical memory on the node (at least 16G).
Thus I don't include this test for regular
passes.

Inspired by commit 40dcaf885eaf3f2f51d08ecb6c18c3f948655c6e

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 test/zdtm/live/static/Makefile |  1 +
 test/zdtm/live/static/maps03.c | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 test/zdtm/live/static/maps03.c

diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index b8b28e4..a888536 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -60,6 +60,7 @@ TST_NOFILE	=				\
 		sem				\
 		maps01				\
 		maps02				\
+		maps03				\
 		xids00				\
 		groups				\
 		file_fown			\
diff --git a/test/zdtm/live/static/maps03.c b/test/zdtm/live/static/maps03.c
new file mode 100644
index 0000000..207e2a0
--- /dev/null
+++ b/test/zdtm/live/static/maps03.c
@@ -0,0 +1,38 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include "zdtmtst.h"
+
+const char *test_doc	= "Test for huge VMA area";
+const char *test_author	= "Cyrill Gorcunov <gorcunov at openvz.org>";
+
+int main(int argc, char **argv)
+{
+	test_init(argc, argv);
+	unsigned char *mem;
+
+	test_msg("Alloc huge VMA\n");
+	mem = (void *)mmap(NULL, (10 << 30), PROT_READ | PROT_WRITE,
+			   MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+	if ((void *)mem == MAP_FAILED) {
+		err("mmap failed: %m");
+		return -1;
+	}
+
+	mem[4 << 30] = 1;
+	mem[8 << 30] = 2;
+
+	test_daemon();
+	test_waitsig();
+
+	test_msg("Testing restored data\n");
+
+	if (mem[4 << 30] != 1 || mem[8 << 30] != 2) {
+		fail("Data corrupted!\n");
+		exit(1);
+	}
+
+	pass();
+
+	return 0;
+}
-- 
1.8.1



More information about the CRIU mailing list