git: fe623d689bd7 - stable/13 - Import atf 0.22 snapshot 55c21b2c5fb189bbdfccb2b297bfa89236502542
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 20 May 2024 09:35:05 UTC
The branch stable/13 has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=fe623d689bd7dc3bb6f5418e53fac454999e8dce
commit fe623d689bd7dc3bb6f5418e53fac454999e8dce
Author: Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2021-09-10 23:08:42 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
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 ,