static void verify_epoll_create1(void) { int fd, coe; fd = tst_syscall(__NR_epoll_create1, 0); if (fd == -1) tst_brk(TFAIL | TERRNO, "epoll_create1(0) failed"); coe = SAFE_FCNTL(fd, F_GETFD); if (coe & FD_CLOEXEC) tst_brk(TFAIL, "flags=0 set close-on-exec flag"); SAFE_CLOSE(fd); fd = tst_syscall(__NR_epoll_create1, EPOLL_CLOEXEC); if (fd == -1) tst_brk(TFAIL | TERRNO, "epoll_create1(EPOLL_CLOEXEC) failed"); coe = SAFE_FCNTL(fd, F_GETFD); if ((coe & FD_CLOEXEC) == 0) tst_brk(TFAIL, "flags=EPOLL_CLOEXEC didn't set close-on-exec"); SAFE_CLOSE(fd); tst_res(TPASS, "epoll_create1(EPOLL_CLOEXEC) PASSED"); }
static void verify_socketpair(unsigned int n) { int res, i; struct tcase *tc = &tcases[n]; TEST(socketpair(PF_UNIX, tc->type, 0, fds)); if (TEST_RETURN == -1) tst_brk(TFAIL | TTERRNO, "socketpair() failed"); for (i = 0; i < 2; i++) { res = SAFE_FCNTL(fds[i], tc->fl_flag); if (tc->flag != 0 && (res & tc->flag) == 0) { tst_res(TFAIL, "socketpair() failed to set %s flag for fds[%d]", tc->des, i); goto ret; } if (tc->flag == 0 && (res & tc->flag) != 0) { tst_res(TFAIL, "socketpair() failed to set %s flag for fds[%d]", tc->des, i); goto ret; } } tst_res(TPASS, "socketpair() passed to set %s flag", tc->des); ret: SAFE_CLOSE(fds[0]); SAFE_CLOSE(fds[1]); }
void check_mfd_has_seals(const char *file, const int lineno, int fd, int seals) { int ret = SAFE_FCNTL((fd), F_GET_SEALS); if (ret != seals) { tst_brk_(file, lineno, TFAIL, "fd %d doesn't have expected seals (%d expected %d)", fd, ret, seals); } tst_res_(file, lineno, TPASS, "fd %d has expected seals (%d)", fd, seals); }