From 7a06960ff424dd4db1d36ef62180076794642c52 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sun, 10 Apr 2016 23:05:18 +0000 Subject: [PATCH] tests/epoll_create1.c: extend for the case of ENOSYS * epoll_create1.c: Make the test work in case of epoll_create1 returning ENOSYS. --- tests/epoll_create1.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/epoll_create1.c b/tests/epoll_create1.c index 4d2e1077..270ab52c 100644 --- a/tests/epoll_create1.c +++ b/tests/epoll_create1.c @@ -26,25 +26,31 @@ */ #include "tests.h" -#include #include -#include -#include #include #if defined __NR_epoll_create1 && defined O_CLOEXEC +# include +# include +# include +# include + int main(void) { - (void) close(0); - - if (syscall(__NR_epoll_create1, O_CLOEXEC)) - perror_msg_and_skip("epoll_create1 O_CLOEXEC"); - puts("epoll_create1(EPOLL_CLOEXEC) = 0"); + int rc = syscall(__NR_epoll_create1, O_CLOEXEC); + if (rc == -1) { + if (ENOSYS != errno) + perror_msg_and_fail("epoll_create1 O_CLOEXEC"); + printf("epoll_create1(EPOLL_CLOEXEC) = -1 ENOSYS (%m)\n"); + } else { + printf("epoll_create1(EPOLL_CLOEXEC) = %d\n", rc); + } assert(syscall(__NR_epoll_create1, O_CLOEXEC | O_NONBLOCK) == -1); - printf("epoll_create1(EPOLL_CLOEXEC|%#x) = -1 EINVAL (%m)\n", O_NONBLOCK); + printf("epoll_create1(EPOLL_CLOEXEC|%#x) = -1 %s (%m)\n", + O_NONBLOCK, ENOSYS == errno ? "ENOSYS" : "EINVAL"); puts("+++ exited with 0 +++"); return 0; -- 2.40.0