From 258a22519f6f3c1cc77884fb4d13e71a473f84b5 Mon Sep 17 00:00:00 2001 From: Fei Jie Date: Fri, 8 Apr 2016 15:59:15 +0800 Subject: [PATCH] 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. --- tests/.gitignore | 1 + tests/Makefile.am | 2 ++ tests/epoll_ctl.c | 32 ++++++++++++++++++++++++++++++++ tests/epoll_ctl.test | 6 ++++++ 4 files changed, 41 insertions(+) create mode 100644 tests/epoll_ctl.c create mode 100755 tests/epoll_ctl.test diff --git a/tests/.gitignore b/tests/.gitignore index 0478e186..849d6ef0 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -27,6 +27,7 @@ dup2 dup3 epoll_create epoll_create1 +epoll_ctl eventfd execve execve-v diff --git a/tests/Makefile.am b/tests/Makefile.am index 8dc66735..2a761d8f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \ diff --git a/tests/epoll_ctl.c b/tests/epoll_ctl.c new file mode 100644 index 00000000..4e985e0e --- /dev/null +++ b/tests/epoll_ctl.c @@ -0,0 +1,32 @@ +#include "tests.h" +#include + +#if defined __NR_epoll_ctl && defined HAVE_SYS_EPOLL_H + +# include +# include +# include +# include +# include + +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 diff --git a/tests/epoll_ctl.test b/tests/epoll_ctl.test new file mode 100755 index 00000000..1aded543 --- /dev/null +++ b/tests/epoll_ctl.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# Check epoll_ctl syscall decoding. + +. "${srcdir=.}/init.sh" +run_strace_match_diff