Changeset View
Changeset View
Standalone View
Standalone View
contrib/netbsd-tests/lib/libc/sys/t_pipe2.c
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
run(int flags) | run(int flags) | ||||
{ | { | ||||
int fd[2], i; | int fd[2], i; | ||||
while ((i = open("/", O_RDONLY)) < 3) | while ((i = open("/", O_RDONLY)) < 3) | ||||
ATF_REQUIRE(i != -1); | ATF_REQUIRE(i != -1); | ||||
#ifdef __FreeBSD__ | #ifdef __NetBSD__ | ||||
closefrom(3); | /* This check is harmful since it closes atf's output file */ | ||||
#else | |||||
ATF_REQUIRE_MSG(closefrom(3) != -1, "closefrom failed: %s", | ATF_REQUIRE_MSG(closefrom(3) != -1, "closefrom failed: %s", | ||||
strerror(errno)); | strerror(errno)); | ||||
#endif | #endif | ||||
ATF_REQUIRE(pipe2(fd, flags) == 0); | ATF_REQUIRE(pipe2(fd, flags) == 0); | ||||
#ifdef __NetBSD__ | |||||
/* This check is harmful since it requires closing atf's output file */ | |||||
ATF_REQUIRE(fd[0] == 3); | ATF_REQUIRE(fd[0] == 3); | ||||
ATF_REQUIRE(fd[1] == 4); | ATF_REQUIRE(fd[1] == 4); | ||||
#endif | |||||
if (flags & O_CLOEXEC) { | if (flags & O_CLOEXEC) { | ||||
ATF_REQUIRE((fcntl(fd[0], F_GETFD) & FD_CLOEXEC) != 0); | ATF_REQUIRE((fcntl(fd[0], F_GETFD) & FD_CLOEXEC) != 0); | ||||
ATF_REQUIRE((fcntl(fd[1], F_GETFD) & FD_CLOEXEC) != 0); | ATF_REQUIRE((fcntl(fd[1], F_GETFD) & FD_CLOEXEC) != 0); | ||||
} else { | } else { | ||||
ATF_REQUIRE((fcntl(fd[0], F_GETFD) & FD_CLOEXEC) == 0); | ATF_REQUIRE((fcntl(fd[0], F_GETFD) & FD_CLOEXEC) == 0); | ||||
ATF_REQUIRE((fcntl(fd[1], F_GETFD) & FD_CLOEXEC) == 0); | ATF_REQUIRE((fcntl(fd[1], F_GETFD) & FD_CLOEXEC) == 0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |