summaryrefslogtreecommitdiff
path: root/tests/epoll_ctl.c
diff options
context:
space:
mode:
authorFei Jie <feij.fnst@cn.fujitsu.com>2016-04-08 15:59:15 +0800
committerDmitry V. Levin <ldv@altlinux.org>2016-04-08 07:59:15 +0000
commit258a22519f6f3c1cc77884fb4d13e71a473f84b5 (patch)
treea51515872352d0147e2c790c9e9779059cf55b72 /tests/epoll_ctl.c
parentbbdd23c8ed00d90909a9de56ddd5ece9c93fba38 (diff)
downloadstrace-258a22519f6f3c1cc77884fb4d13e71a473f84b5.tar.gz
tests: add epoll_ctl.test
* tests/epoll_ctl.c: New file. * tests/epoll_ctl.test: New test. * tests/.gitignore: Add epoll_ctl. * tests/Makefile.am (check_PROGRAMS): Likewise. (DECODER_TESTS): Add epoll_ctl.test.
Diffstat (limited to 'tests/epoll_ctl.c')
-rw-r--r--tests/epoll_ctl.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/epoll_ctl.c b/tests/epoll_ctl.c
new file mode 100644
index 000000000..4e985e0e2
--- /dev/null
+++ b/tests/epoll_ctl.c
@@ -0,0 +1,32 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#if defined __NR_epoll_ctl && defined HAVE_SYS_EPOLL_H
+
+# include <errno.h>
+# include <inttypes.h>
+# include <stdio.h>
+# include <sys/epoll.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+ struct epoll_event *const ev = tail_alloc(sizeof(*ev));
+ ev->events = EPOLLIN;
+
+ int rc = syscall(__NR_epoll_ctl, -1, EPOLL_CTL_ADD, -2, ev);
+ printf("epoll_ctl(-1, EPOLL_CTL_ADD, -2, {EPOLLIN,"
+ " {u32=%u, u64=%" PRIu64 "}}) = %d %s (%m)\n",
+ ev->data.u32, ev->data.u64, rc,
+ errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_epoll_ctl && HAVE_SYS_EPOLL_H")
+
+#endif