From nobody Thu Dec 18 18:23:12 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dXJv51Ycxz6LTm4 for ; Thu, 18 Dec 2025 18:23:13 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dXJv46kFxz47df for ; Thu, 18 Dec 2025 18:23:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766082193; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C8XzCMdl7juVCgyBYF/EiJ8e3e/FoKdddFziMw2YitQ=; b=A3KC56GL6XXbaVXrUAHDg5EKdvG7pPBXN8Xf2sgF/KzXfT8n2DpvLK5ehxaXtxhA0nHtBa n8Z716inxB0OD8wijtI48l0VRstVB1yn+8y6sGFsfzYmPQB1lP6OOjw1s1RG6jyqllPHga V+FjiXUt4mV17OhFv63ZtGNb+eqzdy7G4TVfvBrAGYTedO9dsadeVO2juZzQqRTNfxLcl9 JeB3IVT59Ypgwa6PEhCubMehdrbRwYx8dSpFvzgqNbAcOl+EOzEmV7R/1DdFat6cElaQPv /QUiGw0ksCK3D2xx+SvyaD6NiVewl9v+VCz3hJlfO2pv7qJj94+QJRF3I/NEuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766082193; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C8XzCMdl7juVCgyBYF/EiJ8e3e/FoKdddFziMw2YitQ=; b=FfPmjKvGvjuV2+ylazFZxNR7k+tYMsnTzZUJvtlD2/tn1B0csKTFGgj927Hv5iiDzzCayL iDZx75cN+8ksYJRXcJDfKi0BP257o6/1OLWyOpt749zqIQyk899RrvT1aaUnp3mlPR2Su4 pb98PRWbW0B9SNstGg+3TUIJa05SqXVi8GS1i7gOsT1l9ZQ7E36oIABoXjneGkGxP2NBHl pCpu8VJ6lQHT7rmMZLXSAmE07gzsffSXTzL4NTHVlZIpnoYloeXi2i0M4xn1L8uf5+3yOe dRBC5qt3O/d2bcHFh0vHFZlbw5zdDq8fmt8Zrq/gW29c2Z/Wy7F/z9xr3VrOpA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1766082193; a=rsa-sha256; cv=none; b=Tm8pmD2td7sAmmYyjRgCrvk/IjXBwI3e9o0jXCokn/EAfvEIh0HRYk7mQSfLJ4kAvUoUYK OGoMU0bvS1aYj2b+KBhPoV4fZblZHe+cAt5ycN+75Myo+Zxod6is0WcIYZBWzZHe0us8q1 Orl4S7gpqaKsyCgfU1RI3NMUAQZKeCNfbafjhqNyUtXxla+B4MqZwH4GIGiDg3My0bdZcp liYzTiebJ4NIX+soR1VVHGnB35Lt8xSzOohjQac0wnuc5rTC93Wtm4GLCl5vlibyPUJYzc JYEs8ypYySCjsZbg2TUG6FzkkcUPBSJIo4MpUR4FfscBuAEd73AqekMvhDUZJg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dXJv45chFzq4n for ; Thu, 18 Dec 2025 18:23:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 26fdf by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 18 Dec 2025 18:23:12 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 200e1ca48fdc - stable/14 - fcntlflags_test: Port to atf-c(3) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 200e1ca48fdc11914cce91957d75e549b91f07c1 Auto-Submitted: auto-generated Date: Thu, 18 Dec 2025 18:23:12 +0000 Message-Id: <69444690.26fdf.3b57ed86@gitrepo.freebsd.org> The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=200e1ca48fdc11914cce91957d75e549b91f07c1 commit 200e1ca48fdc11914cce91957d75e549b91f07c1 Author: John Baldwin AuthorDate: 2025-10-03 16:43:18 +0000 Commit: John Baldwin CommitDate: 2025-12-18 17:01:56 +0000 fcntlflags_test: Port to atf-c(3) Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D52720 (cherry picked from commit 5c331f449e9ca549d03ae1a3f50ac0e5306b488e) --- tests/sys/file/Makefile | 2 +- tests/sys/file/fcntlflags_test.c | 116 +++++++++++++++++++-------------------- 2 files changed, 58 insertions(+), 60 deletions(-) diff --git a/tests/sys/file/Makefile b/tests/sys/file/Makefile index 010606bfeba0..fd490cb0543e 100644 --- a/tests/sys/file/Makefile +++ b/tests/sys/file/Makefile @@ -6,7 +6,7 @@ BINDIR= ${TESTSDIR} ATF_TESTS_C+= path_test TAP_TESTS_C+= closefrom_test TAP_TESTS_C+= dup_test -TAP_TESTS_C+= fcntlflags_test +ATF_TESTS_C+= fcntlflags_test TAP_TESTS_SH+= flock_test PLAIN_TESTS_C+= ftruncate_test PLAIN_TESTS_C+= newfileops_on_fork_test diff --git a/tests/sys/file/fcntlflags_test.c b/tests/sys/file/fcntlflags_test.c index c5026e38c48b..009bb87371a1 100644 --- a/tests/sys/file/fcntlflags_test.c +++ b/tests/sys/file/fcntlflags_test.c @@ -24,85 +24,83 @@ * SUCH DAMAGE. */ -#include - +#include #include #include #include +#include + /* * O_ACCMODE is currently defined incorrectly. This is what it should be. * Various code depends on the incorrect value. */ #define CORRECT_O_ACCMODE (O_ACCMODE | O_EXEC) -static int testnum; - static void -subtests(const char *path, int omode, const char *omodetext) +basic_tests(const char *path, int omode, const char *omodetext) { int fd, flags1, flags2, flags3; fd = open(path, omode); - if (fd == -1) - printf("not ok %d - open(\"%s\", %s) failed\n", - testnum++, path, omodetext); - else - printf("ok %d - open(\"%s\", %s) succeeded\n", - testnum++, path, omodetext); + ATF_REQUIRE_MSG(fd != -1, "open(\"%s\", %s) failed: %s", path, + omodetext, strerror(errno)); + flags1 = fcntl(fd, F_GETFL); - if (flags1 == -1) - printf("not ok %d - fcntl(F_GETFL) failed\n", testnum++); - else if ((flags1 & CORRECT_O_ACCMODE) == omode) - printf("ok %d - fcntl(F_GETFL) gave correct result\n", - testnum++); - else - printf("not ok %d - fcntl(F_GETFL) gave incorrect result " - "(%#x & %#x != %#x)\n", - testnum++, flags1, CORRECT_O_ACCMODE, omode); - if (fcntl(fd, F_SETFL, flags1) == -1) - printf("not ok %d - fcntl(F_SETFL) same flags failed\n", - testnum++); - else - printf("ok %d - fcntl(F_SETFL) same flags succeeded\n", - testnum++); + ATF_REQUIRE_MSG(flags1 != -1, "fcntl(F_GETFL) (1) failed: %s", + strerror(errno)); + ATF_REQUIRE_INTEQ(omode, flags1 & CORRECT_O_ACCMODE); + ATF_REQUIRE((flags1 & O_NONBLOCK) == 0); + + ATF_REQUIRE_MSG(fcntl(fd, F_SETFL, flags1) != -1, + "fcntl(F_SETFL) same flags failed: %s", strerror(errno)); + flags2 = fcntl(fd, F_GETFL); - if (flags2 == -1) - printf("not ok %d - fcntl(F_GETFL) failed\n", testnum++); - else if (flags2 == flags1) - printf("ok %d - fcntl(F_GETFL) gave same result\n", - testnum++); - else - printf("not ok %d - fcntl(F_SETFL) caused fcntl(F_GETFL) to " - "change from %#x to %#x\n", - testnum++, flags1, flags2); - if (fcntl(fd, F_SETFL, flags2 | O_NONBLOCK) == -1) - printf("not ok %d - fcntl(F_SETFL) O_NONBLOCK failed\n", - testnum++); - else - printf("ok %d - fcntl(F_SETFL) O_NONBLOCK succeeded\n", - testnum++); + ATF_REQUIRE_MSG(flags2 != -1, "fcntl(F_GETFL) (2) failed: %s", + strerror(errno)); + ATF_REQUIRE_INTEQ(flags1, flags2); + + ATF_REQUIRE_MSG(fcntl(fd, F_SETFL, flags2 | O_NONBLOCK) != -1, + "fcntl(F_SETFL) O_NONBLOCK failed: %s", strerror(errno)); + flags3 = fcntl(fd, F_GETFL); - if (flags3 == -1) - printf("not ok %d - fcntl(F_GETFL) failed\n", testnum++); - else if (flags3 == (flags2 | O_NONBLOCK)) - printf("ok %d - fcntl(F_GETFL) gave expected result\n", - testnum++); - else - printf("not ok %d - fcntl(F_SETFL) gave unexpected result " - "(%#x != %#x)\n", - testnum++, flags3, flags2 | O_NONBLOCK); + ATF_REQUIRE_MSG(flags3 != -1, "fcntl(F_GETFL) (3) failed: %s", + strerror(errno)); + ATF_REQUIRE_INTEQ(flags2 | O_NONBLOCK, flags3); + (void)close(fd); } -int -main(int argc __unused, char **argv __unused) +ATF_TC_WITHOUT_HEAD(read_only_null); +ATF_TC_BODY(read_only_null, tc) +{ + basic_tests("/dev/null", O_RDONLY, "O_RDONLY"); +} + +ATF_TC_WITHOUT_HEAD(write_only_null); +ATF_TC_BODY(write_only_null, tc) +{ + basic_tests("/dev/null", O_WRONLY, "O_WRONLY"); +} + +ATF_TC_WITHOUT_HEAD(read_write_null); +ATF_TC_BODY(read_write_null, tc) { - printf("1..24\n"); - testnum = 1; - subtests("/dev/null", O_RDONLY, "O_RDONLY"); - subtests("/dev/null", O_WRONLY, "O_WRONLY"); - subtests("/dev/null", O_RDWR, "O_RDWR"); - subtests("/bin/sh", O_EXEC, "O_EXEC"); - return (0); + basic_tests("/dev/null", O_RDWR, "O_RDWR"); +} + +ATF_TC_WITHOUT_HEAD(exec_only_sh); +ATF_TC_BODY(exec_only_sh, tc) +{ + basic_tests("/bin/sh", O_EXEC, "O_EXEC"); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, read_only_null); + ATF_TP_ADD_TC(tp, write_only_null); + ATF_TP_ADD_TC(tp, read_write_null); + ATF_TP_ADD_TC(tp, exec_only_sh); + + return (atf_no_error()); }