1 /* vi: set sw=4 ts=4 sts=4: */
3 * inotify test for uClibc
4 * Copyright (C) 2012 by Kevin Cernekee <cernekee@gmail.com>
6 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
15 #include <sys/inotify.h>
16 #include <sys/fcntl.h>
21 int ifd, fd, ret, result = 0;
22 struct inotify_event e;
23 char tfile[] = "/tmp/inotify.XXXXXX";
28 ifd = inotify_init1(IN_NONBLOCK);
30 perror("inotify_init1()");
33 if (inotify_add_watch(ifd, tfile, IN_DELETE_SELF) < 0) {
34 perror("inotify_add_watch()");
38 /* nonblocking inotify should return immediately with no events */
39 ret = read(ifd, &e, sizeof(e));
40 if (ret != -1 || errno != EAGAIN) {
41 fprintf(stderr, "first read() returned %d\n", ret);
45 /* generate an event */
48 /* now check whether our event was seen */
49 ret = read(ifd, &e, sizeof(e));
50 if (ret != sizeof(e)) {
51 fprintf(stderr, "second read() returned %d\n", ret);
55 if (!(e.mask & IN_DELETE_SELF)) {
56 fprintf(stderr, "incorrect event mask: %" PRIx32 "\n", e.mask);
64 #define TEST_FUNCTION do_test ()
65 #include "../test-skeleton.c"