From nobody Fri Apr 17 03:57:24 2026 X-Original-To: dev-commits-src-main@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 4fxh0h48hWz6bGk2 for ; Fri, 17 Apr 2026 03:57:24 +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" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fxh0h3KpVz41ks for ; Fri, 17 Apr 2026 03:57:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776398244; 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=1VPXVzV7XEbqXs9V8b9B8yGBIct6phhjev4jA42iGeE=; b=RX8xYwWIRPauPsE6KEdnPvqmN0e/UPagcIxviRkNJaGSzoez1nVb0QRel3s6kGU0jwHMNC HIUQ/h5VlK/abTBupOV8tDyB+UT8Gp5X+1A7ufwbYZsi2lzyNWtnn9Zeho7nuHTUnAL04L sTZhJLBVrqb2TLX7ICHKmkGW8OLm5ROZ0YicKIRxlZEhY7jxEek22KxBNY9RfvWkx9i+Fc DwyAmjm0sSCzeAnvWnd2Sq3YyNfFhjrpu31544WBUDNno1Gf11JhtWNgrS9L7KSgGhwV6o sEybx64reMN24phY5tQlR/WKQfB6/eJKkK/HO6XtqOu7cIF4JuVbcpPNhClSIQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776398244; a=rsa-sha256; cv=none; b=AWAK/zgco0YES4uA/RzV09k3y3+2recAWClVBptGhRCl29q138nkAblWErrXh9sXv2gaW5 4H9sXx9aNnxMNjS3UrclKo3xOWbZc8yritJhqdnzBiaqwVJKhUCxAWslDivqzY61BtLC8k EvsL/FhNOQy/AT5Ud67lQtWnVSFx6PZDrsN5+y/Zyh/MLLyinRGvoBg88LFS6srkHMGSOR /YsMGb1tHZymX+/x14MFwB0UXqF9DZ91o531LO3MjwPhQoYgbYyVRYMnrn4uYtwLKf+vP1 ViHd8hwo25VyYnrtrxWkcm3M4XuhdYnUT9Aqt4Y1wj9w8f+cW1c7UvItxCyDgQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776398244; 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=1VPXVzV7XEbqXs9V8b9B8yGBIct6phhjev4jA42iGeE=; b=Hp0hsqPVeg5sJ9TtynMDWNMSsCHTMlelWIBOx8dnA6gbdJf19/eRVHSMZK00dwx4reSA0x yJdUPdvY3xnkihNEGAdjksaT1GAVC1EcvC9wXbJOvKNHstBiQpW2HOYXLl2scCg0LeymH2 4lxxVfLOIBu+e3moQJ8t8U0GHPup7hxEdASUv5mk018kPstlyPjFxAPcGNsdytd2nonSJB jVIPDOJxWtRM8EbgPhvHqosM4bZJQ100FyrFbFsL7jaxnfzKZsl6vsHAdrUgB8nZb6BvNl BWO3VisqHzYZXK7l/zVlwtKS0A38CtyeHjGjGDTeMBqjdtWvP6iIDl+UTKJa9w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fxh0h2X0BzdnQ for ; Fri, 17 Apr 2026 03:57:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2788c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 17 Apr 2026 03:57:24 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 51d2c3801082 - main - tests: kqueue: improve diagnostics for our CPONFORK test List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 51d2c38010824b90d7462711896a88165db9d015 Auto-Submitted: auto-generated Date: Fri, 17 Apr 2026 03:57:24 +0000 Message-Id: <69e1afa4.2788c.3b1f88bb@gitrepo.freebsd.org> The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=51d2c38010824b90d7462711896a88165db9d015 commit 51d2c38010824b90d7462711896a88165db9d015 Author: Kyle Evans AuthorDate: 2026-04-17 03:57:06 +0000 Commit: Kyle Evans CommitDate: 2026-04-17 03:57:06 +0000 tests: kqueue: improve diagnostics for our CPONFORK test Notably, confirm in the child that our close-on-fork fd is actually closed, and break RECV_ALL out into a table and check each bit individually to provide a better message when the test fails. While we're here, just switch to waitid() rather than trying to identify the point where we have to make the switch. This reduces maintenance slightly, as keeping our assertion static would require still adding to a _RECV_ALL mask *just* for that purpose. Reviewed by: kib, markj (both slightly earlier version) Differential Revision: https://reviews.freebsd.org/D56372 --- tests/sys/kqueue/kqueue_fork.c | 71 +++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/tests/sys/kqueue/kqueue_fork.c b/tests/sys/kqueue/kqueue_fork.c index 6f517a2e0e29..ad8f69056e07 100644 --- a/tests/sys/kqueue/kqueue_fork.c +++ b/tests/sys/kqueue/kqueue_fork.c @@ -92,21 +92,68 @@ ATF_TC_BODY(shared_table_filt_sig, tc) #define RECV_VNODE 0x02 #define RECV_CLOREAD 0x04 #define RECV_ERROR 0x80 -#define RECV_ALL (RECV_TIMER | RECV_VNODE) + +static const struct cponfork_recv { + const char *recv_error_desc; + unsigned int recv_bit; + bool recv_parent_only; +} cponfork_recv[] = { + { "EVFILT_TIMER did not fire", RECV_TIMER, false }, + { "EVFILT_VNODE expected with creation of canary", RECV_VNODE, false }, + { "EVFILT_READ received for fd closed on fork", RECV_CLOREAD, true }, +}; + +static void +cponfork_notes_mask_check(unsigned int mask, bool childmask) +{ + const struct cponfork_recv *rcv; + unsigned int expect; + + ATF_REQUIRE(mask != RECV_ERROR); + for (size_t i = 0; i < nitems(cponfork_recv); i++) { + rcv = &cponfork_recv[i]; + + expect = childmask && rcv->recv_parent_only ? 0 : rcv->recv_bit; + ATF_REQUIRE_EQ_MSG(expect, mask & rcv->recv_bit, + "%s (%s, mask %x)", rcv->recv_error_desc, + childmask ? "child" : "parent", + mask); + } +} + +static unsigned int +cponfork_notes_mask(bool inchild) +{ + const struct cponfork_recv *rcv; + unsigned int mask = 0; + + for (size_t i = 0; i < nitems(cponfork_recv); i++) { + rcv = &cponfork_recv[i]; + + if (!inchild || !rcv->recv_parent_only) + mask |= rcv->recv_bit; + } + + ATF_REQUIRE(mask != 0); + return (mask); +} static int cponfork_notes_check(int kq, int clofd) { struct kevent ev; + unsigned int mask; int error, received = 0; + mask = cponfork_notes_mask(true); + EV_SET(&ev, TIMER_TIMEOUT, EVFILT_TIMER, EV_ADD | EV_ENABLE | EV_ONESHOT, NOTE_SECONDS, 4, NULL); error = kevent(kq, &ev, 1, NULL, 0, NULL); if (error == -1) return (RECV_ERROR); - while ((received & RECV_ALL) != RECV_ALL) { + while ((received & mask) != mask) { error = kevent(kq, NULL, 0, &ev, 1, NULL); if (error < 0) return (RECV_ERROR); @@ -138,7 +185,8 @@ ATF_TC_WITHOUT_HEAD(cponfork_notes); ATF_TC_BODY(cponfork_notes, tc) { struct kevent ev[3]; - int clofd, dfd, error, kq, pdfd, pmask, status; + siginfo_t info; + int clofd, dfd, error, kq, pdfd, pmask; pid_t pid; kq = kqueuex(KQUEUE_CPONFORK); @@ -164,8 +212,8 @@ ATF_TC_BODY(cponfork_notes, tc) /* * Every event we setup here we should expect to observe in both the * child and the parent, with exception to the EVFILT_READ of clofd. We - * except that one to be dropped in the child when the kqueue it's - * attached to goes away, thus its exclusion from the RECV_ALL mask. + * expect that one to be dropped in the child when the kqueue it's + * attached to goes away, thus its exclusion from the child mask. */ EV_SET(&ev[0], dfd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_ONESHOT, NOTE_WRITE, 0, NULL); @@ -195,6 +243,9 @@ ATF_TC_BODY(cponfork_notes, tc) else if (kf.kf_type != KF_TYPE_KQUEUE) _exit(RECV_ERROR); + if (fcntl(clofd, F_KINFO, &kf) != -1 || errno != EBADF) + _exit(RECV_ERROR); + _exit(cponfork_notes_check(kq, clofd)); } @@ -209,15 +260,13 @@ ATF_TC_BODY(cponfork_notes, tc) * still fire twice (once in parent, once in child). */ pmask = cponfork_notes_check(kq, clofd); - ATF_REQUIRE_EQ(pmask, RECV_ALL | RECV_CLOREAD); + cponfork_notes_mask_check(pmask, false); /* Wait for the child to timeout or observe the timer. */ - _Static_assert(RECV_ALL <= UCHAR_MAX, - "Too many events to observe -- switch from waitpid -> waitid"); - error = waitpid(pid, &status, 0); + error = waitid(P_PID, pid, &info, WEXITED); ATF_REQUIRE(error != -1); - ATF_REQUIRE(WIFEXITED(status)); - ATF_REQUIRE_EQ(WEXITSTATUS(status), RECV_ALL); + ATF_REQUIRE_EQ(CLD_EXITED, info.si_code); + cponfork_notes_mask_check(info.si_status, true); } ATF_TP_ADD_TCS(tp)