From nobody Fri Apr 17 03:57:24 2026 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 4fxh0p0Jx9z6bGgH for ; Fri, 17 Apr 2026 03:57:30 +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 4fxh0n4n0Dz41qV for ; Fri, 17 Apr 2026 03:57:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776398249; 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=o0AwyofdG6T0fiVRq7qoyk7mAAtroIqMUdnZGDXBRFUTMqSyXK/MX5eK95ntJQQV+y1IbV UYOUmh89kqaJR5UCYv7SzJawhxbPJcN7F8ptX5r97egH3hrr8ZuW8YmDSdUXt7ECVwyreg /KrjAWc0AxenbapQZX/dw08doRjVr9Axqb4tULqWVhWgI9hKXVWpNxrEOFToiWToASk0tO njPRGa5bogl0Oy1FF5WmVIbSe0tWT9/KuEtGgqKPUCNwoysq+AhIIdMV49bh/jHP/r+FMf Gy/aaAc8eUfqu1xezzIZ4WBfDAvoQDbqrPGw/v36fhpigiFJ63s9SV+cuQ4OHw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776398249; a=rsa-sha256; cv=none; b=NGZSP080gCqaB9g17U5dlZBLn2T6YfhZZ3JvR3DFKoLN9YUbH78PaRxasVOE/QHosJ8I7s luoQgi4qb63eDIw0W6floKGBbLvnxwWXOj2jrvPbEffxb/obml+OWshrNB3lDPTXKQH4Ac mvXA90gMK5LR8+jpTGGCVFQtXT9nahTBufbxPkGMTt53WWNnTpwq4m2oHfdyXHLnIH/uo1 KkW04e3DUHr9Ktp5RDFSdGWt1dzWzkzyipbZCN7cTN7+dCer9R77kuwajAGlCdFf7GOsjo h2w7+iPiR+YVKwFjsFwIx2Kr1Tv/sBGEOlR21WXr+sx9js0DjPWiY0YSjNUizw== 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=1776398249; 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=O2294uO3vXCCI0vA5f8nXtJF7lEOYXNyCufGNWXR/pJwkvH7RIn8yz4SxgKrM7cXZeXieD f2JYpxpw45dLJwgSzqaMfdNiAvzcoN5HPtfOUUg3gZaS1LeG8HQrJJ+hLb0eW8gEacj+oI AycfOLbmcXLaZbiumTqVgPxHOrWr0TzKZyjposjmlsi2lbtHsrE6W5R6hlH425VsiCTuIl OgIJLm2M4sHywxc1jUPnJBZm3UytVLySj7+oY6IzIGG2tAfhVjl40f/Szl0z7mOo4dD9Wt XnwbffBad5Mry5WktK0QUmvzzOvP/mTrbHfil2Er6k9ijGOkv9zSFj0iqQrJpA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fxh0n3VjFzdK3 for ; Fri, 17 Apr 2026 03:57:29 +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 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: 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)