]> granicus.if.org Git - strace/blob - tests/epoll_ctl.c
tests: add epoll_ctl.test
[strace] / tests / epoll_ctl.c
1 #include "tests.h"
2 #include <sys/syscall.h>
3
4 #if defined __NR_epoll_ctl && defined HAVE_SYS_EPOLL_H
5
6 # include <errno.h>
7 # include <inttypes.h>
8 # include <stdio.h>
9 # include <sys/epoll.h>
10 # include <unistd.h>
11
12 int
13 main(void)
14 {
15         struct epoll_event *const ev = tail_alloc(sizeof(*ev));
16         ev->events = EPOLLIN;
17
18         int rc = syscall(__NR_epoll_ctl, -1, EPOLL_CTL_ADD, -2, ev);
19         printf("epoll_ctl(-1, EPOLL_CTL_ADD, -2, {EPOLLIN,"
20                " {u32=%u, u64=%" PRIu64 "}}) = %d %s (%m)\n",
21                ev->data.u32, ev->data.u64, rc,
22                errno == ENOSYS ? "ENOSYS" : "EBADF");
23
24         puts("+++ exited with 0 +++");
25         return 0;
26 }
27
28 #else
29
30 SKIP_MAIN_UNDEFINED("__NR_epoll_ctl && HAVE_SYS_EPOLL_H")
31
32 #endif