svn commit: r321452 - projects/runtime-coverage/lib/msun/tests
Ngie Cooper
ngie at FreeBSD.org
Tue Jul 25 03:41:06 UTC 2017
Author: ngie
Date: Tue Jul 25 03:41:05 2017
New Revision: 321452
URL: https://svnweb.freebsd.org/changeset/base/321452
Log:
Convert lib/msun/trig_test from TAP to ATF format
Only expose :accuracy and :reduction if !i386, similar to before,
but more holistically to avoid future -Wunused issue with the unused
functions.
MFC after: 1 month
Modified:
projects/runtime-coverage/lib/msun/tests/Makefile
projects/runtime-coverage/lib/msun/tests/trig_test.c
Modified: projects/runtime-coverage/lib/msun/tests/Makefile
==============================================================================
--- projects/runtime-coverage/lib/msun/tests/Makefile Tue Jul 25 03:33:39 2017 (r321451)
+++ projects/runtime-coverage/lib/msun/tests/Makefile Tue Jul 25 03:41:05 2017 (r321452)
@@ -68,7 +68,7 @@ TAP_TESTS_C+= nan_test
TAP_TESTS_C+= nearbyint_test
TAP_TESTS_C+= next_test
TAP_TESTS_C+= rem_test
-TAP_TESTS_C+= trig_test
+ATF_TESTS_C+= trig_test
.if !empty(PROG) && !empty(TAP_TESTS_C:M${PROG})
CFLAGS+= -O0
Modified: projects/runtime-coverage/lib/msun/tests/trig_test.c
==============================================================================
--- projects/runtime-coverage/lib/msun/tests/trig_test.c Tue Jul 25 03:33:39 2017 (r321451)
+++ projects/runtime-coverage/lib/msun/tests/trig_test.c Tue Jul 25 03:41:05 2017 (r321452)
@@ -44,6 +44,8 @@ __FBSDID("$FreeBSD$");
#include <math.h>
#include <stdio.h>
+#include <atf-c.h>
+
#include "test-utils.h"
#pragma STDC FENV_ACCESS ON
@@ -63,9 +65,9 @@ __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_CHECK(feclearexcept(FE_ALL_EXCEPT) == 0); \
+ ATF_CHECK(fpequal((func)(_d), (result))); \
+ ATF_CHECK(((void)(func), fetestexcept(exceptmask) == (excepts))); \
} while (0)
#define testall(prefix, x, result, exceptmask, excepts) do { \
@@ -79,13 +81,16 @@ __FBSDID("$FreeBSD$");
test(prefix##f, x, (float)result, exceptmask, excepts); \
} while (0)
-/*
- * Test special cases in sin(), cos(), and tan().
- */
-static void
-run_special_tests(void)
+ATF_TC(special);
+ATF_TC_HEAD(special, tc)
{
+ atf_tc_set_md_var(tc, "descr",
+ "test special cases in sin(), cos(), and tan()");
+}
+ATF_TC_BODY(special, tc)
+{
+
/* Values at 0 should be exact. */
testall(tan, 0.0, 0.0, ALL_STD_EXCEPT, 0);
testall(tan, -0.0, -0.0, ALL_STD_EXCEPT, 0);
@@ -108,12 +113,16 @@ run_special_tests(void)
testall(cos, NAN, NAN, ALL_STD_EXCEPT, 0);
}
-/*
- * Tests to ensure argument reduction for large arguments is accurate.
- */
-static void
-run_reduction_tests(void)
+#ifndef __i386__
+ATF_TC(reduction);
+ATF_TC_HEAD(reduction, tc)
{
+
+ atf_tc_set_md_var(tc, "descr",
+ "tests to ensure argument reduction for large arguments is accurate");
+}
+ATF_TC_BODY(reduction, tc)
+{
/* floats very close to odd multiples of pi */
static const float f_pi_odd[] = {
85563208.0f,
@@ -156,69 +165,72 @@ run_reduction_tests(void)
unsigned i;
for (i = 0; i < nitems(f_pi_odd); i++) {
- assert(fabs(sinf(f_pi_odd[i])) < FLT_EPSILON);
- assert(cosf(f_pi_odd[i]) == -1.0);
- assert(fabs(tan(f_pi_odd[i])) < FLT_EPSILON);
+ ATF_CHECK(fabs(sinf(f_pi_odd[i])) < FLT_EPSILON);
+ ATF_CHECK(cosf(f_pi_odd[i]) == -1.0);
+ ATF_CHECK(fabs(tan(f_pi_odd[i])) < FLT_EPSILON);
- assert(fabs(sinf(-f_pi_odd[i])) < FLT_EPSILON);
- assert(cosf(-f_pi_odd[i]) == -1.0);
- assert(fabs(tanf(-f_pi_odd[i])) < FLT_EPSILON);
+ ATF_CHECK(fabs(sinf(-f_pi_odd[i])) < FLT_EPSILON);
+ ATF_CHECK(cosf(-f_pi_odd[i]) == -1.0);
+ ATF_CHECK(fabs(tanf(-f_pi_odd[i])) < FLT_EPSILON);
- assert(fabs(sinf(f_pi_odd[i] * 2)) < FLT_EPSILON);
- assert(cosf(f_pi_odd[i] * 2) == 1.0);
- assert(fabs(tanf(f_pi_odd[i] * 2)) < FLT_EPSILON);
+ ATF_CHECK(fabs(sinf(f_pi_odd[i] * 2)) < FLT_EPSILON);
+ ATF_CHECK(cosf(f_pi_odd[i] * 2) == 1.0);
+ ATF_CHECK(fabs(tanf(f_pi_odd[i] * 2)) < FLT_EPSILON);
- assert(fabs(sinf(-f_pi_odd[i] * 2)) < FLT_EPSILON);
- assert(cosf(-f_pi_odd[i] * 2) == 1.0);
- assert(fabs(tanf(-f_pi_odd[i] * 2)) < FLT_EPSILON);
+ ATF_CHECK(fabs(sinf(-f_pi_odd[i] * 2)) < FLT_EPSILON);
+ ATF_CHECK(cosf(-f_pi_odd[i] * 2) == 1.0);
+ ATF_CHECK(fabs(tanf(-f_pi_odd[i] * 2)) < FLT_EPSILON);
}
for (i = 0; i < nitems(d_pi_odd); i++) {
- assert(fabs(sin(d_pi_odd[i])) < 2 * DBL_EPSILON);
- assert(cos(d_pi_odd[i]) == -1.0);
- assert(fabs(tan(d_pi_odd[i])) < 2 * DBL_EPSILON);
+ ATF_CHECK(fabs(sin(d_pi_odd[i])) < 2 * DBL_EPSILON);
+ ATF_CHECK(cos(d_pi_odd[i]) == -1.0);
+ ATF_CHECK(fabs(tan(d_pi_odd[i])) < 2 * DBL_EPSILON);
- assert(fabs(sin(-d_pi_odd[i])) < 2 * DBL_EPSILON);
- assert(cos(-d_pi_odd[i]) == -1.0);
- assert(fabs(tan(-d_pi_odd[i])) < 2 * DBL_EPSILON);
+ ATF_CHECK(fabs(sin(-d_pi_odd[i])) < 2 * DBL_EPSILON);
+ ATF_CHECK(cos(-d_pi_odd[i]) == -1.0);
+ ATF_CHECK(fabs(tan(-d_pi_odd[i])) < 2 * DBL_EPSILON);
- assert(fabs(sin(d_pi_odd[i] * 2)) < 2 * DBL_EPSILON);
- assert(cos(d_pi_odd[i] * 2) == 1.0);
- assert(fabs(tan(d_pi_odd[i] * 2)) < 2 * DBL_EPSILON);
+ ATF_CHECK(fabs(sin(d_pi_odd[i] * 2)) < 2 * DBL_EPSILON);
+ ATF_CHECK(cos(d_pi_odd[i] * 2) == 1.0);
+ ATF_CHECK(fabs(tan(d_pi_odd[i] * 2)) < 2 * DBL_EPSILON);
- assert(fabs(sin(-d_pi_odd[i] * 2)) < 2 * DBL_EPSILON);
- assert(cos(-d_pi_odd[i] * 2) == 1.0);
- assert(fabs(tan(-d_pi_odd[i] * 2)) < 2 * DBL_EPSILON);
+ ATF_CHECK(fabs(sin(-d_pi_odd[i] * 2)) < 2 * DBL_EPSILON);
+ ATF_CHECK(cos(-d_pi_odd[i] * 2) == 1.0);
+ ATF_CHECK(fabs(tan(-d_pi_odd[i] * 2)) < 2 * DBL_EPSILON);
}
#if LDBL_MANT_DIG > 53
for (i = 0; i < nitems(ld_pi_odd); i++) {
- assert(fabsl(sinl(ld_pi_odd[i])) < LDBL_EPSILON);
- assert(cosl(ld_pi_odd[i]) == -1.0);
- assert(fabsl(tanl(ld_pi_odd[i])) < LDBL_EPSILON);
+ ATF_CHECK(fabsl(sinl(ld_pi_odd[i])) < LDBL_EPSILON);
+ ATF_CHECK(cosl(ld_pi_odd[i]) == -1.0);
+ ATF_CHECK(fabsl(tanl(ld_pi_odd[i])) < LDBL_EPSILON);
- assert(fabsl(sinl(-ld_pi_odd[i])) < LDBL_EPSILON);
- assert(cosl(-ld_pi_odd[i]) == -1.0);
- assert(fabsl(tanl(-ld_pi_odd[i])) < LDBL_EPSILON);
+ ATF_CHECK(fabsl(sinl(-ld_pi_odd[i])) < LDBL_EPSILON);
+ ATF_CHECK(cosl(-ld_pi_odd[i]) == -1.0);
+ ATF_CHECK(fabsl(tanl(-ld_pi_odd[i])) < LDBL_EPSILON);
- assert(fabsl(sinl(ld_pi_odd[i] * 2)) < LDBL_EPSILON);
- assert(cosl(ld_pi_odd[i] * 2) == 1.0);
- assert(fabsl(tanl(ld_pi_odd[i] * 2)) < LDBL_EPSILON);
+ ATF_CHECK(fabsl(sinl(ld_pi_odd[i] * 2)) < LDBL_EPSILON);
+ ATF_CHECK(cosl(ld_pi_odd[i] * 2) == 1.0);
+ ATF_CHECK(fabsl(tanl(ld_pi_odd[i] * 2)) < LDBL_EPSILON);
- assert(fabsl(sinl(-ld_pi_odd[i] * 2)) < LDBL_EPSILON);
- assert(cosl(-ld_pi_odd[i] * 2) == 1.0);
- assert(fabsl(tanl(-ld_pi_odd[i] * 2)) < LDBL_EPSILON);
+ ATF_CHECK(fabsl(sinl(-ld_pi_odd[i] * 2)) < LDBL_EPSILON);
+ ATF_CHECK(cosl(-ld_pi_odd[i] * 2) == 1.0);
+ ATF_CHECK(fabsl(tanl(-ld_pi_odd[i] * 2)) < LDBL_EPSILON);
}
#endif
}
-/*
- * Tests the accuracy of these functions over the primary range.
- */
-static void
-run_accuracy_tests(void)
+ATF_TC(accuracy);
+ATF_TC_HEAD(accuracy, tc)
{
+ atf_tc_set_md_var(tc, "descr",
+ "tests the accuracy of these functions over the primary range");
+}
+ATF_TC_BODY(accuracy, tc)
+{
+
/* For small args, sin(x) = tan(x) = x, and cos(x) = 1. */
testall(sin, 0xd.50ee515fe4aea16p-114L, 0xd.50ee515fe4aea16p-114L,
ALL_STD_EXCEPT, FE_INEXACT);
@@ -256,25 +268,17 @@ run_accuracy_tests(void)
* - tests for large numbers that get reduced to hi+lo with lo!=0
*/
}
+#endif
-int
-main(void)
+ATF_TP_ADD_TCS(tp)
{
- printf("1..3\n");
+ ATF_TP_ADD_TC(tp, special);
- run_special_tests();
- printf("ok 1 - trig\n");
-
#ifndef __i386__
- run_reduction_tests();
+ ATF_TP_ADD_TC(tp, accuracy);
+ ATF_TP_ADD_TC(tp, reduction);
#endif
- printf("ok 2 - trig\n");
-#ifndef __i386__
- run_accuracy_tests();
-#endif
- printf("ok 3 - trig\n");
-
- return (0);
+ return (atf_no_error());
}
More information about the svn-src-projects
mailing list