Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Mar 2021 12:00:23 GMT
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 133bc645077d - main - Convert the msun tests to ATF
Message-ID:  <202103221200.12MC0NYE055062@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=133bc645077d77ddb3c7d49130b4ec6fd93e7d34

commit 133bc645077d77ddb3c7d49130b4ec6fd93e7d34
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2021-03-22 11:15:13 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2021-03-22 11:55:06 +0000

    Convert the msun tests to ATF
    
    This provides better error messages that just an assertion failure and
    also makes it easier to mark individual tests as XFAIL.
    It was also helpful when coming up with D28786 and D28787.
    
    Differential Revision: https://reviews.freebsd.org/D28798
---
 lib/msun/tests/Makefile           |  36 +++--
 lib/msun/tests/cexp_test.c        |  80 ++++------
 lib/msun/tests/conj_test.c        |  85 +++++------
 lib/msun/tests/csqrt_test.c       |  79 +++++-----
 lib/msun/tests/ctrig_test.c       |   2 -
 lib/msun/tests/exponential_test.c |  84 ++++++-----
 lib/msun/tests/fenv_test.c        | 298 ++++++++++++++++++--------------------
 lib/msun/tests/fma_test.c         |  96 ++++++------
 lib/msun/tests/fmaxmin_test.c     | 176 ++++++++++++++--------
 lib/msun/tests/ilogb_test.c       |  70 +++++----
 lib/msun/tests/invctrig_test.c    |  68 ++++-----
 lib/msun/tests/invtrig_test.c     |  85 ++++-------
 lib/msun/tests/logarithm_test.c   |  85 ++++-------
 lib/msun/tests/lrint_test.c       |  49 +++----
 lib/msun/tests/lround_test.c      |  49 ++++---
 lib/msun/tests/lround_test.t      |  10 --
 lib/msun/tests/nan_test.c         |  53 +++----
 lib/msun/tests/nearbyint_test.c   |  72 +++++----
 lib/msun/tests/next_test.c        |  86 +++++++----
 lib/msun/tests/rem_test.c         | 109 +++++++-------
 lib/msun/tests/test-utils.h       |  11 ++
 lib/msun/tests/trig_test.c        |   8 +-
 22 files changed, 845 insertions(+), 846 deletions(-)

diff --git a/lib/msun/tests/Makefile b/lib/msun/tests/Makefile
index 85a558bb0733..309f49c6dddd 100644
--- a/lib/msun/tests/Makefile
+++ b/lib/msun/tests/Makefile
@@ -52,30 +52,28 @@ NETBSD_ATF_TESTS_C+=	sqrt_test
 NETBSD_ATF_TESTS_C+=	tan_test
 NETBSD_ATF_TESTS_C+=	tanh_test
 
-TAP_TESTS_C+=	cexp_test
-TAP_TESTS_C+=	conj_test
+ATF_TESTS_C+=	cexp_test
+ATF_TESTS_C+=	conj_test
 .if ${MACHINE_CPUARCH} != "aarch64"
 # Hits an assert in llvm when building for arm64:
 # https://llvm.org/bugs/show_bug.cgi?id=26081
-TAP_TESTS_C+=	csqrt_test
+ATF_TESTS_C+=	csqrt_test
 .endif
 ATF_TESTS_C+=	ctrig_test
-TAP_TESTS_C+=	exponential_test
-TAP_TESTS_C+=	fenv_test
-TAP_TESTS_C+=	fma_test
-TAP_TESTS_C+=	fmaxmin_test
-TAP_TESTS_C+=	ilogb2_test
-TAP_TESTS_C+=	invtrig_test
-TAP_TESTS_C+=	invctrig_test
-TAP_TESTS_C+=	logarithm_test
-TAP_TESTS_C+=	lrint_test
-# XXX: the testcase crashes on all platforms, but only on head
-# (bug 205451)
-#TAP_TESTS_C+=	lround_test
-TAP_TESTS_C+=	nan_test
-TAP_TESTS_C+=	nearbyint_test
-TAP_TESTS_C+=	next_test
-TAP_TESTS_C+=	rem_test
+ATF_TESTS_C+=	exponential_test
+ATF_TESTS_C+=	fenv_test
+ATF_TESTS_C+=	fma_test
+ATF_TESTS_C+=	fmaxmin_test
+ATF_TESTS_C+=	ilogb2_test
+ATF_TESTS_C+=	invtrig_test
+ATF_TESTS_C+=	invctrig_test
+ATF_TESTS_C+=	logarithm_test
+ATF_TESTS_C+=	lrint_test
+ATF_TESTS_C+=	lround_test
+ATF_TESTS_C+=	nan_test
+ATF_TESTS_C+=	nearbyint_test
+ATF_TESTS_C+=	next_test
+ATF_TESTS_C+=	rem_test
 ATF_TESTS_C+=	trig_test
 
 .if !empty(PROG) && !empty(TAP_TESTS_C:M${PROG})
diff --git a/lib/msun/tests/cexp_test.c b/lib/msun/tests/cexp_test.c
index 8e342f8e0070..3a0f5dc39a5e 100644
--- a/lib/msun/tests/cexp_test.c
+++ b/lib/msun/tests/cexp_test.c
@@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 
-#include <assert.h>
 #include <complex.h>
 #include <fenv.h>
 #include <float.h>
@@ -63,9 +62,10 @@ __FBSDID("$FreeBSD$");
 do {									\
 	volatile long double complex _d = z;				\
 	volatile type complex _r = result;				\
-	assert(feclearexcept(FE_ALL_EXCEPT) == 0);			\
-	assert(cfpequal_cs((func)(_d), (_r), (checksign)));		\
-	assert(((void)(func), fetestexcept(exceptmask) == (excepts)));	\
+	ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));		\
+	ATF_CHECK(cfpequal_cs((func)(_d), (_r), (checksign)));		\
+	CHECK_FP_EXCEPTIONS_MSG(excepts, exceptmask, "for %s(%s)",	\
+	    #func, #z);							\
 } while (0)
 
 #define	test(func, z, result, exceptmask, excepts, checksign)		\
@@ -77,7 +77,7 @@ do {									\
 /* Test within a given tolerance. */
 #define	test_tol(func, z, result, tol)				do {	\
 	volatile long double complex _d = z;				\
-	assert(cfpequal_tol((func)(_d), (result), (tol),		\
+	ATF_CHECK(cfpequal_tol((func)(_d), (result), (tol),		\
 	    FPE_ABS_ZERO | CS_BOTH));					\
 } while (0)
 
@@ -102,8 +102,8 @@ static const float finites[] =
 
 
 /* Tests for 0 */
-static void
-test_zero(void)
+ATF_TC_WITHOUT_HEAD(zero);
+ATF_TC_BODY(zero, tc)
 {
 
 	/* cexp(0) = 1, no exceptions raised */
@@ -117,15 +117,14 @@ test_zero(void)
  * Tests for NaN.  The signs of the results are indeterminate unless the
  * imaginary part is 0.
  */
-static void
-test_nan(void)
+ATF_TC_WITHOUT_HEAD(nan);
+ATF_TC_BODY(nan, tc)
 {
 	unsigned i;
 
 	/* cexp(x + NaNi) = NaN + NaNi and optionally raises invalid */
 	/* cexp(NaN + yi) = NaN + NaNi and optionally raises invalid (|y|>0) */
 	for (i = 0; i < nitems(finites); i++) {
-		printf("# Run %d..\n", i);
 		testall(CMPLXL(finites[i], NAN), CMPLXL(NAN, NAN),
 			ALL_STD_EXCEPT & ~FE_INVALID, 0, 0);
 		if (finites[i] == 0.0)
@@ -150,14 +149,13 @@ test_nan(void)
 		ALL_STD_EXCEPT, 0, 0);
 }
 
-static void
-test_inf(void)
+ATF_TC_WITHOUT_HEAD(inf);
+ATF_TC_BODY(inf, tc)
 {
 	unsigned i;
 
 	/* cexp(x + inf i) = NaN + NaNi and raises invalid */
 	for (i = 0; i < nitems(finites); i++) {
-		printf("# Run %d..\n", i);
 		testall(CMPLXL(finites[i], INFINITY), CMPLXL(NAN, NAN),
 			ALL_STD_EXCEPT, FE_INVALID, 1);
 	}
@@ -192,14 +190,13 @@ test_inf(void)
 		ALL_STD_EXCEPT, 0, 1);
 }
 
-static void
-test_reals(void)
+ATF_TC_WITHOUT_HEAD(reals);
+ATF_TC_BODY(reals, tc)
 {
 	unsigned i;
 
 	for (i = 0; i < nitems(finites); i++) {
 		/* XXX could check exceptions more meticulously */
-		printf("# Run %d..\n", i);
 		test(cexp, CMPLXL(finites[i], 0.0),
 		     CMPLXL(exp(finites[i]), 0.0),
 		     FE_INVALID | FE_DIVBYZERO, 0, 1);
@@ -215,13 +212,12 @@ test_reals(void)
 	}
 }
 
-static void
-test_imaginaries(void)
+ATF_TC_WITHOUT_HEAD(imaginaries);
+ATF_TC_BODY(imaginaries, tc)
 {
 	unsigned i;
 
 	for (i = 0; i < nitems(finites); i++) {
-		printf("# Run %d..\n", i);
 		test(cexp, CMPLXL(0.0, finites[i]),
 		     CMPLXL(cos(finites[i]), sin(finites[i])),
 		     ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
@@ -237,8 +233,8 @@ test_imaginaries(void)
 	}
 }
 
-static void
-test_small(void)
+ATF_TC_WITHOUT_HEAD(small);
+ATF_TC_BODY(small, tc)
 {
 	static const double tests[] = {
 	     /* csqrt(a + bI) = x + yI */
@@ -253,7 +249,6 @@ test_small(void)
 	unsigned i;
 
 	for (i = 0; i < nitems(tests); i += 4) {
-		printf("# Run %d..\n", i);
 		a = tests[i];
 		b = tests[i + 1];
 		x = tests[i + 2];
@@ -268,8 +263,8 @@ test_small(void)
 }
 
 /* Test inputs with a real part r that would overflow exp(r). */
-static void
-test_large(void)
+ATF_TC_WITHOUT_HEAD(large);
+ATF_TC_BODY(large, tc)
 {
 
 	test_tol(cexp, CMPLXL(709.79, 0x1p-1074),
@@ -295,32 +290,15 @@ test_large(void)
 		 CMPLXL(INFINITY, 5.7878851079e+37f), 2 * FLT_ULP());
 }
 
-int
-main(void)
+ATF_TP_ADD_TCS(tp)
 {
-
-	printf("1..7\n");
-
-	test_zero();
-	printf("ok 1 - cexp zero\n");
-
-	test_nan();
-	printf("ok 2 - cexp nan\n");
-
-	test_inf();
-	printf("ok 3 - cexp inf\n");
-
-	test_reals();
-	printf("ok 4 - cexp reals\n");
-
-	test_imaginaries();
-	printf("ok 5 - cexp imaginaries\n");
-
-	test_small();
-	printf("ok 6 - cexp small\n");
-
-	test_large();
-	printf("ok 7 - cexp large\n");
-
-	return (0);
+	ATF_TP_ADD_TC(tp, zero);
+	ATF_TP_ADD_TC(tp, nan);
+	ATF_TP_ADD_TC(tp, inf);
+	ATF_TP_ADD_TC(tp, reals);
+	ATF_TP_ADD_TC(tp, imaginaries);
+	ATF_TP_ADD_TC(tp, small);
+	ATF_TP_ADD_TC(tp, large);
+
+	return (atf_no_error());
 }
diff --git a/lib/msun/tests/conj_test.c b/lib/msun/tests/conj_test.c
index 960fed5074b5..5e9868939277 100644
--- a/lib/msun/tests/conj_test.c
+++ b/lib/msun/tests/conj_test.c
@@ -31,7 +31,6 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include <assert.h>
 #include <complex.h>
 #include <fenv.h>
 #include <math.h>
@@ -70,70 +69,54 @@ static const double tests[] = {
 	-INFINITY, INFINITY,
 };
 
-int
-main(void)
+ATF_TC_WITHOUT_HEAD(main);
+ATF_TC_BODY(main, tc)
 {
 	static const int ntests = sizeof(tests) / sizeof(tests[0]) / 2;
 	complex float in;
 	complex long double expected;
 	int i;
 
-	printf("1..%d\n", ntests * 3);
-
 	for (i = 0; i < ntests; i++) {
 		__real__ expected = __real__ in = tests[2 * i];
 		__imag__ in = tests[2 * i + 1];
 		__imag__ expected = -cimag(in);
 
-		assert(fpequal(libcrealf(in), __real__ in));
-		assert(fpequal(libcreal(in), __real__ in));
-		assert(fpequal(libcreall(in), __real__ in));
-		assert(fpequal(libcimagf(in), __imag__ in));
-		assert(fpequal(libcimag(in), __imag__ in));
-		assert(fpequal(libcimagl(in), __imag__ in));
+		ATF_REQUIRE(fpequal(libcrealf(in), __real__ in));
+		ATF_REQUIRE(fpequal(libcreal(in), __real__ in));
+		ATF_REQUIRE(fpequal(libcreall(in), __real__ in));
+		ATF_REQUIRE(fpequal(libcimagf(in), __imag__ in));
+		ATF_REQUIRE(fpequal(libcimag(in), __imag__ in));
+		ATF_REQUIRE(fpequal(libcimagl(in), __imag__ in));
 
-		feclearexcept(FE_ALL_EXCEPT);
-		if (!cfpequal(libconjf(in), expected)) {
-			printf("not ok %d\t# conjf(%#.2g + %#.2gI): "
-			       "wrong value\n",
-			       3 * i + 1, creal(in), cimag(in));
-		} else if (fetestexcept(FE_ALL_EXCEPT)) {
-			printf("not ok %d\t# conjf(%#.2g + %#.2gI): "
-			       "threw an exception\n",
-			       3 * i + 1, creal(in), cimag(in));
-		} else {
-			printf("ok %d\t\t# conjf(%#.2g + %#.2gI)\n",
-			       3 * i + 1, creal(in), cimag(in));
-		}
+		ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
+		ATF_REQUIRE_MSG(
+		    cfpequal(libconjf(in), expected),
+		    "conjf(%#.2g + %#.2gI): wrong value", creal(in), cimag(in)
+		);
+		ATF_REQUIRE_EQ_MSG(0, fetestexcept(FE_ALL_EXCEPT),
+		    "conj(%#.2g + %#.2gI): threw an exception: %#x", creal(in),
+		    cimag(in), fetestexcept(FE_ALL_EXCEPT));
 
-		feclearexcept(FE_ALL_EXCEPT);
-		if (!cfpequal(libconj(in), expected)) {
-			printf("not ok %d\t# conj(%#.2g + %#.2gI): "
-			       "wrong value\n",
-			       3 * i + 2, creal(in), cimag(in));
-		} else if (fetestexcept(FE_ALL_EXCEPT)) {
-			printf("not ok %d\t# conj(%#.2g + %#.2gI): "
-			       "threw an exception\n",
-			       3 * i + 2, creal(in), cimag(in));
-		} else {
-			printf("ok %d\t\t# conj(%#.2g + %#.2gI)\n",
-			       3 * i + 2, creal(in), cimag(in));
-		}
+		ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
+		ATF_REQUIRE_MSG(cfpequal(libconj(in), expected),
+		    "conj(%#.2g + %#.2gI): wrong value", creal(in), cimag(in));
+		ATF_REQUIRE_EQ_MSG(0, fetestexcept(FE_ALL_EXCEPT),
+		    "conj(%#.2g + %#.2gI): threw an exception: %#x", creal(in),
+		    cimag(in), fetestexcept(FE_ALL_EXCEPT));
 
-		feclearexcept(FE_ALL_EXCEPT);
-		if (!cfpequal(libconjl(in), expected)) {
-			printf("not ok %d\t# conjl(%#.2g + %#.2gI): "
-			       "wrong value\n",
-			       3 * i + 3, creal(in), cimag(in));
-		} else if (fetestexcept(FE_ALL_EXCEPT)) {
-			printf("not ok %d\t# conjl(%#.2g + %#.2gI): "
-			       "threw an exception\n",
-			       3 * i + 3, creal(in), cimag(in));
-		} else {
-			printf("ok %d\t\t# conjl(%#.2g + %#.2gI)\n",
-			       3 * i + 3, creal(in), cimag(in));
-		}
+		ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
+		ATF_REQUIRE_MSG(cfpequal(libconjl(in), expected),
+		    "conjl(%#.2g + %#.2gI): wrong value", creal(in), cimag(in));
+		ATF_REQUIRE_EQ_MSG(0, fetestexcept(FE_ALL_EXCEPT),
+		    "conjl(%#.2g + %#.2gI): threw an exception: %#x", creal(in),
+		    cimag(in), fetestexcept(FE_ALL_EXCEPT));
 	}
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+	ATF_TP_ADD_TC(tp, main);
 
-	return (0);
+	return (atf_no_error());
 }
diff --git a/lib/msun/tests/csqrt_test.c b/lib/msun/tests/csqrt_test.c
index 9f596ed67596..a84605a379de 100644
--- a/lib/msun/tests/csqrt_test.c
+++ b/lib/msun/tests/csqrt_test.c
@@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 
-#include <assert.h>
 #include <complex.h>
 #include <float.h>
 #include <math.h>
@@ -72,7 +71,7 @@ static void
 assert_equal(long double complex d1, long double complex d2)
 {
 
-	assert(cfpequal(d1, d2));
+	ATF_CHECK(cfpequal(d1, d2));
 }
 
 /*
@@ -133,7 +132,7 @@ test_finite(void)
 			b = tests[i + 1] * mults[j] * mults[j];
 			x = tests[i + 2] * mults[j];
 			y = tests[i + 3] * mults[j];
-			assert(t_csqrt(CMPLXL(a, b)) == CMPLXL(x, y));
+			ATF_CHECK(t_csqrt(CMPLXL(a, b)) == CMPLXL(x, y));
 		}
 	}
 
@@ -190,11 +189,11 @@ static void
 test_nans(void)
 {
 
-	assert(creall(t_csqrt(CMPLXL(INFINITY, NAN))) == INFINITY);
-	assert(isnan(cimagl(t_csqrt(CMPLXL(INFINITY, NAN)))));
+	ATF_CHECK(creall(t_csqrt(CMPLXL(INFINITY, NAN))) == INFINITY);
+	ATF_CHECK(isnan(cimagl(t_csqrt(CMPLXL(INFINITY, NAN)))));
 
-	assert(isnan(creall(t_csqrt(CMPLXL(-INFINITY, NAN)))));
-	assert(isinf(cimagl(t_csqrt(CMPLXL(-INFINITY, NAN)))));
+	ATF_CHECK(isnan(creall(t_csqrt(CMPLXL(-INFINITY, NAN)))));
+	ATF_CHECK(isinf(cimagl(t_csqrt(CMPLXL(-INFINITY, NAN)))));
 
 	assert_equal(t_csqrt(CMPLXL(NAN, INFINITY)),
 		     CMPLXL(INFINITY, INFINITY));
@@ -224,7 +223,7 @@ test_overflow(int maxexp)
 	long double complex result;
 	int exp, i;
 
-	assert(maxexp > 0 && maxexp % 2 == 0);
+	ATF_CHECK(maxexp > 0 && maxexp % 2 == 0);
 
 	for (i = 0; i < 4; i++) {
 		exp = maxexp - 2 * i;
@@ -233,22 +232,22 @@ test_overflow(int maxexp)
 		a = ldexpl(115 * 0x1p-8, exp);
 		b = ldexpl(252 * 0x1p-8, exp);
 		result = t_csqrt(CMPLXL(a, b));
-		assert(creall(result) == ldexpl(14 * 0x1p-4, exp / 2));
-		assert(cimagl(result) == ldexpl(9 * 0x1p-4, exp / 2));
+		ATF_CHECK_EQ(creall(result), ldexpl(14 * 0x1p-4, exp / 2));
+		ATF_CHECK_EQ(cimagl(result), ldexpl(9 * 0x1p-4, exp / 2));
 
 		/* csqrt(-11 + 60*I) = 5 + 6*I */
 		a = ldexpl(-11 * 0x1p-6, exp);
 		b = ldexpl(60 * 0x1p-6, exp);
 		result = t_csqrt(CMPLXL(a, b));
-		assert(creall(result) == ldexpl(5 * 0x1p-3, exp / 2));
-		assert(cimagl(result) == ldexpl(6 * 0x1p-3, exp / 2));
+		ATF_CHECK_EQ(creall(result), ldexpl(5 * 0x1p-3, exp / 2));
+		ATF_CHECK_EQ(cimagl(result), ldexpl(6 * 0x1p-3, exp / 2));
 
 		/* csqrt(225 + 0*I) == 15 + 0*I */
 		a = ldexpl(225 * 0x1p-8, exp);
 		b = 0;
 		result = t_csqrt(CMPLXL(a, b));
-		assert(creall(result) == ldexpl(15 * 0x1p-4, exp / 2));
-		assert(cimagl(result) == 0);
+		ATF_CHECK_EQ(creall(result), ldexpl(15 * 0x1p-4, exp / 2));
+		ATF_CHECK_EQ(cimagl(result), 0);
 	}
 }
 
@@ -266,8 +265,8 @@ test_precision(int maxexp, int mantdig)
 	uint64_t mantbits, sq_mantbits;
 	int exp, i;
 
-	assert(maxexp > 0 && maxexp % 2 == 0);
-	assert(mantdig <= 64);
+	ATF_CHECK(maxexp > 0 && maxexp % 2 == 0);
+	ATF_CHECK(mantdig <= 64);
 	mantdig = rounddown(mantdig, 2);
 
 	for (exp = 0; exp <= maxexp; exp += 2) {
@@ -289,79 +288,67 @@ test_precision(int maxexp, int mantdig)
 			b = ldexpl((long double)sq_mantbits,
 			    exp - 1 - mantdig);
 			x = ldexpl(mantbits, (exp - 2 - mantdig) / 2);
-			assert(b == x * x * 2);
+			ATF_CHECK_EQ(b, x * x * 2);
 			result = t_csqrt(CMPLXL(0, b));
-			assert(creall(result) == x);
-			assert(cimagl(result) == x);
+			ATF_CHECK_EQ(x, creall(result));
+			ATF_CHECK_EQ(x, cimagl(result));
 		}
 	}
 }
 
-int
-main(void)
+ATF_TC_WITHOUT_HEAD(csqrt);
+ATF_TC_BODY(csqrt, tc)
 {
-
-	printf("1..18\n");
-
 	/* Test csqrt() */
 	t_csqrt = _csqrt;
 
 	test_finite();
-	printf("ok 1 - csqrt\n");
 
 	test_zeros();
-	printf("ok 2 - csqrt\n");
 
 	test_infinities();
-	printf("ok 3 - csqrt\n");
 
 	test_nans();
-	printf("ok 4 - csqrt\n");
 
 	test_overflow(DBL_MAX_EXP);
-	printf("ok 5 - csqrt\n");
 
 	test_precision(DBL_MAX_EXP, DBL_MANT_DIG);
-	printf("ok 6 - csqrt\n");
+}
 
+ATF_TC_WITHOUT_HEAD(csqrtf);
+ATF_TC_BODY(csqrtf, tc)
+{
 	/* Now test csqrtf() */
 	t_csqrt = _csqrtf;
 
 	test_finite();
-	printf("ok 7 - csqrt\n");
 
 	test_zeros();
-	printf("ok 8 - csqrt\n");
 
 	test_infinities();
-	printf("ok 9 - csqrt\n");
 
 	test_nans();
-	printf("ok 10 - csqrt\n");
 
 	test_overflow(FLT_MAX_EXP);
-	printf("ok 11 - csqrt\n");
 
 	test_precision(FLT_MAX_EXP, FLT_MANT_DIG);
-	printf("ok 12 - csqrt\n");
+}
 
+ATF_TC_WITHOUT_HEAD(csqrtl);
+ATF_TC_BODY(csqrtl, tc)
+{
 	/* Now test csqrtl() */
 	t_csqrt = csqrtl;
 
 	test_finite();
-	printf("ok 13 - csqrt\n");
 
 	test_zeros();
-	printf("ok 14 - csqrt\n");
 
 	test_infinities();
-	printf("ok 15 - csqrt\n");
 
 	test_nans();
-	printf("ok 16 - csqrt\n");
 
 	test_overflow(LDBL_MAX_EXP);
-	printf("ok 17 - csqrt\n");
 
 	test_precision(LDBL_MAX_EXP,
 #ifndef __i386__
@@ -370,7 +357,13 @@ main(void)
 	    DBL_MANT_DIG
 #endif
 	    );
-	printf("ok 18 - csqrt\n");
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+	ATF_TP_ADD_TC(tp, csqrt);
+	ATF_TP_ADD_TC(tp, csqrtf);
+	ATF_TP_ADD_TC(tp, csqrtl);
 
-	return (0);
+	return (atf_no_error());
 }
diff --git a/lib/msun/tests/ctrig_test.c b/lib/msun/tests/ctrig_test.c
index 2499e53ab4d5..f3951c575ceb 100644
--- a/lib/msun/tests/ctrig_test.c
+++ b/lib/msun/tests/ctrig_test.c
@@ -38,8 +38,6 @@ __FBSDID("$FreeBSD$");
 #include <math.h>
 #include <stdio.h>
 
-#include <atf-c.h>
-
 #include "test-utils.h"
 
 #pragma STDC FENV_ACCESS	ON
diff --git a/lib/msun/tests/exponential_test.c b/lib/msun/tests/exponential_test.c
index 5b39d29fa5bf..14cedf8f9190 100644
--- a/lib/msun/tests/exponential_test.c
+++ b/lib/msun/tests/exponential_test.c
@@ -31,7 +31,6 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include <assert.h>
 #include <fenv.h>
 #include <float.h>
 #include <math.h>
@@ -60,9 +59,10 @@ __FBSDID("$FreeBSD$");
  */
 #define	test(func, x, result, exceptmask, excepts)	do {		\
 	volatile long double _d = x;					\
-	assert(feclearexcept(FE_ALL_EXCEPT) == 0);			\
-	assert(fpequal((func)(_d), (result)));				 \
-	assert(((void)(func), fetestexcept(exceptmask) == (excepts)));	\
+	ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));		\
+	ATF_CHECK(fpequal((func)(_d), (result)));			\
+	CHECK_FP_EXCEPTIONS_MSG(excepts, exceptmask, "for %s(%s)",	\
+	    #func, #x);							\
 } while (0)
 
 /* Test all the functions that compute b^x. */
@@ -122,48 +122,66 @@ run_generic_tests(void)
 	testall1(-50000.0, -1.0, ALL_STD_EXCEPT, FE_INEXACT);
 }
 
-static void
-run_exp2_tests(void)
+
+/*
+ * We should insist that exp2() return exactly the correct
+ * result and not raise an inexact exception for integer
+ * arguments.
+ */
+ATF_TC_WITHOUT_HEAD(exp2f);
+ATF_TC_BODY(exp2f, tc)
 {
-	unsigned i;
-
-	/*
-	 * We should insist that exp2() return exactly the correct
-	 * result and not raise an inexact exception for integer
-	 * arguments.
-	 */
-	feclearexcept(FE_ALL_EXCEPT);
-	for (i = FLT_MIN_EXP - FLT_MANT_DIG; i < FLT_MAX_EXP; i++) {
-		assert(exp2f(i) == ldexpf(1.0, i));
-		assert(fetestexcept(ALL_STD_EXCEPT) == 0);
-	}
-	for (i = DBL_MIN_EXP - DBL_MANT_DIG; i < DBL_MAX_EXP; i++) {
-		assert(exp2(i) == ldexp(1.0, i));
-		assert(fetestexcept(ALL_STD_EXCEPT) == 0);
-	}
-	for (i = LDBL_MIN_EXP - LDBL_MANT_DIG; i < LDBL_MAX_EXP; i++) {
-		assert(exp2l(i) == ldexpl(1.0, i));
-		assert(fetestexcept(ALL_STD_EXCEPT) == 0);
+	ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
+	for (int i = FLT_MIN_EXP - FLT_MANT_DIG; i < FLT_MAX_EXP; i++) {
+		ATF_CHECK_EQ(exp2f(i), ldexpf(1.0, i));
+		CHECK_FP_EXCEPTIONS(0, ALL_STD_EXCEPT);
 	}
 }
 
-int
-main(void)
+ATF_TC_WITHOUT_HEAD(exp2);
+ATF_TC_BODY(exp2, tc)
 {
+	ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
+	for (int i = DBL_MIN_EXP - DBL_MANT_DIG; i < DBL_MAX_EXP; i++) {
+		ATF_CHECK_EQ(exp2(i), ldexp(1.0, i));
+		CHECK_FP_EXCEPTIONS(0, ALL_STD_EXCEPT);
+	}
+}
 
-	printf("1..3\n");
+ATF_TC_WITHOUT_HEAD(exp2l);
+ATF_TC_BODY(exp2l, tc)
+{
+	ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
+	for (int i = LDBL_MIN_EXP - LDBL_MANT_DIG; i < LDBL_MAX_EXP; i++) {
+		ATF_CHECK_EQ(exp2l(i), ldexpl(1.0, i));
+		CHECK_FP_EXCEPTIONS(0, ALL_STD_EXCEPT);
+	}
+}
 
+ATF_TC_WITHOUT_HEAD(generic);
+ATF_TC_BODY(generic, tc)
+{
 	run_generic_tests();
-	printf("ok 1 - exponential\n");
+}
 
 #ifdef __i386__
+ATF_TC_WITHOUT_HEAD(generic_fp_pe);
+ATF_TC_BODY(generic_fp_pe, tc)
+{
 	fpsetprec(FP_PE);
 	run_generic_tests();
+}
 #endif
-	printf("ok 2 - exponential\n");
 
-	run_exp2_tests();
-	printf("ok 3 - exponential\n");
+ATF_TP_ADD_TCS(tp)
+{
+	ATF_TP_ADD_TC(tp, generic);
+#ifdef __i386__
+	ATF_TP_ADD_TC(tp, generic_fp_pe);
+#endif
+	ATF_TP_ADD_TC(tp, exp2);
+	ATF_TP_ADD_TC(tp, exp2f);
+	ATF_TP_ADD_TC(tp, exp2l);
 
-	return (0);
+	return (atf_no_error());
 }
diff --git a/lib/msun/tests/fenv_test.c b/lib/msun/tests/fenv_test.c
index 62abfefb4a8a..b80b591cf52b 100644
--- a/lib/msun/tests/fenv_test.c
+++ b/lib/msun/tests/fenv_test.c
@@ -63,11 +63,14 @@ static int std_except_sets[1 << NEXCEPTS];
 /*
  * Initialize std_except_sets[] to the power set of std_excepts[]
  */
-static void
-init_exceptsets(void)
+static __attribute__((constructor)) void
+do_setup(void)
 {
 	unsigned i, j, sr;
 
+	/* Avoid double output after fork() */
+	setvbuf(stdout, NULL, _IONBF, 0);
+
 	for (i = 0; i < 1 << NEXCEPTS; i++) {
 		for (sr = i, j = 0; sr != 0; sr >>= 1, j++)
 			std_except_sets[i] |= std_excepts[j] & ((~sr & 1) - 1);
@@ -154,7 +157,7 @@ static void
 trap_handler(int sig)
 {
 
-	assert(sig == SIGFPE);
+	ATF_CHECK_EQ(SIGFPE, sig);
 	_exit(0);
 }
 
@@ -163,8 +166,8 @@ trap_handler(int sig)
  * The memcmp() test below may be too much to ask for, since there
  * could be multiple machine-specific default environments.
  */
-static void
-test_dfl_env(void)
+ATF_TC_WITHOUT_HEAD(dfl_env);
+ATF_TC_BODY(dfl_env, tc)
 {
 #ifndef NO_STRICT_DFL_ENV
 	fenv_t env;
@@ -186,52 +189,51 @@ test_dfl_env(void)
 	 * 1. http://support.amd.com/TechDocs/26569_APM_v5.pdf
 	 * 2. http://www.intel.com/Assets/en_US/PDF/manual/253666.pdf
 	 */
-	assert(memcmp(&env.__mxcsr, &FE_DFL_ENV->__mxcsr,
+	ATF_CHECK(memcmp(&env.__mxcsr, &FE_DFL_ENV->__mxcsr,
 	    sizeof(env.__mxcsr)) == 0);
-	assert(memcmp(&env.__x87.__control, &FE_DFL_ENV->__x87.__control,
+	ATF_CHECK(memcmp(&env.__x87.__control, &FE_DFL_ENV->__x87.__control,
 	    sizeof(env.__x87.__control)) == 0);
-	assert(memcmp(&env.__x87.__status, &FE_DFL_ENV->__x87.__status,
+	ATF_CHECK(memcmp(&env.__x87.__status, &FE_DFL_ENV->__x87.__status,
 	    sizeof(env.__x87.__status)) == 0);
-	assert(memcmp(&env.__x87.__tag, &FE_DFL_ENV->__x87.__tag,
+	ATF_CHECK(memcmp(&env.__x87.__tag, &FE_DFL_ENV->__x87.__tag,
 	    sizeof(env.__x87.__tag)) == 0);
 #else
-	assert(memcmp(&env, FE_DFL_ENV, sizeof(env)) == 0);
+	ATF_CHECK_EQ(0, memcmp(&env, FE_DFL_ENV, sizeof(env)));
 #endif
 
 #endif
-	assert(fetestexcept(FE_ALL_EXCEPT) == 0);
+	ATF_CHECK_EQ(0, fetestexcept(FE_ALL_EXCEPT));
 }
 
 /*
  * Test fetestexcept() and feclearexcept().
  */
-static void
-test_fetestclearexcept(void)
+ATF_TC_WITHOUT_HEAD(fetestclearexcept);
+ATF_TC_BODY(fetestclearexcept, tc)
 {
 	int excepts, i;
 
 	for (i = 0; i < 1 << NEXCEPTS; i++)
-		assert(fetestexcept(std_except_sets[i]) == 0);
+		ATF_CHECK_EQ(0, fetestexcept(std_except_sets[i]));
 	for (i = 0; i < 1 << NEXCEPTS; i++) {
 		excepts = std_except_sets[i];
 
 		/* FE_ALL_EXCEPT might be special-cased, as on i386. */
 		raiseexcept(excepts);
-		assert(fetestexcept(excepts) == excepts);
-		assert(feclearexcept(FE_ALL_EXCEPT) == 0);
-		assert(fetestexcept(FE_ALL_EXCEPT) == 0);
+		ATF_CHECK_EQ(excepts, fetestexcept(excepts));
+		ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
+		ATF_CHECK_EQ(0, fetestexcept(FE_ALL_EXCEPT));
 
 		raiseexcept(excepts);
-		assert(fetestexcept(excepts) == excepts);
+		ATF_CHECK_EQ(excepts, fetestexcept(excepts));
 		if ((excepts & (FE_UNDERFLOW | FE_OVERFLOW)) != 0) {
 			excepts |= FE_INEXACT;
-			assert((fetestexcept(ALL_STD_EXCEPT) | FE_INEXACT) ==
-			    excepts);
+			ATF_CHECK_EQ(excepts, (fetestexcept(ALL_STD_EXCEPT) | FE_INEXACT));
 		} else {
-			assert(fetestexcept(ALL_STD_EXCEPT) == excepts);
+			ATF_CHECK_EQ(excepts, fetestexcept(ALL_STD_EXCEPT));
 		}
-		assert(feclearexcept(excepts) == 0);
-		assert(fetestexcept(ALL_STD_EXCEPT) == 0);
+		ATF_CHECK_EQ(0, feclearexcept(excepts));
+		ATF_CHECK_EQ(0, fetestexcept(ALL_STD_EXCEPT));
 	}
 }
 
@@ -240,31 +242,29 @@ test_fetestclearexcept(void)
  *
  * Prerequisites: fetestexcept(), feclearexcept()
  */
-static void
-test_fegsetexceptflag(void)
+ATF_TC_WITHOUT_HEAD(fegsetexceptflag);
+ATF_TC_BODY(fegsetexceptflag, tc)
 {
 	fexcept_t flag;
 	int excepts, i;
 
-	assert(fetestexcept(FE_ALL_EXCEPT) == 0);
+	ATF_CHECK_EQ(0, fetestexcept(FE_ALL_EXCEPT));
 	for (i = 0; i < 1 << NEXCEPTS; i++) {
 		excepts = std_except_sets[i];
 
-		assert(fegetexceptflag(&flag, excepts) == 0);
+		ATF_CHECK_EQ(0, fegetexceptflag(&flag, excepts));
 		raiseexcept(ALL_STD_EXCEPT);
-		assert(fesetexceptflag(&flag, excepts) == 0);
-		assert(fetestexcept(ALL_STD_EXCEPT) ==
-		    (ALL_STD_EXCEPT ^ excepts));
-
-		assert(fegetexceptflag(&flag, FE_ALL_EXCEPT) == 0);
-		assert(feclearexcept(FE_ALL_EXCEPT) == 0);
-		assert(fesetexceptflag(&flag, excepts) == 0);
-		assert(fetestexcept(ALL_STD_EXCEPT) == 0);
-		assert(fesetexceptflag(&flag, ALL_STD_EXCEPT ^ excepts) == 0);
-		assert(fetestexcept(ALL_STD_EXCEPT) ==
-		    (ALL_STD_EXCEPT ^ excepts));
-
-		assert(feclearexcept(FE_ALL_EXCEPT) == 0);
+		ATF_CHECK_EQ(0, fesetexceptflag(&flag, excepts));
+		ATF_CHECK_EQ((ALL_STD_EXCEPT ^ excepts), fetestexcept(ALL_STD_EXCEPT));
+
+		ATF_CHECK_EQ(0, fegetexceptflag(&flag, FE_ALL_EXCEPT));
+		ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
+		ATF_CHECK_EQ(0, fesetexceptflag(&flag, excepts));
+		ATF_CHECK_EQ(0, fetestexcept(ALL_STD_EXCEPT));
+		ATF_CHECK_EQ(0, fesetexceptflag(&flag, ALL_STD_EXCEPT ^ excepts));
+		ATF_CHECK_EQ((ALL_STD_EXCEPT ^ excepts), fetestexcept(ALL_STD_EXCEPT));
+
+		ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
 	}
 }
 
@@ -273,63 +273,62 @@ test_fegsetexceptflag(void)
  *
  * Prerequisites: fetestexcept(), feclearexcept()
  */
-static void
-test_feraiseexcept(void)
+ATF_TC_WITHOUT_HEAD(feraiseexcept);
+ATF_TC_BODY(feraiseexcept, tc)
 {
 	int excepts, i;
 
 	for (i = 0; i < 1 << NEXCEPTS; i++) {
 		excepts = std_except_sets[i];
 
-		assert(fetestexcept(FE_ALL_EXCEPT) == 0);
-		assert(feraiseexcept(excepts) == 0);
+		ATF_CHECK_EQ(0, fetestexcept(FE_ALL_EXCEPT));
+		ATF_CHECK_EQ(0, feraiseexcept(excepts));
 		if ((excepts & (FE_UNDERFLOW | FE_OVERFLOW)) != 0) {
 			excepts |= FE_INEXACT;
-			assert((fetestexcept(ALL_STD_EXCEPT) | FE_INEXACT) ==
-			    excepts);
+			ATF_CHECK_EQ(excepts, (fetestexcept(ALL_STD_EXCEPT) | FE_INEXACT));
 		} else {
-			assert(fetestexcept(ALL_STD_EXCEPT) == excepts);
+			ATF_CHECK_EQ(excepts, fetestexcept(ALL_STD_EXCEPT));
 		}
-		assert(feclearexcept(FE_ALL_EXCEPT) == 0);
+		ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
 	}
-	assert(feraiseexcept(FE_INVALID | FE_DIVBYZERO) == 0);
-	assert(fetestexcept(ALL_STD_EXCEPT) == (FE_INVALID | FE_DIVBYZERO));
-	assert(feraiseexcept(FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) == 0);
-	assert(fetestexcept(ALL_STD_EXCEPT) == ALL_STD_EXCEPT);
-	assert(feclearexcept(FE_ALL_EXCEPT) == 0);
+	ATF_CHECK_EQ(0, feraiseexcept(FE_INVALID | FE_DIVBYZERO));
+	ATF_CHECK_EQ((FE_INVALID | FE_DIVBYZERO), fetestexcept(ALL_STD_EXCEPT));
+	ATF_CHECK_EQ(0, feraiseexcept(FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT));
+	ATF_CHECK_EQ(ALL_STD_EXCEPT, fetestexcept(ALL_STD_EXCEPT));
+	ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
 }
 
 /*
  * Test fegetround() and fesetround().
  */
-static void
-test_fegsetround(void)
+ATF_TC_WITHOUT_HEAD(fegsetround);
+ATF_TC_BODY(fegsetround, tc)
 {
 
-	assert(fegetround() == FE_TONEAREST);
-	assert(getround() == FE_TONEAREST);
-	assert(FLT_ROUNDS == 1);
+	ATF_CHECK_EQ(FE_TONEAREST, fegetround());
+	ATF_CHECK_EQ(FE_TONEAREST, getround());
+	ATF_CHECK_EQ(1, FLT_ROUNDS);
 
-	assert(fesetround(FE_DOWNWARD) == 0);
-	assert(fegetround() == FE_DOWNWARD);
-	assert(getround() == FE_DOWNWARD);
-	assert(FLT_ROUNDS == 3);
+	ATF_CHECK_EQ(0, fesetround(FE_DOWNWARD));
+	ATF_CHECK_EQ(FE_DOWNWARD, fegetround());
+	ATF_CHECK_EQ(FE_DOWNWARD, getround());
+	ATF_CHECK_EQ(3, FLT_ROUNDS);
 
-	assert(fesetround(FE_UPWARD) == 0);
-	assert(getround() == FE_UPWARD);
-	assert(fegetround() == FE_UPWARD);
-	assert(FLT_ROUNDS == 2);
+	ATF_CHECK_EQ(0, fesetround(FE_UPWARD));
+	ATF_CHECK_EQ(FE_UPWARD, getround());
+	ATF_CHECK_EQ(FE_UPWARD, fegetround());
+	ATF_CHECK_EQ(2, FLT_ROUNDS);
 
-	assert(fesetround(FE_TOWARDZERO) == 0);
-	assert(getround() == FE_TOWARDZERO);
-	assert(fegetround() == FE_TOWARDZERO);
-	assert(FLT_ROUNDS == 0);
+	ATF_CHECK_EQ(0, fesetround(FE_TOWARDZERO));
+	ATF_CHECK_EQ(FE_TOWARDZERO, getround());
+	ATF_CHECK_EQ(FE_TOWARDZERO, fegetround());
+	ATF_CHECK_EQ(0, FLT_ROUNDS);
 
-	assert(fesetround(FE_TONEAREST) == 0);
-	assert(getround() == FE_TONEAREST);
-	assert(FLT_ROUNDS == 1);
+	ATF_CHECK_EQ(0, fesetround(FE_TONEAREST));
+	ATF_CHECK_EQ(FE_TONEAREST, getround());
+	ATF_CHECK_EQ(1, FLT_ROUNDS);
 
*** 2135 LINES SKIPPED ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103221200.12MC0NYE055062>