]> granicus.if.org Git - strace/blob - tests/epoll_ctl.c
tests: use errno2name()
[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                errno2name());
23
24         rc = syscall(__NR_epoll_ctl, -3, EPOLL_CTL_DEL, -4, ev);
25         printf("epoll_ctl(-3, EPOLL_CTL_DEL, -4, %p) = %d %s (%m)\n",
26                ev, rc, errno2name());
27
28         rc = syscall(__NR_epoll_ctl, -1L, EPOLL_CTL_MOD, -16L, 0);
29         printf("epoll_ctl(-1, EPOLL_CTL_MOD, -16, NULL) = %d %s (%m)\n",
30                rc, errno2name());
31
32         puts("+++ exited with 0 +++");
33         return 0;
34 }
35
36 #else
37
38 SKIP_MAIN_UNDEFINED("__NR_epoll_ctl && HAVE_SYS_EPOLL_H")
39
40 #endif