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.
This commit is contained in:
Fei Jie 2016-04-08 15:59:15 +08:00 committed by Dmitry V. Levin
parent bbdd23c8ed
commit 258a22519f
4 changed files with 41 additions and 0 deletions

1
tests/.gitignore vendored
View File

@ -27,6 +27,7 @@ dup2
dup3
epoll_create
epoll_create1
epoll_ctl
eventfd
execve
execve-v

View File

@ -78,6 +78,7 @@ check_PROGRAMS = \
dup3 \
epoll_create \
epoll_create1 \
epoll_ctl \
eventfd \
execve \
execve-v \
@ -278,6 +279,7 @@ DECODER_TESTS = \
dup3.test \
epoll_create.test \
epoll_create1.test \
epoll_ctl.test \
eventfd.test \
execve.test \
execve-v.test \

32
tests/epoll_ctl.c Normal file
View File

@ -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

6
tests/epoll_ctl.test Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
# Check epoll_ctl syscall decoding.
. "${srcdir=.}/init.sh"
run_strace_match_diff