aboutsummaryrefslogtreecommitdiff
path: root/atf-c
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2021-09-10 22:50:50 +0000
committerAlan Somers <asomers@FreeBSD.org>2021-09-10 22:50:50 +0000
commitcd355e3667c67b15d9850bacb416b13486e22c24 (patch)
tree9c47797123524e0a94d800711aed08cb35a83302 /atf-c
parenta3330ae736606c1812b9e9c4b9dcfdfb1a150dde (diff)
Diffstat (limited to 'atf-c')
-rw-r--r--atf-c/atf-c.327
-rw-r--r--atf-c/macros.h19
-rw-r--r--atf-c/tc.c12
3 files changed, 44 insertions, 14 deletions
diff --git a/atf-c/atf-c.3 b/atf-c/atf-c.3
index 2e0de174c9a9..2b5f07595865 100644
--- a/atf-c/atf-c.3
+++ b/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 October 13, 2014
+.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/atf-c/macros.h b/atf-c/macros.h
index 485a159acecb..1784fc47435d 100644
--- a/atf-c/macros.h
+++ b/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/atf-c/tc.c b/atf-c/tc.c
index 69b31123f3a3..84a8beb4fa13 100644
--- a/atf-c/tc.c
+++ b/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.