From owner-dev-commits-src-all@freebsd.org Wed Mar 17 14:05:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3564156944C; Wed, 17 Mar 2021 14:05:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F0sPD1NRgz3sXZ; Wed, 17 Mar 2021 14:05:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A95D07F9F; Wed, 17 Mar 2021 14:05:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 12HE5JGM086036; Wed, 17 Mar 2021 14:05:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12HE5J1x086035; Wed, 17 Mar 2021 14:05:19 GMT (envelope-from git) Date: Wed, 17 Mar 2021 14:05:19 GMT Message-Id: <202103171405.12HE5J1x086035@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: d97a4cb221d5 - stable/13 - Fix two failing tests after ATF update MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d97a4cb221d5f52a92473a4709aa97f812739f34 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Mar 2021 14:05:21 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=d97a4cb221d5f52a92473a4709aa97f812739f34 commit d97a4cb221d5f52a92473a4709aa97f812739f34 Author: Alex Richardson AuthorDate: 2021-02-15 22:11:30 +0000 Commit: Alex Richardson CommitDate: 2021-03-17 12:22:15 +0000 Fix two failing tests after ATF update Since https://github.com/freebsd/atf/commit/4581cefc1e3811dd3c926b5dd4b15fd63d2e19da ATF opens the results file on startup. This fixes problems like capsicumized tests not being able to open the file on exit. However, this test closes all file descriptors just to check that socketpair returns fd 3+4 and thereby also closes the ATF results file. This then results in an EBADF when writing the result so the test is reported as broken. While system calls that create new file descriptors (must?) use the lowest available file descriptor number, it does not seem useful to test this property here. Drop the check for FD==3/4 to unbreak the testsuite. We could also try to re-open the results file in ATF if we get a EBADF error, but that will fail when running under Capsicum. Reviewed By: cem Differential Revision: https://reviews.freebsd.org/D28683 (cherry picked from commit 10fc4c3218381fef7189a5b8d46a757cd1989dff) --- contrib/netbsd-tests/lib/libc/sys/t_pipe2.c | 8 +++++--- contrib/netbsd-tests/lib/libc/sys/t_socketpair.c | 21 ++++++++++++++++++--- 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);