From nobody Mon May 20 09:35:05 2024 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 4VjXV2032Yz5KZ4L; Mon, 20 May 2024 09:35:06 +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 4VjXV15mWxz4tMx; Mon, 20 May 2024 09:35:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716197705; 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=VSIE3yzHQvXkshHz0eDF3TRkv8Gw8FFtlxp6ZE8yBeI=; b=hvAMLTZZTOWdVTYkkwXRr6xtmqElwEUjpk87AGqIPo4CoauxwK4S0BJjFH4ZRut0ABJaDB psmc9de6e8bT66VP1/H3lUDbNkeoyko34QFGxmKXNICaqH0HwF+Boq6NsBtAq1hhETsI5U /il/2TPtTmETEtFFddJt8gaWOuju9q9IaHWYdz2HYFfvoPbz1O8popL4dCpaBjFpOGVqO4 CHRjrtbzXM081LMU540W4kGkLkfHvDo0toVPgRNiCUktnwjcrAqAiTSatb4DuyA747JFRw 6d6Z4mzAOCu8knN41zYGjdF7HghkfM8OeDGT50OqMWLcobmBYitC4Xr15+h13Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716197705; a=rsa-sha256; cv=none; b=lm+4B8P3a5sGRl7zMBMwWWz4/K+mRJCSme8tWAROYOQqNoXBAb4WAm8dXRqeygr7SugG0U O/fwl/5wllhfvJ7sDBCV6TkZQvvP0AWQssJXl2PkazMj4P/O3Fi3sV+QWMqkgZQ+WGWVm2 SRKsFMYJndHyO5j1DcTCw52r7tu08vNvbraWX492wGYTA2nndAvzOmPOOMkktkk3YMDMb5 wunhozp804eZ5PTKFB+uLL+CuixdQo94EdW5ms0w55RgxZ5cf7yTDQ3HKvGi2QX0DQMIBg G26H8XawZlbKhvN9VA1EjDidJ1RSjj0hizTy7/RvbDOeLwU1WWDIyF1v8zqQuQ== 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=1716197705; 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=VSIE3yzHQvXkshHz0eDF3TRkv8Gw8FFtlxp6ZE8yBeI=; b=Ul6Wpn/u6S52dLk/QY6xAkyeDVfTs54IDBhNW5sxkG22NWv2UfIoRe/4RzwpkpxThGrJJq 40Ja3tQdDTxEWASPXNvtoQzPIrsxR5h8oTsSYWbhDOPzeG3jWblcrjsaM75fLuZFKOwQ54 LrVU84Ai7lo9iGbVO1yrAFudS3c4GA+N/DTayWtDkbEAxyDMfwa0tQYWRcMQiCQcMm9znj EHyIcVW+QqgFjaD70adMys9fE+r+3z6JgBgZLEesMZLOajhBwbqyTPnVyXdNqWq9IaqUQc wGeNiIPeGIPs/eTWW6Z/UKgCNV4EUjsGIV9Bet6f/mMS18UPMmxySYRyGznJ6g== 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 4VjXV15MQVzYXq; Mon, 20 May 2024 09:35:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44K9Z5lf039737; Mon, 20 May 2024 09:35:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44K9Z5PY039734; Mon, 20 May 2024 09:35:05 GMT (envelope-from git) Date: Mon, 20 May 2024 09:35:05 GMT Message-Id: <202405200935.44K9Z5PY039734@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: fe623d689bd7 - stable/13 - Import atf 0.22 snapshot 55c21b2c5fb189bbdfccb2b297bfa89236502542 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: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fe623d689bd7dc3bb6f5418e53fac454999e8dce Auto-Submitted: auto-generated The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=fe623d689bd7dc3bb6f5418e53fac454999e8dce commit fe623d689bd7dc3bb6f5418e53fac454999e8dce Author: Alan Somers AuthorDate: 2021-09-10 23:08:42 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-05-20 09:04:59 +0000 Import atf 0.22 snapshot 55c21b2c5fb189bbdfccb2b297bfa89236502542 The main improvement is the ability to skip a test that is expected to fail. (cherry picked from commit 71a1ae7cebd3791d4d18ac9620a7a4ce8cf15819) --- contrib/atf/atf-c/atf-c.3 | 27 ++++++++++++++++++++++----- contrib/atf/atf-c/macros.h | 19 +++++++++++++++++++ contrib/atf/atf-c/tc.c | 12 +++--------- contrib/atf/atf-sh/atf-check.cpp | 4 ++-- contrib/atf/atf-sh/atf-sh.3 | 12 ++++++------ 5 files changed, 52 insertions(+), 22 deletions(-) diff --git a/contrib/atf/atf-c/atf-c.3 b/contrib/atf/atf-c/atf-c.3 index d7aa8c382dff..c38e068bb380 100644 --- a/contrib/atf/atf-c/atf-c.3 +++ b/contrib/atf/atf-c/atf-c.3 @@ -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 April 5, 2017 +.Dd February 23, 2021 .Dt ATF-C 3 .Os .Sh NAME @@ -35,6 +35,8 @@ .Nm ATF_CHECK_MATCH_MSG , .Nm ATF_CHECK_STREQ , .Nm ATF_CHECK_STREQ_MSG , +.Nm ATF_CHECK_INTEQ , +.Nm ATF_CHECK_INTEQ_MSG , .Nm ATF_CHECK_ERRNO , .Nm ATF_REQUIRE , .Nm ATF_REQUIRE_MSG , @@ -44,6 +46,8 @@ .Nm ATF_REQUIRE_MATCH_MSG , .Nm ATF_REQUIRE_STREQ , .Nm ATF_REQUIRE_STREQ_MSG , +.Nm ATF_REQUIRE_INTEQ , +.Nm ATF_REQUIRE_INTEQ_MSG , .Nm ATF_REQUIRE_ERRNO , .Nm ATF_TC , .Nm ATF_TC_BODY , @@ -96,8 +100,10 @@ .Fn ATF_CHECK_EQ_MSG "expected_expression" "actual_expression" "fail_msg_fmt" ... .Fn ATF_CHECK_MATCH "regexp" "string" .Fn ATF_CHECK_MATCH_MSG "regexp" "string" "fail_msg_fmt" ... -.Fn ATF_CHECK_STREQ "string_1" "string_2" -.Fn ATF_CHECK_STREQ_MSG "string_1" "string_2" "fail_msg_fmt" ... +.Fn ATF_CHECK_STREQ "expected_string" "actual_string" +.Fn ATF_CHECK_STREQ_MSG "expected_string" "actual_string" "fail_msg_fmt" ... +.Fn ATF_CHECK_INTEQ "expected_int" "actual_int" +.Fn ATF_CHECK_INTEQ_MSG "expected_int" "actual_int" "fail_msg_fmt" ... .Fn ATF_CHECK_ERRNO "expected_errno" "bool_expression" .Fn ATF_REQUIRE "expression" .Fn ATF_REQUIRE_MSG "expression" "fail_msg_fmt" ... @@ -107,6 +113,8 @@ .Fn ATF_REQUIRE_MATCH_MSG "regexp" "string" "fail_msg_fmt" ... .Fn ATF_REQUIRE_STREQ "expected_string" "actual_string" .Fn ATF_REQUIRE_STREQ_MSG "expected_string" "actual_string" "fail_msg_fmt" ... +.Fn ATF_REQUIRE_INTEQ "expected_int" "actual_int" +.Fn ATF_REQUIRE_INTEQ_MSG "expected_int" "actual_int" "fail_msg_fmt" ... .Fn ATF_REQUIRE_ERRNO "expected_errno" "bool_expression" .\" NO_CHECK_STYLE_END .Fn ATF_TC "name" @@ -494,7 +502,7 @@ and .Fn ATF_REQUIRE_EQ_MSG take two expressions and fail if the two evaluated values are not equal. The common style is to put the expected value in the first parameter and the -actual value in the second parameter. +observed value in the second parameter. .Pp .Fn ATF_CHECK_MATCH , .Fn ATF_CHECK_MATCH_MSG , @@ -513,7 +521,16 @@ and .Fn ATF_REQUIRE_STREQ_MSG take two strings and fail if the two are not equal character by character. The common style is to put the expected string in the first parameter and the -actual string in the second parameter. +observed string in the second parameter. +.Pp +.Fn ATF_CHECK_INTEQ , +.Fn ATF_CHECK_INTEQ_MSG , +.Fn ATF_REQUIRE_INTEQ +and +.Fn ATF_REQUIRE_INTQ_MSG +take two integers and fail if the two are not equal. +The common style is to put the expected integer in the first parameter and the +observed integer in the second parameter. .Pp .Fn ATF_CHECK_ERRNO and diff --git a/contrib/atf/atf-c/macros.h b/contrib/atf/atf-c/macros.h index 485a159acecb..1784fc47435d 100644 --- a/contrib/atf/atf-c/macros.h +++ b/contrib/atf/atf-c/macros.h @@ -185,6 +185,25 @@ "%s != %s (%s != %s): " fmt, \ #expected, #actual, expected, actual, ##__VA_ARGS__) +#define ATF_REQUIRE_INTEQ(expected, actual) \ + ATF_REQUIRE_MSG((expected) == (actual), "%s != %s (%jd != %jd)", \ + #expected, #actual, (intmax_t)(expected), \ + (intmax_t)(actual)) + +#define ATF_CHECK_INTEQ(expected, actual) \ + ATF_CHECK_MSG((expected) == (actual), "%s != %s (%jd != %jd)", #expected, \ + #actual, (intmax_t)(expected), (intmax_t)(actual)) + +#define ATF_REQUIRE_INTEQ_MSG(expected, actual, fmt, ...) \ + ATF_REQUIRE_MSG((expected) == (actual), "%s != %s (%jd != %jd): " fmt, \ + #expected, #actual, (intmax_t)(expected), \ + (intmax_t)(actual), ##__VA_ARGS__) + +#define ATF_CHECK_INTEQ_MSG(expected, actual, fmt, ...) \ + ATF_CHECK_MSG((expected) == (actual), "%s != %s (%jd != %jd): " fmt, \ + #expected, #actual, (intmax_t)(expected), \ + (intmax_t)(actual), ##__VA_ARGS__) + #define ATF_REQUIRE_MATCH(regexp, string) \ ATF_REQUIRE_MSG(atf_utils_grep_string("%s", string, regexp), \ "'%s' not matched in '%s'", regexp, string); diff --git a/contrib/atf/atf-c/tc.c b/contrib/atf/atf-c/tc.c index 69b31123f3a3..84a8beb4fa13 100644 --- a/contrib/atf/atf-c/tc.c +++ b/contrib/atf/atf-c/tc.c @@ -381,15 +381,9 @@ pass(struct context *ctx) static void skip(struct context *ctx, atf_dynstr_t *reason) { - if (ctx->expect == EXPECT_PASS) { - create_resfile(ctx, "skipped", -1, reason); - context_close_resfile(ctx); - exit(EXIT_SUCCESS); - } else { - error_in_expect(ctx, "Can only skip a test case when running in " - "expect pass mode"); - } - UNREACHABLE; + create_resfile(ctx, "skipped", -1, reason); + context_close_resfile(ctx); + exit(EXIT_SUCCESS); } /** Formats a failure/skip reason message. diff --git a/contrib/atf/atf-sh/atf-check.cpp b/contrib/atf/atf-sh/atf-check.cpp index 38ab527aab54..4cb1e33a005a 100644 --- a/contrib/atf/atf-sh/atf-check.cpp +++ b/contrib/atf/atf-sh/atf-check.cpp @@ -501,7 +501,7 @@ compare_files(const atf::fs::path& p1, const atf::fs::path& p2) std::ifstream f2(p2.c_str()); if (!f2) - throw std::runtime_error("Failed to open " + p1.str()); + throw std::runtime_error("Failed to open " + p2.str()); for (;;) { char buf1[512], buf2[512]; @@ -512,7 +512,7 @@ compare_files(const atf::fs::path& p1, const atf::fs::path& p2) f2.read(buf2, sizeof(buf2)); if (f2.bad()) - throw std::runtime_error("Failed to read from " + p1.str()); + throw std::runtime_error("Failed to read from " + p2.str()); if ((f1.gcount() == 0) && (f2.gcount() == 0)) { equal = true; diff --git a/contrib/atf/atf-sh/atf-sh.3 b/contrib/atf/atf-sh/atf-sh.3 index 5d1119b2b5dc..c3080c296826 100644 --- a/contrib/atf/atf-sh/atf-sh.3 +++ b/contrib/atf/atf-sh/atf-sh.3 @@ -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 June 08, 2017 +.Dd January 27, 2021 .Dt ATF-SH 3 .Os .Sh NAME @@ -361,21 +361,21 @@ This example demonstrates the use of the very useful function: .Bd -literal -offset indent # Check for silent output -atf_check -s exit:0 -o empty -e empty 'true' +atf_check -s exit:0 -o empty -e empty true # Check for silent output and failure -atf_check -s exit:1 -o empty -e empty 'false' +atf_check -s exit:1 -o empty -e empty false # Check for known stdout and silent stderr echo foo >expout -atf_check -s exit:0 -o file:expout -e empty 'echo foo' +atf_check -s exit:0 -o file:expout -e empty echo foo # Generate a file for later inspection -atf_check -s exit:0 -o save:stdout -e empty 'ls' +atf_check -s exit:0 -o save:stdout -e empty ls grep foo ls || atf_fail "foo file not found in listing" # Or just do the match along the way -atf_check -s exit:0 -o match:"^foo$" -e empty 'ls' +atf_check -s exit:0 -o match:"^foo$" -e empty ls .Ed .Sh SEE ALSO .Xr atf-check 1 ,