From nobody Wed Nov 11 20:36:14 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 4jPwKB5cmcz6xlqY for ; Wed, 11 Nov 2026 20:36:14 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jPwKB2mT8z4Q3T for ; Wed, 11 Nov 2026 20:36:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794429374; 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=oKyi2Os824jl7mEEqj+r/wWOfupscjPcrui1VNlw4wI=; b=O2mYXNyH6wuj63RluPH4s5C0QPqpr2e4nfCUqwcYsm965r4ax+u5vpOt5chhKXiAno2pOn Exg9fzbJ0E7LlLBwb4e2d8d92plMqSMOotdSeTM95xHIldQlf0EtD+v4NccIhk+G0OHRlA MCaJzmTC7KBICy7jI0Up+ByWUsnsvAEZqjVpEkJKQIGKV5hL5jkFcdQkM5T8CGaIEv6Xf1 OEioTdlubH8DFRHY9HpvRr24BLXPS4H8EPm/gg95aaYrhLl+rwv6J+Vs+TWSvm2TTywUTq KStnDwPfUQtl2RkK3dlFmNqH/RTQJgBCUJhyvKpSJEp1qmAJRrL0zIZ94Curew== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794429374; b=pXO2z1/SHXHb9/I/aOskYGnza+fbqu/CrxHi3TRQRp70y6hdqr7+KYfowmKaeanmqdm3dT 79xGJnRU160/KNtnz80ESRflkk+HQXDohwtJRBm5oAhlBgO+lxZ844pRhnOjAm1iHPnQCQ n/xHfPRI2sUiKk54ZV5Il1w+ruq1D5Xpf7qySwWexOxy2EjvR/V3KkxgQkfBB0Xe/def/h yFfSIU5b70sHVvwY4thMGHmykteKK5f6BFgfdXRXl1Q9K/qjtQy9BkrOl8KD8iYB1w6UYn hyI7jZEEY1T0VM5DeImaYmcMPvSDlOrHPnkYfgPVMUItjxBY1Cxo6qHyzT9wmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794429374; 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=oKyi2Os824jl7mEEqj+r/wWOfupscjPcrui1VNlw4wI=; b=S63I1mquJiYOqriTolG3Pdyue4/J0/XddnVtrUuWXRoCNuMz2T4GloBsUK2onKradpJiuv vyM+pyxRVFHGRnu/K3KID5bGraLeDNMHe3tS2qYtQ1nT5MYTOqkWDM+KnEKDMfkHo5rY+i uSiSZ4EMAR55O/weGXcPDPN+fewQFxDHxri9kJ6Pl0KcoDpzUD9hXwbKg3NKEyZnZHji1L EWQUuFxPGdgysmkQwy/M60Z4Fa5YZCK0uDJ8G7dGx3sMGAusOMVZiBaA2drYQdcaM1/b2W jzzkvM1XRGzNA23SkxktofqNliJZVo54pIyRZg4+oqm4ir36luuy7av7cWCe8A== 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 4jPwKB29dXzVn3 for ; Wed, 11 Nov 2026 20:36:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id e700 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 11 Nov 2026 20:36:14 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 76797b9b6ed4 - main - atf-check: Add shortcut for not-exit:0 List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 76797b9b6ed4f2fe4ebb08fede0f19a88f985494 Auto-Submitted: auto-generated Date: Wed, 11 Nov 2026 20:36:14 +0000 Message-Id: <6af4d1be.e700.7b5b38d4@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=76797b9b6ed4f2fe4ebb08fede0f19a88f985494 commit 76797b9b6ed4f2fe4ebb08fede0f19a88f985494 Author: Dag-Erling Smørgrav AuthorDate: 2026-11-11 20:35:44 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-11 20:35:44 +0000 atf-check: Add shortcut for not-exit:0 Allow the command to be preceded by an exclamation point, which changes the default expected result to a clean exit with a non-zero exit code. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: ngie Differential Revision: https://reviews.freebsd.org/D58099 --- contrib/atf/atf-sh/atf-check.1 | 18 ++++++++++++++++-- contrib/atf/atf-sh/atf-check.cpp | 10 +++++++++- contrib/atf/atf-sh/atf-check_test.sh | 6 ++++++ contrib/atf/atf-sh/atf_check_test.sh | 12 ++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/contrib/atf/atf-sh/atf-check.1 b/contrib/atf/atf-sh/atf-check.1 index 18d000a8750c..8c4fb94f5c11 100644 --- a/contrib/atf/atf-sh/atf-check.1 +++ b/contrib/atf/atf-sh/atf-check.1 @@ -22,7 +22,7 @@ .\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.Dd August 13, 2026 +.Dd September 24, 2026 .Dt ATF-CHECK 1 .Os .Sh NAME @@ -35,6 +35,7 @@ .Op Fl e Ar action:arg ... .Op Fl x .Op Fl r Ar timeout[:interval] +.Op \&! .Ar command .Sh DESCRIPTION .Nm @@ -60,6 +61,19 @@ acts as if it was run with .Ar empty .Fl e .Ar empty . +If +.Ar command +is preceded by +.Sq \&! , +it will default to +.Fl s +.Ar not-exit:0 +instead of +.Fl s +.Ar exit:0 . +Multiple checks for the same output channel are allowed and, if specified, +their results will be combined as a logical and (meaning that the output must +match all the provided checks). .Pp .Fl o .Ar empty @@ -159,7 +173,7 @@ directly: atf_check true # Typical usage if failure is expected -atf_check -s not-exit:0 false +atf_check ! false # Checking stdout/stderr echo foobar >expout diff --git a/contrib/atf/atf-sh/atf-check.cpp b/contrib/atf/atf-sh/atf-check.cpp index 819ff7e9c82b..67d2b479c710 100644 --- a/contrib/atf/atf-sh/atf-check.cpp +++ b/contrib/atf/atf-sh/atf-check.cpp @@ -910,13 +910,21 @@ atf_check::process_option(int ch, const char* arg) int atf_check::main(void) { + bool negate = false; + + while (m_argc > 0 && strcmp(m_argv[0], "!") == 0) { + negate = !negate; + m_argc--; + m_argv++; + } + if (m_argc < 1) throw atf::application::usage_error("No command specified"); int status = EXIT_FAILURE; if (m_status_checks.empty()) { - m_status_checks.push_back(status_check(sc_exit, false, EXIT_SUCCESS, + m_status_checks.push_back(status_check(sc_exit, negate, EXIT_SUCCESS, false)); } else if (m_status_checks.size() > 1) { // TODO: Remove this restriction. diff --git a/contrib/atf/atf-sh/atf-check_test.sh b/contrib/atf/atf-sh/atf-check_test.sh index 3d2e78438640..11f622ea8316 100644 --- a/contrib/atf/atf-sh/atf-check_test.sh +++ b/contrib/atf/atf-sh/atf-check_test.sh @@ -90,11 +90,17 @@ sflag_exit_body() h_pass 'false' -s not-exit:0 h_pass 'exit 255' -s exit:255 h_pass 'exit 0' -s not-exit:255 + h_pass 'false' ! + h_pass 'true' ! ! + h_pass 'false' ! ! ! h_fail 'exit 256' -s exit:256 h_fail 'exit -1' -s exit:-1 h_fail 'true' -s not-exit:256 h_fail 'true' -s not-exit:-1 + h_fail 'true' ! + h_fail 'false' ! ! + h_fail 'true' ! ! ! h_pass 'true' -s exit h_pass 'false' -s exit diff --git a/contrib/atf/atf-sh/atf_check_test.sh b/contrib/atf/atf-sh/atf_check_test.sh index 6fe2bb775274..3495473f83fd 100644 --- a/contrib/atf/atf-sh/atf_check_test.sh +++ b/contrib/atf/atf-sh/atf_check_test.sh @@ -207,6 +207,17 @@ flush_stdout_on_death_body() || atf_fail 'Second command not in output' } +atf_test_case negate +negate_body() +{ + atf_check true + atf_check ! false + atf_check ! ! true + atf_check ! ! ! false + atf_check true ! + atf_check -o inline:'!\n' echo ! +} + atf_init_test_cases() { atf_add_test_case info_ok @@ -216,6 +227,7 @@ atf_init_test_cases() atf_add_test_case null_stderr atf_add_test_case equal atf_add_test_case flush_stdout_on_death + atf_add_test_case negate } # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4