[CRIU] [PATCH cr 16/16] zdtm: cow00 checks unshared pages
Andrey Vagin
avagin at openvz.org
Tue Oct 23 06:02:28 EDT 2012
A parent and a child write in one page and check data after suspend/resume
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
test/zdtm/live/static/cow00.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/test/zdtm/live/static/cow00.c b/test/zdtm/live/static/cow00.c
index 04b6c53..2c72283 100644
--- a/test/zdtm/live/static/cow00.c
+++ b/test/zdtm/live/static/cow00.c
@@ -13,8 +13,9 @@
const char *test_doc = "Check that cow memory are restored";
const char *test_author = "Andrey Vagin <avagin at parallels.com";
-#define MAP_SIZE (PAGE_SIZE * 2)
+#define MAP_SIZE (PAGE_SIZE * 3)
#define NONCOW_OFFSET PAGE_SIZE
+#define UNSHARE_OFFSET (PAGE_SIZE * 2)
static int is_cow(void *addr, pid_t p1, pid_t p2)
{
@@ -82,11 +83,15 @@ int main(int argc, char ** argv)
memset(addr, 1, PAGE_SIZE);
+ addr[UNSHARE_OFFSET] = 'P';
+
pid = test_fork();
if (pid < 0) {
err("Unable to fork a new process\n");
return 1;
} else if (pid == 0) {
+ addr[UNSHARE_OFFSET] = 'C';
+
test_waitsig();
if (addr[NONCOW_OFFSET]) {
@@ -95,6 +100,12 @@ int main(int argc, char ** argv)
return 1;
}
+ if (addr[UNSHARE_OFFSET] != 'C') {
+ fail("%p contains '%c' instead of 'C'",
+ addr + UNSHARE_OFFSET, addr[UNSHARE_OFFSET]);
+ return 1;
+ }
+
return 0;
}
@@ -117,6 +128,12 @@ int main(int argc, char ** argv)
goto out;
}
+ if (addr[UNSHARE_OFFSET] != 'P') {
+ fail("%p contains '%c' instead of 'P'",
+ addr + UNSHARE_OFFSET, addr[UNSHARE_OFFSET]);
+ goto out;
+ }
+
ret = 0;
out:
kill(pid, SIGTERM);
--
1.7.1
More information about the CRIU
mailing list