[CRIU] [PATCH] zdtm/inotify00: check events properly
Andrey Vagin
avagin at openvz.org
Mon Sep 1 13:01:51 PDT 2014
Now test catches smth. Cyrill, could you look at this:
[root at avagin-fc19-cr criu]# bash test/zdtm.sh -i 1 static/inotify00
================================= CRIU CHECK =================================
Error (timerfd.c:56): timerfd: No timerfd support for c/r: Inappropriate ioctl for device
============================= WARNING =============================
Not all features needed for CRIU are merged to upstream kernel yet,
so for now we maintain our own branch which can be cloned from:
git://git.kernel.org/pub/scm/linux/kernel/git/gorcunov/linux-cr.git
===================================================================
Execute zdtm/live/static/inotify00
./inotify00 --pidfile=inotify00.pid --outfile=inotify00.out
Dump 9184
Restore
Check results 9184
Test: zdtm/live/static/inotify00, Result: FAIL
==================================== ERROR ====================================
Test: zdtm/live/static/inotify00, Namespace:
Dump log : /root/git/orig/criu/test/dump/static/inotify00/9184/1/dump.log
--------------------------------- grep Error ---------------------------------
------------------------------------- END -------------------------------------
Restore log: /root/git/orig/criu/test/dump/static/inotify00/9184/1/restore.log
--------------------------------- grep Error ---------------------------------
------------------------------------- END -------------------------------------
Output file: /root/git/orig/criu/test/zdtm/live/static/inotify00.out
------------------------------------------------------------------------------
23:38:37.709: 9184: 4
23:38:37.709: 9184: -----
23:38:38.902: 9184: 10
23:38:38.903: 9184: 4
23:38:38.903: 9184: 20
23:38:38.903: 9184: 4
23:38:38.903: 9184: 400
23:38:38.903: 9184: 8000
23:38:38.903: 9184: FAIL: inotify00.c:90: Unexpected events (errno = 11 (Resource temporarily unavailable))
23:38:38.903: 9184: -----
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================
Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
test/zdtm/live/static/inotify00.c | 63 ++++++++++++++++++++++++++-------------
1 file changed, 43 insertions(+), 20 deletions(-)
diff --git a/test/zdtm/live/static/inotify00.c b/test/zdtm/live/static/inotify00.c
index 587408c..3a3856d 100644
--- a/test/zdtm/live/static/inotify00.c
+++ b/test/zdtm/live/static/inotify00.c
@@ -22,53 +22,76 @@ const char path[] = "inotify-removed";
#define BUFF_SIZE ((sizeof(struct inotify_event) + PATH_MAX))
-int main (int argc, char *argv[])
+static int read_evetns(int fd)
{
char buf[BUFF_SIZE];
- int fd, wd, deleted, wd_deleted;
+ struct inotify_event *e;
+ int n = 0, ret, off;
+
+ while (1) {
+ ret = read(fd, buf, sizeof(buf));
+ if (ret < 0 && errno != EAGAIN) {
+ err("Unable to read from inotirfy fd");
+ return -1;
+ }
+ if (ret <= 0)
+ break;
+ off = 0;
+ while (off < ret) {
+ e = (struct inotify_event *) (buf + off);
+ off += sizeof(struct inotify_event) + e->len;
+ test_msg("%x\n", e->mask);
+ if (e->len)
+ test_msg("\t%s\n", e->name);
+ n++;
+ }
+ }
+
+ return n;
+}
+
+int main (int argc, char *argv[])
+{
+ int fd, deleted, wd_deleted;
test_init(argc, argv);
fd = inotify_init1(IN_NONBLOCK);
if (fd < 0) {
- fail("inotify_init failed");
+ err("inotify_init failed");
exit(1);
}
- wd = 0;
- wd |= inotify_add_watch(fd, "/", IN_ALL_EVENTS);
- if (wd < 0) {
- fail("inotify_add_watch failed");
- exit(1);
- }
-
- deleted = open(path, O_CREAT | O_TRUNC);
+ deleted = open(path, O_CREAT | O_TRUNC, 0666);
if (deleted < 0) {
- fail("inotify_init failed");
+ err("inotify_init failed");
exit(1);
}
wd_deleted = inotify_add_watch(fd, path, IN_ALL_EVENTS);
if (wd_deleted < 0) {
- fail("inotify_add_watch failed");
+ err("inotify_add_watch failed");
exit(1);
}
if (unlink(path)) {
- fail("can't unlink %s\n", path);
+ err("can't unlink %s\n", path);
exit(1);
}
+ if (read_evetns(fd) < 0)
+ exit(1);
+ test_msg("-----\n");
+
test_daemon();
test_waitsig();
- wd = open("/", O_RDONLY);
- if (read(fd, buf, sizeof(buf)) > 0) {
+ if (read_evetns(fd))
+ fail("Unexpected events");
+ test_msg("-----\n");
+ close(deleted);
+ if (read_evetns(fd) > 0)
pass();
- } else {
- fail("No events in queue");
- exit(1);
- }
return 0;
}
--
1.9.3
More information about the CRIU
mailing list