aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_pipe2.c8
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_socketpair.c21
2 files changed, 23 insertions, 6 deletions
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c b/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c
index 48f973488c7a..1b62fa630fd5 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c
@@ -53,17 +53,19 @@ run(int flags)
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
index 246b584d496a..165a42971d64 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c
@@ -63,16 +63,18 @@ run(int domain, int type, int flags)
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 @@ ATF_TC_BODY(null_sv, tc)
{
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);