diff --git a/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c b/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c --- a/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c @@ -53,17 +53,19 @@ while ((i = open("/", O_RDONLY)) < 3) ATF_REQUIRE(i != -1); -#ifdef __FreeBSD__ - closefrom(3); -#else +#ifdef __NetBSD__ + /* This check is harmful since it closes atf's output file */ ATF_REQUIRE_MSG(closefrom(3) != -1, "closefrom failed: %s", strerror(errno)); #endif 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[1] == 4); +#endif if (flags & O_CLOEXEC) { ATF_REQUIRE((fcntl(fd[0], F_GETFD) & FD_CLOEXEC) != 0); diff --git a/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c b/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c --- a/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c @@ -63,16 +63,18 @@ while ((i = open("/", O_RDONLY)) < 3) ATF_REQUIRE(i != -1); -#ifdef __FreeBSD__ - closefrom(3); -#else +#ifdef __NetBSD__ + /* This check is harmful since it closes atf's output file */ ATF_REQUIRE(closefrom(3) != -1); #endif ATF_REQUIRE(socketpair(domain, type | flags, 0, fd) == 0); +#if __NetBSD__ + /* This check is harmful since it requires closing atf's output file */ ATF_REQUIRE(fd[0] == 3); ATF_REQUIRE(fd[1] == 4); +#endif connected(fd[0]); connected(fd[1]); @@ -125,12 +127,25 @@ { int fd; +#ifdef __NetBSD__ + /* This check is harmful since it closes atf's output file */ closefrom(3); +#else + int lowfd = open("/", O_RDONLY); + ATF_REQUIRE(lowfd > 0); + ATF_REQUIRE_EQ(0, close(lowfd)); +#endif ATF_REQUIRE_EQ(socketpair(AF_UNIX, SOCK_DGRAM, 0, NULL), -1); ATF_REQUIRE_EQ(EFAULT, errno); fd = open("/", O_RDONLY); +#ifdef __NetBSD__ ATF_REQUIRE_EQ_MSG(fd, 3, "socketpair(..., NULL) allocated descriptors"); +#else + ATF_REQUIRE_EQ_MSG(fd, lowfd, + "socketpair(..., NULL) allocated descriptors: fd=%d, lowfd=%d", + fd, lowfd); +#endif } ATF_TC(socketpair_basic);