Convert lib/msun/ctrig_test from TAP to ATF

This is being done as a precursor for work needed to annontate failing
testcases with clang 4.0+.

MFC after:	1 week
PR:	217528
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Enji Cooper 2017-03-04 09:16:51 +00:00
parent 8042c504f5
commit 5c47281893
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=314649
2 changed files with 56 additions and 50 deletions

View File

@ -51,7 +51,7 @@ TAP_TESTS_C+= conj_test
# https://llvm.org/bugs/show_bug.cgi?id=26081
TAP_TESTS_C+= csqrt_test
.endif
TAP_TESTS_C+= ctrig_test
ATF_TESTS_C+= ctrig_test
TAP_TESTS_C+= exponential_test
TAP_TESTS_C+= fenv_test
TAP_TESTS_C+= fma_test

View File

@ -31,13 +31,14 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <assert.h>
#include <complex.h>
#include <fenv.h>
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <atf-c.h>
#include "test-utils.h"
#pragma STDC FENV_ACCESS ON
@ -60,9 +61,9 @@ __FBSDID("$FreeBSD$");
volatile long double complex _d = z; \
debug(" testing %s(%Lg + %Lg I) == %Lg + %Lg I\n", #func, \
creall(_d), cimagl(_d), creall(result), cimagl(result)); \
assert(feclearexcept(FE_ALL_EXCEPT) == 0); \
assert(cfpequal_cs((func)(_d), (result), (checksign))); \
assert(((void)(func), fetestexcept(exceptmask) == (excepts))); \
ATF_CHECK(feclearexcept(FE_ALL_EXCEPT) == 0); \
ATF_CHECK(cfpequal_cs((func)(_d), (result), (checksign))); \
ATF_CHECK(((void)(func), fetestexcept(exceptmask) == (excepts))); \
} while (0)
/*
@ -74,7 +75,7 @@ __FBSDID("$FreeBSD$");
volatile long double complex _d = z; \
debug(" testing %s(%Lg + %Lg I) ~= %Lg + %Lg I\n", #func, \
creall(_d), cimagl(_d), creall(result), cimagl(result)); \
assert(cfpequal_tol((func)(_d), (result), (tol), FPE_ABS_ZERO)); \
ATF_CHECK(cfpequal_tol((func)(_d), (result), (tol), FPE_ABS_ZERO)); \
} while (0)
/* These wrappers apply the identities f(conj(z)) = conj(f(z)). */
@ -127,9 +128,12 @@ __FBSDID("$FreeBSD$");
} while (0)
/* Tests for 0 */
void
test_zero(void)
ATF_TC(test_zero_input);
ATF_TC_HEAD(test_zero_input, tc)
{
atf_tc_set_md_var(tc, "descr", "test 0 input");
}
ATF_TC_BODY(test_zero_input, tc)
{
long double complex zero = CMPLXL(0.0, 0.0);
@ -142,11 +146,12 @@ test_zero(void)
testall_odd(ctan, zero, zero, ALL_STD_EXCEPT, 0, CS_BOTH);
}
/*
* Tests for NaN inputs.
*/
void
test_nan()
ATF_TC(test_nan_inputs);
ATF_TC_HEAD(test_nan_inputs, tc)
{
atf_tc_set_md_var(tc, "descr", "test NaN inputs");
}
ATF_TC_BODY(test_nan_inputs, tc)
{
long double complex nan_nan = CMPLXL(NAN, NAN);
long double complex z;
@ -222,8 +227,12 @@ test_nan()
testall_odd(ctan, z, nan_nan, OPT_INVALID, 0, 0);
}
void
test_inf(void)
ATF_TC(test_inf_inputs);
ATF_TC_HEAD(test_inf_inputs, tc)
{
atf_tc_set_md_var(tc, "descr", "test infinity inputs");
}
ATF_TC_BODY(test_inf_inputs, tc)
{
static const long double finites[] = {
0, M_PI / 4, 3 * M_PI / 4, 5 * M_PI / 4,
@ -287,9 +296,12 @@ test_inf(void)
testall_odd(ctan, z, CMPLXL(NAN, NAN), OPT_INEXACT, FE_INVALID, 0);
}
/* Tests along the real and imaginary axes. */
void
test_axes(void)
ATF_TC(test_axes);
ATF_TC_HEAD(test_axes, tc)
{
atf_tc_set_md_var(tc, "descr", "test along the real/imaginary axes");
}
ATF_TC_BODY(test_axes, tc)
{
static const long double nums[] = {
M_PI / 4, M_PI / 2, 3 * M_PI / 4,
@ -347,8 +359,12 @@ test_axes(void)
}
}
void
test_small(void)
ATF_TC(test_small_inputs);
ATF_TC_HEAD(test_small_inputs, tc)
{
atf_tc_set_md_var(tc, "descr", "test underflow inputs");
}
ATF_TC_BODY(test_small_inputs, tc)
{
/*
* z = 0.5 + i Pi/4
@ -409,12 +425,20 @@ test_small(void)
}
}
/* Test inputs that might cause overflow in a sloppy implementation. */
void
test_large(void)
ATF_TC(test_large_inputs);
ATF_TC_HEAD(test_large_inputs, tc)
{
atf_tc_set_md_var(tc, "descr",
"Test inputs that might cause overflow in a sloppy implementation");
}
ATF_TC_BODY(test_large_inputs, tc)
{
long double complex z;
#ifdef __i386__
atf_tc_expect_fail("test fails on i386 - bug 205446");
#endif
/* tanh() uses a threshold around x=22, so check both sides. */
z = CMPLXL(21, 0.78539816339744830961566084581987572L);
testall_odd_tol(ctanh, z,
@ -452,33 +476,15 @@ test_large(void)
FE_OVERFLOW, CS_BOTH);
}
int
main(int argc, char *argv[])
ATF_TP_ADD_TCS(tp)
{
printf("1..6\n");
ATF_TP_ADD_TC(tp, test_zero_input);
ATF_TP_ADD_TC(tp, test_nan_inputs);
ATF_TP_ADD_TC(tp, test_inf_inputs);
ATF_TP_ADD_TC(tp, test_axes);
ATF_TP_ADD_TC(tp, test_small_inputs);
ATF_TP_ADD_TC(tp, test_large_inputs);
test_zero();
printf("ok 1 - ctrig zero\n");
test_nan();
printf("ok 2 - ctrig nan\n");
test_inf();
printf("ok 3 - ctrig inf\n");
test_axes();
printf("ok 4 - ctrig axes\n");
test_small();
printf("ok 5 - ctrig small\n");
#if defined(__i386__)
printf("ok 6 # SKIP ctrig large # fails on i386 because of bug 205446\n");
#else
test_large();
printf("ok 6 - ctrig large\n");
#endif
return (0);
return (atf_no_error());
}