[CRIU] [PATCH 5/6] zdtm: Add inotify00 test case

Cyrill Gorcunov gorcunov at openvz.org
Tue Apr 17 09:22:30 EDT 2012


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 test/zdtm.sh                      |    1 +
 test/zdtm/live/static/Makefile    |    1 +
 test/zdtm/live/static/inotify00.c |   57 +++++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 0 deletions(-)
 create mode 100644 test/zdtm/live/static/inotify00.c

diff --git a/test/zdtm.sh b/test/zdtm.sh
index b962424..f33a61e 100644
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -40,6 +40,7 @@ static/selfexe00
 static/file_fown
 static/unlink_fstat00
 static/unlink_fstat02
+static/inotify00
 "
 
 UTS_TEST_LIST="
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index b8e78bc..0f1e0df 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -41,6 +41,7 @@ TST_NOFILE	=				\
 		maps01				\
 		xids00				\
 		file_fown			\
+		inotify00			\
 #		jobctl00			\
 
 TST_FILE	=				\
diff --git a/test/zdtm/live/static/inotify00.c b/test/zdtm/live/static/inotify00.c
new file mode 100644
index 0000000..79d653c
--- /dev/null
+++ b/test/zdtm/live/static/inotify00.c
@@ -0,0 +1,57 @@
+#define _GNU_SOURCE         /* See feature_test_macros(7) */
+#include <unistd.h>
+#include <limits.h>
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/inotify.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc	= "Check for inotify delivery";
+const char *test_author	= "Cyrill Gorcunov <gorcunov at openvz.org>";
+
+#define BUFF_SIZE ((sizeof(struct inotify_event) + PATH_MAX))
+
+int main (int argc, char *argv[])
+{
+	char buf[BUFF_SIZE];
+	int fd, wd;
+
+	test_init(argc, argv);
+
+	fd = inotify_init1(IN_NONBLOCK);
+	if (fd < 0) {
+		fail("inotify_init failed");
+		exit(1);
+	}
+
+	wd  = 0;
+	wd |= inotify_add_watch(fd, "/", IN_ALL_EVENTS);
+	wd |= inotify_add_watch(fd, "/root", IN_ALL_EVENTS);
+	wd |= inotify_add_watch(fd, "/boot", IN_ALL_EVENTS);
+	if (wd < 0) {
+		fail("inotify_add_watch failed");
+		exit(1);
+	}
+
+	test_daemon();
+	test_waitsig();
+
+	wd = open("/", O_RDONLY);
+	if (read(fd, buf, sizeof(buf)) > 0) {
+		pass();
+	} else {
+		fail("No events in queue");
+		exit(1);
+	}
+
+	return 0;
+}
-- 
1.7.7.6



More information about the CRIU mailing list