tests/epoll_create1.c: extend for the case of ENOSYS
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 10 Apr 2016 23:05:18 +0000 (23:05 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 10 Apr 2016 23:05:18 +0000 (23:05 +0000)
* epoll_create1.c: Make the test work in case of epoll_create1
returning ENOSYS.

tests/epoll_create1.c

index 4d2e1077962d293076495aaf8259042f435ebeb1..270ab52cc276a732d232e7095920007c8c9e7073 100644 (file)
  */
 
 #include "tests.h"
-#include <assert.h>
 #include <fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
 #include <sys/syscall.h>
 
 #if defined __NR_epoll_create1 && defined O_CLOEXEC
 
+# include <assert.h>
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
 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;