[CRIU] [PATCH] zdtm/inotify00: fix expected sets of events

Andrey Vagin avagin at openvz.org
Fri Sep 5 08:27:10 PDT 2014


zdtm.sh with zero iterations of dumping/restoring checks correctness of
tests.

$ bash test/zdtm.sh -i 0 zdtm/inotify00
Output file: /root/git/orig/criu/test/zdtm/live/static/inotify00.out
------------------------------------------------------------------------------
19:16:29.601:  6905: 	unlink 02       : event      0x200 -> IN_DELETE
19:16:29.602:  6905: 	unlink 02       : event      0x200 -> IN_DELETE
19:16:29.602:  6905: 	unlink 02       : event        0x8 -> IN_CLOSE_WRITE
19:16:29.602:  6905: 	unlink 02       : event        0x8 -> IN_CLOSE_WRITE
19:16:29.602:  6905: 	unlink 02       : event      0x400 -> IN_DELETE_SELF
19:16:29.602:  6905: 	unlink 02       : event     0x8000 -> IN_IGNORED
19:16:29.602:  6905: 	unlink 02       : read  6 events
19:16:29.614:  6905: 	after           : event        0x8 -> IN_CLOSE_WRITE
19:16:29.614:  6905: 	after           : read  1 events
19:16:29.614:  6905: FAIL: inotify00.c:217: Unhandled events in emask 0x200 -> IN_DELETE (errno = 11 (Resource temporarily unavailable))
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================

This patch removes logic about linked files, because it's useless.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm/live/static/inotify00.c    | 77 +++++++++++++-----------------------
 test/zdtm/live/static/inotify00.opts |  1 +
 2 files changed, 29 insertions(+), 49 deletions(-)
 create mode 100644 test/zdtm/live/static/inotify00.opts

diff --git a/test/zdtm/live/static/inotify00.c b/test/zdtm/live/static/inotify00.c
index 2e25a66..519afe3 100644
--- a/test/zdtm/live/static/inotify00.c
+++ b/test/zdtm/live/static/inotify00.c
@@ -107,9 +107,9 @@ out:
 
 int main (int argc, char *argv[])
 {
-	unsigned int mask = IN_DELETE | IN_CLOSE_WRITE | IN_DELETE_SELF;
-	char test_link_path[PATH_MAX], test_file_path[PATH_MAX];
-	int fd, link_fd, real_fd;
+	unsigned int mask = IN_DELETE | IN_CLOSE_WRITE | IN_DELETE_SELF | IN_CREATE;
+	char test_file_path[PATH_MAX];
+	int fd, real_fd;
 	unsigned int emask;
 
 	test_init(argc, argv);
@@ -125,26 +125,11 @@ int main (int argc, char *argv[])
 		exit(1);
 	}
 
-	snprintf(test_link_path, sizeof(test_link_path), "%s/%s", dirname, TEST_LINK);
 	snprintf(test_file_path, sizeof(test_file_path), "%s/%s", dirname, TEST_FILE);
 
-	if (chdir(dirname)) {
-		err("Can't step into %s", dirname);
-		exit(1);
-	}
-
-	if (open(TEST_FILE, O_CREAT | O_TRUNC | O_RDWR, 0644) < 0) {
-		err("inotify_init failed");
-		exit(1);
-	}
-
-	if (link(TEST_FILE, TEST_LINK)) {
-		err("Can't link %s -> %s", TEST_FILE, TEST_LINK);
-		exit(1);
-	}
-
-	if (chdir("..")) {
-		err("Can't step into %s", "..");
+	real_fd = open(test_file_path, O_CREAT | O_TRUNC | O_RDWR, 0644);
+	if (real_fd < 0) {
+		err("Can't create %s", test_file_path);
 		exit(1);
 	}
 
@@ -153,47 +138,23 @@ int main (int argc, char *argv[])
 		exit(1);
 	}
 
-	if (inotify_add_watch(fd, test_link_path, mask) < 0) {
-		err("inotify_add_watch failed");
-		exit(1);
-	}
-
 	if (inotify_add_watch(fd, test_file_path, mask) < 0) {
 		err("inotify_add_watch failed");
 		exit(1);
 	}
 
-	link_fd = open(test_link_path, O_RDWR);
-	if (link_fd < 0) {
-		err("Can't open link");
-		exit(1);
-	}
-
-	real_fd = open(test_file_path, O_RDWR);
-	if (real_fd < 0) {
-		err("Can't open real");
-		exit(1);
-	}
-
 	/*
 	 * At this moment we have a file inside testing
 	 * directory and a hardlink to it. The file and
 	 * hardlink are opened.
 	 */
 
-	if (unlink(test_link_path)) {
-		err("can't unlink %s\n", test_link_path);
-		exit(1);
-	}
-
 	if (unlink(test_file_path)) {
 		err("can't unlink %s\n", test_file_path);
 		exit(1);
 	}
 
-	close(link_fd);
-
-	emask = IN_CLOSE_WRITE | IN_DELETE_SELF;
+	emask = IN_DELETE;
 	inotify_read_events("unlink 02", fd, &emask);
 	if (emask) {
 		char emask_bits[128];
@@ -208,7 +169,7 @@ int main (int argc, char *argv[])
 
 	close(real_fd);
 
-	emask = IN_DELETE | IN_CLOSE_WRITE;
+	emask = IN_CLOSE_WRITE;
 	inotify_read_events("after", fd, &emask);
 	if (emask) {
 		char emask_bits[128];
@@ -216,8 +177,26 @@ int main (int argc, char *argv[])
 		fail("Unhandled events in emask %#x -> %s",
 		    emask, emask_bits);
 		return 1;
-	} else
-		pass();
+	}
+
+	real_fd = open(test_file_path, O_CREAT | O_TRUNC | O_RDWR, 0644);
+	if (real_fd < 0) {
+		err("Can't create %s", test_file_path);
+		exit(1);
+	}
+	close(real_fd);
+
+	emask = IN_CREATE | IN_CLOSE_WRITE;
+	inotify_read_events("after2", fd, &emask);
+	if (emask) {
+		char emask_bits[128];
+		decode_event_mask(emask_bits, sizeof(emask_bits), emask);
+		fail("Unhandled events in emask %#x -> %s",
+		    emask, emask_bits);
+		return 1;
+	}
+
+	pass();
 
 	return 0;
 }
diff --git a/test/zdtm/live/static/inotify00.opts b/test/zdtm/live/static/inotify00.opts
new file mode 100644
index 0000000..4722946
--- /dev/null
+++ b/test/zdtm/live/static/inotify00.opts
@@ -0,0 +1 @@
+--link-remap
-- 
1.9.3



More information about the CRIU mailing list