[PATCH 2/4] tests: add epoll_ctl.test
Fei Jie
feij.fnst at cn.fujitsu.com
Fri Apr 8 07:59:15 UTC 2016
* 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 | 31 +++++++++++++++++++++++++++++++
tests/epoll_ctl.test | 6 ++++++
4 files changed, 40 insertions(+)
create mode 100644 tests/epoll_ctl.c
create mode 100755 tests/epoll_ctl.test
diff --git a/tests/.gitignore b/tests/.gitignore
index 0478e18..849d6ef 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 8dc6673..2a761d8 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 0000000..b24bae8
--- /dev/null
+++ b/tests/epoll_ctl.c
@@ -0,0 +1,31 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_epoll_ctl
+
+# include <errno.h>
+# include <stdio.h>
+# include <sys/epoll.h>
+# include <unistd.h>
+# include <inttypes.h>
+
+int
+main(void)
+{
+ struct epoll_event *const ev = tail_alloc(sizeof(struct epoll_event));
+ ev->events = EPOLLIN;
+ int rc = syscall(__NR_epoll_ctl, -1, EPOLL_CTL_ADD, -1, ev);
+ printf("epoll_ctl(-1, EPOLL_CTL_ADD, -1, {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_create")
+
+#endif
diff --git a/tests/epoll_ctl.test b/tests/epoll_ctl.test
new file mode 100755
index 0000000..1aded54
--- /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
--
1.8.3.1
More information about the Strace-devel
mailing list