CVS commit: src/tests/lib/libm
Module Name:src Committed By: gson Date: Tue Aug 25 13:39:16 UTC 2020 Modified Files: src/tests/lib/libm: t_fmod.c Log Message: Only expect the fmod test case to fail when using qemu's TCG CPU emulation, and not under hardware virtualization such as qemu -accel nvmm. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_fmod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fmod.c diff -u src/tests/lib/libm/t_fmod.c:1.3 src/tests/lib/libm/t_fmod.c:1.4 --- src/tests/lib/libm/t_fmod.c:1.3 Sat Jan 3 14:23:53 2015 +++ src/tests/lib/libm/t_fmod.c Tue Aug 25 13:39:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fmod.c,v 1.3 2015/01/03 14:23:53 gson Exp $ */ +/* $NetBSD: t_fmod.c,v 1.4 2020/08/25 13:39:16 gson Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -43,7 +43,7 @@ ATF_TC_HEAD(fmod, tc) ATF_TC_BODY(fmod, tc) { - if (isQEMU()) + if (isQEMU_TCG()) atf_tc_expect_fail("PR misc/44767"); ATF_CHECK(fmodf(2.0, 1.0) == 0);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: lukem Date: Sun Jun 21 06:58:16 UTC 2020 Modified Files: src/tests/lib/libm: Makefile Log Message: fix build of t_cabsl from t_cabsl.cxx t_cabsl source is in t_cabsl.cxx not t_cabsl.cc - the latter is what bsd.tests.mk defaults to. This only broke after my commit of share/mk/bsd.dep.mk rev 1.85 but I don't know why it didn't cause a problem previously. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.46 src/tests/lib/libm/Makefile:1.47 --- src/tests/lib/libm/Makefile:1.46 Fri Apr 26 08:52:16 2019 +++ src/tests/lib/libm/Makefile Sun Jun 21 06:58:16 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.46 2019/04/26 08:52:16 maya Exp $ +# $NetBSD: Makefile,v 1.47 2020/06/21 06:58:16 lukem Exp $ .include @@ -46,6 +46,8 @@ TESTS_C+= t_tan TESTS_C+= t_tanh TESTS_CXX+= t_cabsl +SRCS.t_cabsl= t_cabsl.cxx + LDADD+= -lm #COPTS+= -Wfloat-equal
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Thu Apr 25 22:58:24 UTC 2019 Modified Files: src/tests/lib/libm: t_cos.c Log Message: Expand to cover long double somewhat. The given data is for double, so use DBL_EPSILON and don't expect better results. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_cos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_cos.c diff -u src/tests/lib/libm/t_cos.c:1.7 src/tests/lib/libm/t_cos.c:1.8 --- src/tests/lib/libm/t_cos.c:1.7 Sat Nov 10 23:04:16 2018 +++ src/tests/lib/libm/t_cos.c Thu Apr 25 22:58:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: t_cos.c,v 1.7 2018/11/10 23:04:16 riastradh Exp $ */ +/* $NetBSD: t_cos.c,v 1.8 2019/04/25 22:58:23 maya Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -60,6 +60,107 @@ static const struct { { 360, 6.283185307179586, 1., 999 }, }; +#ifdef __HAVE_LONG_DOUBLE +/* + * cosl(3) + */ +ATF_TC(cosl_angles); +ATF_TC_HEAD(cosl_angles, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test some selected angles"); +} + +ATF_TC_BODY(cosl_angles, tc) +{ + /* + * XXX The given data is for double, so take that + * into account and expect less precise results.. + */ + const long double eps = DBL_EPSILON; + size_t i; + + for (i = 0; i < __arraycount(angles); i++) { + int deg = angles[i].angle; + long double theta = angles[i].x; + long double cos_theta = angles[i].y; + + assert(cos_theta != 0); + if (!(fabsl((cosl(theta) - cos_theta)/cos_theta) <= eps)) { + atf_tc_fail_nonfatal("cos(%d deg = %.17Lg) = %.17Lg" + " != %.17Lg", + deg, theta, cosl(theta), cos_theta); + } + } +} + +ATF_TC(cosl_nan); +ATF_TC_HEAD(cosl_nan, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test cosl(NaN) == NaN"); +} + +ATF_TC_BODY(cosl_nan, tc) +{ + const long double x = 0.0L / 0.0L; + + ATF_CHECK(isnan(x) != 0); + ATF_CHECK(isnan(cosl(x)) != 0); +} + +ATF_TC(cosl_inf_neg); +ATF_TC_HEAD(cosl_inf_neg, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test cosl(-Inf) == NaN"); +} + +ATF_TC_BODY(cosl_inf_neg, tc) +{ + const long double x = -1.0L / 0.0L; + + ATF_CHECK(isnan(cosl(x)) != 0); +} + +ATF_TC(cosl_inf_pos); +ATF_TC_HEAD(cosl_inf_pos, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test cosl(+Inf) == NaN"); +} + +ATF_TC_BODY(cosl_inf_pos, tc) +{ + const long double x = 1.0L / 0.0L; + + ATF_CHECK(isnan(cosl(x)) != 0); +} + + +ATF_TC(cosl_zero_neg); +ATF_TC_HEAD(cosl_zero_neg, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test cosl(-0.0) == 1.0"); +} + +ATF_TC_BODY(cosl_zero_neg, tc) +{ + const long double x = -0.0L; + + ATF_CHECK(cosl(x) == 1.0); +} + +ATF_TC(cosl_zero_pos); +ATF_TC_HEAD(cosl_zero_pos, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test cosl(+0.0) == 1.0"); +} + +ATF_TC_BODY(cosl_zero_pos, tc) +{ + const long double x = 0.0L; + + ATF_CHECK(cosl(x) == 1.0); +} +#endif + /* * cos(3) */ @@ -260,6 +361,14 @@ ATF_TC_BODY(cosf_zero_pos, tc) ATF_TP_ADD_TCS(tp) { +#ifdef __HAVE_LONG_DOUBLE + ATF_TP_ADD_TC(tp, cosl_angles); + ATF_TP_ADD_TC(tp, cosl_nan); + ATF_TP_ADD_TC(tp, cosl_inf_neg); + ATF_TP_ADD_TC(tp, cosl_inf_pos); + ATF_TP_ADD_TC(tp, cosl_zero_neg); + ATF_TP_ADD_TC(tp, cosl_zero_pos); +#endif ATF_TP_ADD_TC(tp, cos_angles); ATF_TP_ADD_TC(tp, cos_nan);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Thu Nov 15 05:14:20 UTC 2018 Modified Files: src/tests/lib/libm: t_cbrt.c Log Message: cbrtl_powl is xfail only if long double has more bits than double. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_cbrt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_cbrt.c diff -u src/tests/lib/libm/t_cbrt.c:1.4 src/tests/lib/libm/t_cbrt.c:1.5 --- src/tests/lib/libm/t_cbrt.c:1.4 Wed Nov 7 03:59:36 2018 +++ src/tests/lib/libm/t_cbrt.c Thu Nov 15 05:14:20 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: t_cbrt.c,v 1.4 2018/11/07 03:59:36 riastradh Exp $ */ +/* $NetBSD: t_cbrt.c,v 1.5 2018/11/15 05:14:20 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_cbrt.c,v 1.4 2018/11/07 03:59:36 riastradh Exp $"); +__RCSID("$NetBSD: t_cbrt.c,v 1.5 2018/11/15 05:14:20 riastradh Exp $"); #include #include @@ -285,7 +285,9 @@ ATF_TC_BODY(cbrtl_powl, tc) const long double eps = 2*LDBL_EPSILON; size_t i; +#if LDBL_MANT_DIG > DBL_MANT_DIG atf_tc_expect_fail("powl not yet implemented with full precision"); +#endif for (i = 0; i < __arraycount(x); i++) { long double x_cbrt = cbrtl(x[i]); long double x_pow13 = powl(x[i], 1.0 / 3.0);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Sat Nov 10 23:04:16 UTC 2018 Modified Files: src/tests/lib/libm: t_cos.c Log Message: Print the input to cosf on failure too. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_cos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_cos.c diff -u src/tests/lib/libm/t_cos.c:1.6 src/tests/lib/libm/t_cos.c:1.7 --- src/tests/lib/libm/t_cos.c:1.6 Wed Nov 7 04:00:13 2018 +++ src/tests/lib/libm/t_cos.c Sat Nov 10 23:04:16 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: t_cos.c,v 1.6 2018/11/07 04:00:13 riastradh Exp $ */ +/* $NetBSD: t_cos.c,v 1.7 2018/11/10 23:04:16 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -179,8 +179,8 @@ ATF_TC_BODY(cosf_angles, tc) assert(cos_theta != 0); if (!(fabsf((cosf(theta) - cos_theta)/cos_theta) <= eps)) { - atf_tc_fail_nonfatal("cosf(%d deg) = %.8g != %.8g", - deg, cos(theta), cos_theta); + atf_tc_fail_nonfatal("cosf(%d deg = %.8g) = %.8g" + " != %.8g", deg, theta, cos(theta), cos_theta); } } }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Wed Nov 7 03:59:37 UTC 2018 Modified Files: src/tests/lib/libm: t_acos.c t_asin.c t_cbrt.c t_cos.c t_cosh.c t_exp.c t_ldexp.c t_libm.h t_log.c t_scalbn.c t_sin.c t_sinh.c t_sqrt.c t_tan.c Log Message: Fix up libm tests. - Fix up last few digits of a lot of known-answer tests. Confirmed with GNU mpfr to 200 bits of precision and cross-checked with whatever libm Ubuntu ships with. - Test relative error, not absolute error. - Set bounds in terms of *_EPSILON, not magic numbers. *_EPSILON is twice the largest relative error of a correctly rounded operation, and equal to the largest relative error of an operation with up to 1ulp error. Most of the operations we're testing are not correctly rounded, but they ought to be no more than 1ulp away. For the few cases where that's not a priori clear (like comparing cbrt and pow(x, 1/3)), use twice *_EPSILON to allow some leeway. - Write the success condition positively as error <= eps. This comes out false if the result is a NaN, meaning failure. In contrast, if we write error > eps for the _failure_ condition, then if the result is a NaN, it will also come out false, but meaning success, which is not what we want. - Fix the trigonometric test cases near bad spots. sin(pi - d) for nonzero d is not zero; it is d + O(d^3). pi is not a floating-point number, so these results should be approximately the nonzero error of our approximation to pi. Likewise with cos(pi/2 - d) and tan(pi + d). (Yes, I know the sin _function_ is ill-conditioned near pi so you shouldn't pass approximate inputs near there, but that's separate from whether a sin _implementation_ gives an answer that is wrong by quintillions of ulps.) Since on x86 (i386 and amd64 alike) we currently use x87 hardware trigonometric instructions, which are bad, these are marked xfail on x86 for now until we switch to software implementations (coming soon to a repository near you). - Use %.8g, %.17g, %.35g to print float, double, long double in failures. This should be enough to identify the problematic outputs and/or reproduce the computation, even if long double is binary128 with 115 bits of precision. If there are any new libm test failures after this, tell me what architecture you're on and send me the atf output and I'll try to figure it out. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libm/t_acos.c cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_asin.c \ src/tests/lib/libm/t_cbrt.c cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_cos.c \ src/tests/lib/libm/t_sin.c cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_cosh.c \ src/tests/lib/libm/t_libm.h src/tests/lib/libm/t_sinh.c cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libm/t_exp.c cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libm/t_ldexp.c cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libm/t_log.c cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libm/t_scalbn.c cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_sqrt.c cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_tan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_acos.c diff -u src/tests/lib/libm/t_acos.c:1.10 src/tests/lib/libm/t_acos.c:1.11 --- src/tests/lib/libm/t_acos.c:1.10 Wed Mar 5 20:14:46 2014 +++ src/tests/lib/libm/t_acos.c Wed Nov 7 03:59:36 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: t_acos.c,v 1.10 2014/03/05 20:14:46 dsl Exp $ */ +/* $NetBSD: t_acos.c,v 1.11 2018/11/07 03:59:36 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ ATF_LIBM_TEST(acos_inrange, "Test acos/a { 0,M_PI / 2, }, { 0.1, 1.47062890567, }, { 0.5, 1.047197551196598, }, - { 0.99, 0.141539473324427, }, + { 0.99, 0.1415394733244273, }, }; unsigned int i; Index: src/tests/lib/libm/t_asin.c diff -u src/tests/lib/libm/t_asin.c:1.3 src/tests/lib/libm/t_asin.c:1.4 --- src/tests/lib/libm/t_asin.c:1.3 Mon Mar 3 10:39:08 2014 +++ src/tests/lib/libm/t_asin.c Wed Nov 7 03:59:36 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: t_asin.c,v 1.3 2014/03/03 10:39:08 martin Exp $ */ +/* $NetBSD: t_asin.c,v 1.4 2018/11/07 03:59:36 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -30,6 +30,7 @@ */ #include +#include #include static const struct { @@ -117,13 +118,14 @@ ATF_TC_HEAD(asin_inrange, tc) ATF_TC_BODY(asin_inrange, tc) { - const double eps = 1.0e-15; - double y; + const double eps = DBL_EPSILON; size_t i; for (i = 0; i < __arraycount(values); i++) { - y = asin(values[i].x); - if (fabs(y - values[i].y) > eps) + double x = values[i].x; + double y = values[i].y; + + if (!(fabs((asin(x) - y)/y) <= eps)) atf_tc_fail_nonfatal("asin(%g) != %g", values[i].x, values[i].y); } @@ -230,16 +232,23 @@ ATF_TC_HEAD(asinf_inrange, tc) A
CVS commit: src/tests/lib/libm
Module Name:src Committed By: riastradh Date: Wed Nov 7 03:56:18 UTC 2018 Modified Files: src/tests/lib/libm: Makefile Log Message: Build libm tests with -fno-builtin. This way they test libm, not whatever the compiler does. We should _also_ have automatic integration tests for what the compiler does, as a separate thing. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.44 src/tests/lib/libm/Makefile:1.45 --- src/tests/lib/libm/Makefile:1.44 Wed Jun 20 03:51:27 2018 +++ src/tests/lib/libm/Makefile Wed Nov 7 03:56:18 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.44 2018/06/20 03:51:27 maya Exp $ +# $NetBSD: Makefile,v 1.45 2018/11/07 03:56:18 riastradh Exp $ .include @@ -7,6 +7,7 @@ TESTSDIR= ${TESTSBASE}/lib/libm .if ${MACHINE} == "alpha" COPTS+= -mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i .endif +COPTS+= -fno-builtin CPPFLAGS.t_fenv.c+= -D__TEST_FENV CPPFLAGS.t_fe_round.c+= -D__TEST_FENV
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Thu Jun 14 21:57:25 UTC 2018 Modified Files: src/tests/lib/libm: t_ilogb.c Log Message: for consistency, print the statement that is true in the error case. also add missing closing paren To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libm/t_ilogb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ilogb.c diff -u src/tests/lib/libm/t_ilogb.c:1.8 src/tests/lib/libm/t_ilogb.c:1.9 --- src/tests/lib/libm/t_ilogb.c:1.8 Thu Jun 14 21:11:08 2018 +++ src/tests/lib/libm/t_ilogb.c Thu Jun 14 21:57:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ilogb.c,v 1.8 2018/06/14 21:11:08 maya Exp $ */ +/* $NetBSD: t_ilogb.c,v 1.9 2018/06/14 21:57:25 maya Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_ilogb.c,v 1.8 2018/06/14 21:11:08 maya Exp $"); +__RCSID("$NetBSD: t_ilogb.c,v 1.9 2018/06/14 21:57:25 maya Exp $"); #include #include @@ -45,7 +45,7 @@ __RCSID("$NetBSD: t_ilogb.c,v 1.8 2018/0 # define ATF_CHECK_RAISED_INVALID do { \ int r = fetestexcept(FE_ALL_EXCEPT); \ ATF_CHECK_MSG((r & FE_INVALID) != 0, \ - "r & FE_INVALID !=0 (r=%#x, FE_INVALID=%#x\n", \ + "r & FE_INVALID == 0 (r=%#x, FE_INVALID=%#x)\n", \ r, FE_INVALID); \ (void)feclearexcept(FE_ALL_EXCEPT); \ } while (/*CONSTCOND*/0)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Thu Jun 14 21:11:08 UTC 2018 Modified Files: src/tests/lib/libm: t_ilogb.c Log Message: Test for FE_INVALID in a way that works for powerpc too. powerpc seems to return FE_INVALID | FE_VXSOFT rather than just FE_INVALID. XXX need extra careful reading of standards To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_ilogb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ilogb.c diff -u src/tests/lib/libm/t_ilogb.c:1.7 src/tests/lib/libm/t_ilogb.c:1.8 --- src/tests/lib/libm/t_ilogb.c:1.7 Fri Jan 13 19:23:40 2017 +++ src/tests/lib/libm/t_ilogb.c Thu Jun 14 21:11:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ilogb.c,v 1.7 2017/01/13 19:23:40 christos Exp $ */ +/* $NetBSD: t_ilogb.c,v 1.8 2018/06/14 21:11:08 maya Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_ilogb.c,v 1.7 2017/01/13 19:23:40 christos Exp $"); +__RCSID("$NetBSD: t_ilogb.c,v 1.8 2018/06/14 21:11:08 maya Exp $"); #include #include @@ -44,7 +44,9 @@ __RCSID("$NetBSD: t_ilogb.c,v 1.7 2017/0 #else # define ATF_CHECK_RAISED_INVALID do { \ int r = fetestexcept(FE_ALL_EXCEPT); \ - ATF_CHECK_MSG(r == FE_INVALID, "r=%#x != %#x\n", r, FE_INVALID); \ + ATF_CHECK_MSG((r & FE_INVALID) != 0, \ + "r & FE_INVALID !=0 (r=%#x, FE_INVALID=%#x\n", \ + r, FE_INVALID); \ (void)feclearexcept(FE_ALL_EXCEPT); \ } while (/*CONSTCOND*/0)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Mon Jun 4 09:13:47 UTC 2018 Modified Files: src/tests/lib/libm: Makefile Log Message: Blindly add __TEST_FENV in the hope of fixing the vax build. (So we can include fenv.h, and then not use it - we ifdef vax out for OS-portability reasons.) To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.42 src/tests/lib/libm/Makefile:1.43 --- src/tests/lib/libm/Makefile:1.42 Tue Dec 20 06:13:19 2016 +++ src/tests/lib/libm/Makefile Mon Jun 4 09:13:47 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.42 2016/12/20 06:13:19 maya Exp $ +# $NetBSD: Makefile,v 1.43 2018/06/04 09:13:47 maya Exp $ .include @@ -11,6 +11,7 @@ COPTS+= -mfloat-ieee -mieee-with-inexact CPPFLAGS.t_fenv.c+= -D__TEST_FENV CPPFLAGS.t_fe_round.c+= -D__TEST_FENV CPPFLAGS.t_ilogb.c+= -D__TEST_FENV +CPPFLAGS.t_scalbn.c+= -D__TEST_FENV CPPFLAGS.t_fmod.c+= -I${.CURDIR}/../libc/gen TESTS_C+= t_acos
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Sun Jun 3 08:39:00 UTC 2018 Modified Files: src/tests/lib/libm: t_scalbn.c Log Message: Test and clear exception around scalbn calls. Second part of PR bin/51834. ifdef out vax to avoid netbsd-specific macros. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libm/t_scalbn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_scalbn.c diff -u src/tests/lib/libm/t_scalbn.c:1.14 src/tests/lib/libm/t_scalbn.c:1.15 --- src/tests/lib/libm/t_scalbn.c:1.14 Fri Jan 13 21:09:12 2017 +++ src/tests/lib/libm/t_scalbn.c Sun Jun 3 08:39:00 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: t_scalbn.c,v 1.14 2017/01/13 21:09:12 agc Exp $ */ +/* $NetBSD: t_scalbn.c,v 1.15 2018/06/03 08:39:00 maya Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,12 +29,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_scalbn.c,v 1.14 2017/01/13 21:09:12 agc Exp $"); +__RCSID("$NetBSD: t_scalbn.c,v 1.15 2018/06/03 08:39:00 maya Exp $"); #include #include #include #include +#include #include @@ -46,16 +47,17 @@ struct testcase { double inval; double result; int error; + int except; }; struct testcase test_vals[] = { - { 0, 1.00085, 1.00085, 0 }, - { 0, 0.99755, 0.99755, 0 }, - { 0, -1.00085, -1.00085, 0 }, - { 0, -0.99755, -0.99755, 0 }, - { 1, 1.00085, 2.0* 1.00085, 0 }, - { 1, 0.99755, 2.0* 0.99755, 0 }, - { 1, -1.00085, 2.0* -1.00085, 0 }, - { 1, -0.99755, 2.0* -0.99755, 0 }, + { 0, 1.00085, 1.00085, 0, 0 }, + { 0, 0.99755, 0.99755, 0, 0 }, + { 0, -1.00085, -1.00085, 0, 0 }, + { 0, -0.99755, -0.99755, 0, 0 }, + { 1, 1.00085, 2.0* 1.00085, 0, 0 }, + { 1, 0.99755, 2.0* 0.99755, 0, 0 }, + { 1, -1.00085, 2.0* -1.00085, 0, 0 }, + { 1, -0.99755, 2.0* -0.99755, 0, 0 }, /* * We could add more corner test cases here, but we would have to @@ -82,10 +84,19 @@ ATF_TC_BODY(scalbn_val, tc) for (i = 0; i < tcnt; i++) { errno = 0; +#ifndef __vax__ + feclearexcept(FE_ALL_EXCEPT); +#endif rv = scalbn(tests[i].inval, tests[i].exp); ATF_CHECK_EQ_MSG(errno, tests[i].error, "test %zu: errno %d instead of %d", i, errno, tests[i].error); +#ifndef __vax__ + ATF_CHECK_EQ_MSG(errno, tests[i].error, + "test %zu: fetestexcept %d instead of %d", i, + fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW), + tests[i].except); +#endif ATF_CHECK_MSG(fabs(rv-tests[i].result)<2.0*DBL_EPSILON, "test %zu: return value %g instead of %g (difference %g)", i, rv, tests[i].result, tests[i].result-rv);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: wiz Date: Sun Sep 3 13:41:19 UTC 2017 Modified Files: src/tests/lib/libm: t_round.c Log Message: Fix verb form. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libm/t_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_round.c diff -u src/tests/lib/libm/t_round.c:1.8 src/tests/lib/libm/t_round.c:1.9 --- src/tests/lib/libm/t_round.c:1.8 Sun Sep 3 13:29:55 2017 +++ src/tests/lib/libm/t_round.c Sun Sep 3 13:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_round.c,v 1.8 2017/09/03 13:29:55 maya Exp $ */ +/* $NetBSD: t_round.c,v 1.9 2017/09/03 13:41:19 wiz Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -123,7 +123,7 @@ ATF_TC_BODY(rounding_alpha_simple, tc) uint64_t unsigned_even = rounding_alpha_simple_even; ATF_CHECK_MSG(unsigned_even % 2 == 0, - "2^63 casted to uint64_t is odd (got %"PRIu64")", unsigned_even); + "2^63 cast to uint64_t is odd (got %"PRIu64")", unsigned_even); } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Sun Sep 3 13:29:55 UTC 2017 Modified Files: src/tests/lib/libm: t_round.c Log Message: Use a global double to stop GCC from optimizing the test away Better diagnostic messages More familiar test for 'even number' To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_round.c diff -u src/tests/lib/libm/t_round.c:1.7 src/tests/lib/libm/t_round.c:1.8 --- src/tests/lib/libm/t_round.c:1.7 Wed Aug 30 22:55:41 2017 +++ src/tests/lib/libm/t_round.c Sun Sep 3 13:29:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_round.c,v 1.7 2017/08/30 22:55:41 maya Exp $ */ +/* $NetBSD: t_round.c,v 1.8 2017/09/03 13:29:55 maya Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -103,8 +103,8 @@ ATF_TC_BODY(rounding_alpha, tc) u = (gimpy_limb_t) d; for (; i > 0; i--) { -printf("i=%d, u: %"PRIu64"\n", i, u); -ATF_CHECK(!(u & 1)); +ATF_CHECK_MSG((u % 2 == 0), + "%"PRIu64" is not an even number! (iteration %d)", u , i); u = u >> 1; } } @@ -115,13 +115,15 @@ ATF_TC_HEAD(rounding_alpha_simple, tc) atf_tc_set_md_var(tc, "descr","Checking double to uint64_t edge case"); } + +double rounding_alpha_simple_even = 9223372036854775808.00; /* 2^63 */ + ATF_TC_BODY(rounding_alpha_simple, tc) { - double even = 9223372036854775808.00; /* 2^63 */ - uint64_t unsigned_even = even; + uint64_t unsigned_even = rounding_alpha_simple_even; ATF_CHECK_MSG(unsigned_even % 2 == 0, - "2^63 casted to uint64_t is odd"); + "2^63 casted to uint64_t is odd (got %"PRIu64")", unsigned_even); } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Wed Aug 30 22:55:41 UTC 2017 Modified Files: src/tests/lib/libm: t_round.c Log Message: Add a short case for the alpha test failure Now I see it's down to the choice of -mfp-trap-mode (n works, su/sui/u don't) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_round.c diff -u src/tests/lib/libm/t_round.c:1.6 src/tests/lib/libm/t_round.c:1.7 --- src/tests/lib/libm/t_round.c:1.6 Wed Aug 30 14:24:20 2017 +++ src/tests/lib/libm/t_round.c Wed Aug 30 22:55:41 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_round.c,v 1.6 2017/08/30 14:24:20 maya Exp $ */ +/* $NetBSD: t_round.c,v 1.7 2017/08/30 22:55:41 maya Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -32,6 +32,7 @@ #include #include #include +#include /* * This tests for a bug in the initial implementation where @@ -108,11 +109,27 @@ ATF_TC_BODY(rounding_alpha, tc) } } +ATF_TC(rounding_alpha_simple); +ATF_TC_HEAD(rounding_alpha_simple, tc) +{ + atf_tc_set_md_var(tc, "descr","Checking double to uint64_t edge case"); +} + +ATF_TC_BODY(rounding_alpha_simple, tc) +{ + double even = 9223372036854775808.00; /* 2^63 */ + uint64_t unsigned_even = even; + + ATF_CHECK_MSG(unsigned_even % 2 == 0, + "2^63 casted to uint64_t is odd"); + +} ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, round_dir); ATF_TP_ADD_TC(tp, rounding_alpha); + ATF_TP_ADD_TC(tp, rounding_alpha_simple); return atf_no_error(); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Wed Aug 30 14:24:20 UTC 2017 Modified Files: src/tests/lib/libm: t_round.c Log Message: use PRIu64 to print uint64_t, don't print sizeof fixes build. sorry, built tested an older version for 32bit. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_round.c diff -u src/tests/lib/libm/t_round.c:1.5 src/tests/lib/libm/t_round.c:1.6 --- src/tests/lib/libm/t_round.c:1.5 Wed Aug 30 10:51:06 2017 +++ src/tests/lib/libm/t_round.c Wed Aug 30 14:24:20 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_round.c,v 1.5 2017/08/30 10:51:06 maya Exp $ */ +/* $NetBSD: t_round.c,v 1.6 2017/08/30 14:24:20 maya Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -100,10 +100,9 @@ ATF_TC_BODY(rounding_alpha, tc) printf("d = %g\n", d); u = (gimpy_limb_t) d; -printf("sizeof u: %zu\n", sizeof(u)); for (; i > 0; i--) { -printf("i=%d, u: %lu\n", i, u); +printf("i=%d, u: %"PRIu64"\n", i, u); ATF_CHECK(!(u & 1)); u = u >> 1; }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Wed Aug 30 10:51:06 UTC 2017 Modified Files: src/tests/lib/libm: t_round.c Log Message: Add test case for alpha's MPFR config test failure This assert fires with -mieee, but not without it. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_round.c diff -u src/tests/lib/libm/t_round.c:1.4 src/tests/lib/libm/t_round.c:1.5 --- src/tests/lib/libm/t_round.c:1.4 Mon Nov 11 23:57:34 2013 +++ src/tests/lib/libm/t_round.c Wed Aug 30 10:51:06 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_round.c,v 1.4 2013/11/11 23:57:34 joerg Exp $ */ +/* $NetBSD: t_round.c,v 1.5 2017/08/30 10:51:06 maya Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -26,9 +26,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include + #include #include #include +#include /* * This tests for a bug in the initial implementation where @@ -76,10 +79,41 @@ ATF_TC_BODY(round_dir, tc) ATF_CHECK(fabsl(cl) < SMALL_NUM); } +ATF_TC(rounding_alpha); +ATF_TC_HEAD(rounding_alpha, tc) +{ + atf_tc_set_md_var(tc, "descr","Checking MPFR's config failure with -mieee on Alpha"); +} + +typedef uint64_t gimpy_limb_t; +#define GIMPY_NUMB_BITS 64 + +ATF_TC_BODY(rounding_alpha, tc) +{ +double d; +gimpy_limb_t u; +int i; + +d = 1.0; +for (i = 0; i < GIMPY_NUMB_BITS - 1; i++) +d = d + d; + +printf("d = %g\n", d); +u = (gimpy_limb_t) d; +printf("sizeof u: %zu\n", sizeof(u)); + +for (; i > 0; i--) { +printf("i=%d, u: %lu\n", i, u); +ATF_CHECK(!(u & 1)); +u = u >> 1; +} +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, round_dir); + ATF_TP_ADD_TC(tp, rounding_alpha); return atf_no_error(); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Mon Aug 21 17:11:18 UTC 2017 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: don't skip nexttoward for aarch64 and mips64 To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.8 src/tests/lib/libm/t_fe_round.c:1.9 --- src/tests/lib/libm/t_fe_round.c:1.8 Sun Aug 20 04:25:47 2017 +++ src/tests/lib/libm/t_fe_round.c Mon Aug 21 13:11:18 2017 @@ -168,9 +168,6 @@ ATF_TC_BODY(fe_nexttoward, tc) double received; int res; -#if defined(_LP64) && (defined(__mips__) || defined(__arm__)) - ATF_CHECK_MSG(0, "nexttoward not supported yet on mips64 or aarch64"); -#else for (unsigned int i = 0; i < __arraycount(values2); i++) { received = nexttoward(values2[i].input, values2[i].toward); if (values2[i].input < values2[i].toward) { @@ -184,7 +181,6 @@ ATF_TC_BODY(fe_nexttoward, tc) "input: %f (index %d): got %f, expected %f, res %d\n", values2[i].input, i, received, values2[i].expected, res); } -#endif } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Sun Aug 20 08:25:47 UTC 2017 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: fix build (missing nexttoward on mips64 and aarch64) To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.7 src/tests/lib/libm/t_fe_round.c:1.8 --- src/tests/lib/libm/t_fe_round.c:1.7 Thu Aug 17 05:14:28 2017 +++ src/tests/lib/libm/t_fe_round.c Sun Aug 20 04:25:47 2017 @@ -168,6 +168,9 @@ ATF_TC_BODY(fe_nexttoward, tc) double received; int res; +#if defined(_LP64) && (defined(__mips__) || defined(__arm__)) + ATF_CHECK_MSG(0, "nexttoward not supported yet on mips64 or aarch64"); +#else for (unsigned int i = 0; i < __arraycount(values2); i++) { received = nexttoward(values2[i].input, values2[i].toward); if (values2[i].input < values2[i].toward) { @@ -181,6 +184,7 @@ ATF_TC_BODY(fe_nexttoward, tc) "input: %f (index %d): got %f, expected %f, res %d\n", values2[i].input, i, received, values2[i].expected, res); } +#endif } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: he Date: Thu Aug 17 09:14:28 UTC 2017 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: Add test cases for nextafter() and nexttoward(). At the moment no corner cases are tested, and the test cases are little more than a verification that the functions are present in the implementation. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.6 src/tests/lib/libm/t_fe_round.c:1.7 --- src/tests/lib/libm/t_fe_round.c:1.6 Fri Aug 11 20:31:58 2017 +++ src/tests/lib/libm/t_fe_round.c Thu Aug 17 09:14:28 2017 @@ -122,11 +122,74 @@ ATF_TC_BODY(fe_nearbyint, tc) } } +static const struct { + double input; + double toward; + double expected; +} values2[] = { + { 10.0, 11.0, 10.0 }, + { -5.0, -6.0, -5.0 }, +}; + +ATF_TC(fe_nextafter); +ATF_TC_HEAD(fe_nextafter, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checking IEEE 754 rounding using nextafter()"); +} + +ATF_TC_BODY(fe_nextafter, tc) +{ + double received; + int res; + + for (unsigned int i = 0; i < __arraycount(values2); i++) { + received = nextafter(values2[i].input, values2[i].toward); + if (values2[i].input < values2[i].toward) { + res = (received > values2[i].input); + } else { + res = (received < values2[i].input); + } + ATF_CHECK_MSG( + res && (fabs(received - values2[i].expected) < EPSILON), + "nextafter() rounding wrong, difference too large\n" + "input: %f (index %d): got %f, expected %f, res %d\n", + values2[i].input, i, received, values2[i].expected, res); + } +} + +ATF_TC(fe_nexttoward); +ATF_TC_HEAD(fe_nexttoward, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checking IEEE 754 rounding using nexttoward()"); +} + +ATF_TC_BODY(fe_nexttoward, tc) +{ + double received; + int res; + + for (unsigned int i = 0; i < __arraycount(values2); i++) { + received = nexttoward(values2[i].input, values2[i].toward); + if (values2[i].input < values2[i].toward) { + res = (received > values2[i].input); + } else { + res = (received < values2[i].input); + } + ATF_CHECK_MSG( + res && (fabs(received - values2[i].expected) < EPSILON), + "nexttoward() rounding wrong, difference too large\n" + "input: %f (index %d): got %f, expected %f, res %d\n", + values2[i].input, i, received, values2[i].expected, res); + } +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, fe_round); ATF_TP_ADD_TC(tp, fe_nearbyint); + ATF_TP_ADD_TC(tp, fe_nextafter); + ATF_TP_ADD_TC(tp, fe_nexttoward); return atf_no_error(); } @@ -139,7 +202,6 @@ ATF_TC_HEAD(t_nofe_round, tc) "dummy test case - no fenv.h support"); } - ATF_TC_BODY(t_nofe_round, tc) { atf_tc_skip("no fenv.h support on this architecture"); @@ -158,11 +220,38 @@ ATF_TC_BODY(t_nofe_nearbyint, tc) atf_tc_skip("no fenv.h support on this architecture"); } +ATF_TC(t_nofe_nextafter); + +ATF_TC_HEAD(t_nofe_nextafter, tc) +{ + atf_tc_set_md_var(tc, "descr", + "dummy test case - no fenv.h support"); +} + +ATF_TC_BODY(t_nofe_nextafter, tc) +{ + atf_tc_skip("no fenv.h support on this architecture"); +} + +ATF_TC(t_nofe_nexttoward); + +ATF_TC_HEAD(t_nofe_nexttoward, tc) +{ + atf_tc_set_md_var(tc, "descr", + "dummy test case - no fenv.h support"); +} + +ATF_TC_BODY(t_nofe_nexttoward, tc) +{ + atf_tc_skip("no fenv.h support on this architecture"); +} ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, t_nofe_round); ATF_TP_ADD_TC(tp, t_nofe_nearbyint); + ATF_TP_ADD_TC(tp, t_nofe_nextafter); + ATF_TP_ADD_TC(tp, t_nofe_nexttoward); return atf_no_error(); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: he Date: Fri Aug 11 20:31:58 UTC 2017 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: Re-enable the test for nearbyint(), now that all ports (save vax, which has a separate #if section here) should have nearbyint(). To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.5 src/tests/lib/libm/t_fe_round.c:1.6 --- src/tests/lib/libm/t_fe_round.c:1.5 Tue Jul 25 21:26:56 2017 +++ src/tests/lib/libm/t_fe_round.c Fri Aug 11 20:31:58 2017 @@ -93,10 +93,40 @@ ATF_TC_BODY(fe_round, tc) } } +ATF_TC(fe_nearbyint); +ATF_TC_HEAD(fe_nearbyint, tc) +{ + atf_tc_set_md_var(tc, "descr","Checking IEEE 754 rounding modes using nearbyint"); +} + +ATF_TC_BODY(fe_nearbyint, tc) +{ + double received; + + for (unsigned int i = 0; i < __arraycount(values); i++) { + fesetround(values[i].round_mode); + + received = nearbyint(values[i].input); + ATF_CHECK_MSG( + (fabs(received - values[i].expected) < EPSILON), + "nearbyint rounding wrong, difference too large\n" + "input: %f (index %d): got %f, expected %ld\n", + values[i].input, i, received, values[i].expected); + + /* Do we get the same rounding mode out? */ + ATF_CHECK_MSG( + (fegetround() == values[i].round_mode), + "Didn't get the same rounding mode out!\n" + "(index %d) fed in %d rounding mode, got %d out\n", + i, values[i].round_mode, fegetround()); + } +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, fe_round); + ATF_TP_ADD_TC(tp, fe_nearbyint); return atf_no_error(); } @@ -115,9 +145,24 @@ ATF_TC_BODY(t_nofe_round, tc) atf_tc_skip("no fenv.h support on this architecture"); } +ATF_TC(t_nofe_nearbyint); + +ATF_TC_HEAD(t_nofe_nearbyint, tc) +{ + atf_tc_set_md_var(tc, "descr", + "dummy test case - no fenv.h support"); +} + +ATF_TC_BODY(t_nofe_nearbyint, tc) +{ + atf_tc_skip("no fenv.h support on this architecture"); +} + + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, t_nofe_round); + ATF_TP_ADD_TC(tp, t_nofe_nearbyint); return atf_no_error(); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: uwe Date: Tue Jul 25 21:26:56 UTC 2017 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: Revert previous as it breaks at least sparc and hpcsh builds. nearbyint() is not included in libm on all platforms. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.4 src/tests/lib/libm/t_fe_round.c:1.5 --- src/tests/lib/libm/t_fe_round.c:1.4 Mon Jul 24 18:14:46 2017 +++ src/tests/lib/libm/t_fe_round.c Tue Jul 25 21:26:56 2017 @@ -93,40 +93,10 @@ ATF_TC_BODY(fe_round, tc) } } -ATF_TC(fe_nearbyint); -ATF_TC_HEAD(fe_nearbyint, tc) -{ - atf_tc_set_md_var(tc, "descr","Checking IEEE 754 rounding modes using nearbyint"); -} - -ATF_TC_BODY(fe_nearbyint, tc) -{ - double received; - - for (unsigned int i = 0; i < __arraycount(values); i++) { - fesetround(values[i].round_mode); - - received = nearbyint(values[i].input); - ATF_CHECK_MSG( - (fabs(received - values[i].expected) < EPSILON), - "nearbyint rounding wrong, difference too large\n" - "input: %f (index %d): got %f, expected %ld\n", - values[i].input, i, received, values[i].expected); - - /* Do we get the same rounding mode out? */ - ATF_CHECK_MSG( - (fegetround() == values[i].round_mode), - "Didn't get the same rounding mode out!\n" - "(index %d) fed in %d rounding mode, got %d out\n", - i, values[i].round_mode, fegetround()); - } -} - ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, fe_round); - ATF_TP_ADD_TC(tp, fe_nearbyint); return atf_no_error(); } @@ -139,27 +109,15 @@ ATF_TC_HEAD(t_nofe_round, tc) "dummy test case - no fenv.h support"); } -ATF_TC_BODY(t_nofe_round, tc) -{ - atf_tc_skip("no fenv.h support on this architecture"); -} -ATF_TC_HEAD(t_nofe_nearbyint, tc) -{ - atf_tc_set_md_var(tc, "descr", - "dummy test case - no fenv.h support"); -} - -ATF_TC_BODY(t_nofe_nearbyint, tc) +ATF_TC_BODY(t_nofe_round, tc) { atf_tc_skip("no fenv.h support on this architecture"); } - ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, t_nofe_round); - ATF_TP_ADD_TC(tp, t_nofe_nearbyint); return atf_no_error(); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: he Date: Mon Jul 24 18:14:46 UTC 2017 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: Add a test checking nearbyint(), using the same table as used by the existing lrint() test. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.3 src/tests/lib/libm/t_fe_round.c:1.4 --- src/tests/lib/libm/t_fe_round.c:1.3 Mon Jul 24 18:13:36 2017 +++ src/tests/lib/libm/t_fe_round.c Mon Jul 24 18:14:46 2017 @@ -93,10 +93,40 @@ ATF_TC_BODY(fe_round, tc) } } +ATF_TC(fe_nearbyint); +ATF_TC_HEAD(fe_nearbyint, tc) +{ + atf_tc_set_md_var(tc, "descr","Checking IEEE 754 rounding modes using nearbyint"); +} + +ATF_TC_BODY(fe_nearbyint, tc) +{ + double received; + + for (unsigned int i = 0; i < __arraycount(values); i++) { + fesetround(values[i].round_mode); + + received = nearbyint(values[i].input); + ATF_CHECK_MSG( + (fabs(received - values[i].expected) < EPSILON), + "nearbyint rounding wrong, difference too large\n" + "input: %f (index %d): got %f, expected %ld\n", + values[i].input, i, received, values[i].expected); + + /* Do we get the same rounding mode out? */ + ATF_CHECK_MSG( + (fegetround() == values[i].round_mode), + "Didn't get the same rounding mode out!\n" + "(index %d) fed in %d rounding mode, got %d out\n", + i, values[i].round_mode, fegetround()); + } +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, fe_round); + ATF_TP_ADD_TC(tp, fe_nearbyint); return atf_no_error(); } @@ -109,15 +139,27 @@ ATF_TC_HEAD(t_nofe_round, tc) "dummy test case - no fenv.h support"); } - ATF_TC_BODY(t_nofe_round, tc) { atf_tc_skip("no fenv.h support on this architecture"); } +ATF_TC_HEAD(t_nofe_nearbyint, tc) +{ + atf_tc_set_md_var(tc, "descr", + "dummy test case - no fenv.h support"); +} + +ATF_TC_BODY(t_nofe_nearbyint, tc) +{ + atf_tc_skip("no fenv.h support on this architecture"); +} + + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, t_nofe_round); + ATF_TP_ADD_TC(tp, t_nofe_nearbyint); return atf_no_error(); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: he Date: Mon Jul 24 18:13:36 UTC 2017 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: Swap around the two last args to the check for expected fegetround(), so the error message makes sense. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.2 src/tests/lib/libm/t_fe_round.c:1.3 --- src/tests/lib/libm/t_fe_round.c:1.2 Tue Dec 20 06:07:38 2016 +++ src/tests/lib/libm/t_fe_round.c Mon Jul 24 18:13:36 2017 @@ -89,7 +89,7 @@ ATF_TC_BODY(fe_round, tc) (fegetround() == values[i].round_mode), "Didn't get the same rounding mode out!\n" "(index %d) fed in %d rounding mode, got %d out\n", - i, fegetround(), values[i].round_mode); + i, values[i].round_mode, fegetround()); } }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Fri Jan 20 21:15:56 UTC 2017 Modified Files: src/tests/lib/libm: t_pow.c Log Message: use isinf instead of isinff. this doesn't introduce a functional change - isinf works for float as well, and is more portable. from Ngie Cooper in PR bin/51838 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_pow.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_pow.c diff -u src/tests/lib/libm/t_pow.c:1.4 src/tests/lib/libm/t_pow.c:1.5 --- src/tests/lib/libm/t_pow.c:1.4 Tue Sep 8 05:24:27 2015 +++ src/tests/lib/libm/t_pow.c Fri Jan 20 21:15:56 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_pow.c,v 1.4 2015/09/08 05:24:27 dholland Exp $ */ +/* $NetBSD: t_pow.c,v 1.5 2017/01/20 21:15:56 maya Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_pow.c,v 1.4 2015/09/08 05:24:27 dholland Exp $"); +__RCSID("$NetBSD: t_pow.c,v 1.5 2017/01/20 21:15:56 maya Exp $"); #include #include @@ -379,12 +379,12 @@ ATF_TC_BODY(powf_inf_neg_x, tc) */ z = powf(x, 3.0); - if (isinff(z) == 0 || signbit(z) == 0) + if (isinf(z) == 0 || signbit(z) == 0) atf_tc_fail_nonfatal("powf(-Inf, 3.0) != -Inf"); z = powf(x, 4.0); - if (isinff(z) == 0 || signbit(z) != 0) + if (isinf(z) == 0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(-Inf, 4.0) != +Inf"); /* @@ -421,7 +421,7 @@ ATF_TC_BODY(powf_inf_neg_y, tc) */ z = powf(0.1, y); - if (isinff(z) == 0 || signbit(z) != 0) + if (isinf(z) == 0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(0.1, -Inf) != +Inf"); z = powf(1.1, y); @@ -452,7 +452,7 @@ ATF_TC_BODY(powf_inf_pos_x, tc) z = powf(x, 2.0); - if (isinff(z) == 0 || signbit(z) != 0) + if (isinf(z) == 0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(+Inf, 2.0) != +Inf"); } @@ -478,7 +478,7 @@ ATF_TC_BODY(powf_inf_pos_y, tc) z = powf(1.1, y); - if (isinff(z) == 0 || signbit(z) != 0) + if (isinf(z) == 0 || signbit(z) != 0) atf_tc_fail_nonfatal("powf(1.1, +Inf) != +Inf"); } @@ -496,8 +496,8 @@ ATF_TC_BODY(powf_one_neg_x, tc) /* * If x is -1.0, and y is +-Inf, 1.0 shall be returned. */ - ATF_REQUIRE(isinff(infp) != 0); - ATF_REQUIRE(isinff(infn) != 0); + ATF_REQUIRE(isinf(infp) != 0); + ATF_REQUIRE(isinf(infn) != 0); if (powf(-1.0, infp) != 1.0) { atf_tc_expect_fail("PR lib/45372");
CVS commit: src/tests/lib/libm
Module Name:src Committed By: agc Date: Fri Jan 13 21:09:12 UTC 2017 Modified Files: src/tests/lib/libm: t_scalbn.c Log Message: also terminate 2 other statements properly To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libm/t_scalbn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_scalbn.c diff -u src/tests/lib/libm/t_scalbn.c:1.13 src/tests/lib/libm/t_scalbn.c:1.14 --- src/tests/lib/libm/t_scalbn.c:1.13 Fri Jan 13 21:00:59 2017 +++ src/tests/lib/libm/t_scalbn.c Fri Jan 13 21:09:12 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_scalbn.c,v 1.13 2017/01/13 21:00:59 agc Exp $ */ +/* $NetBSD: t_scalbn.c,v 1.14 2017/01/13 21:09:12 agc Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_scalbn.c,v 1.13 2017/01/13 21:00:59 agc Exp $"); +__RCSID("$NetBSD: t_scalbn.c,v 1.14 2017/01/13 21:09:12 agc Exp $"); #include #include @@ -81,7 +81,7 @@ ATF_TC_BODY(scalbn_val, tc) double rv; for (i = 0; i < tcnt; i++) { - errno = 0 + errno = 0; rv = scalbn(tests[i].inval, tests[i].exp); ATF_CHECK_EQ_MSG(errno, tests[i].error, "test %zu: errno %d instead of %d", i, errno, @@ -368,7 +368,7 @@ ATF_TC_BODY(scalbnl_val, tc) long double rv; for (i = 0; i < tcnt; i++) { - errno = 0 + errno = 0; rv = scalbnl(tests[i].inval, tests[i].exp); ATF_CHECK_EQ_MSG(errno, tests[i].error, "test %zu: errno %d instead of %d", i, errno,
CVS commit: src/tests/lib/libm
Module Name:src Committed By: agc Date: Fri Jan 13 21:00:59 UTC 2017 Modified Files: src/tests/lib/libm: t_scalbn.c Log Message: terminate the statement properly To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libm/t_scalbn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_scalbn.c diff -u src/tests/lib/libm/t_scalbn.c:1.12 src/tests/lib/libm/t_scalbn.c:1.13 --- src/tests/lib/libm/t_scalbn.c:1.12 Fri Jan 13 19:26:03 2017 +++ src/tests/lib/libm/t_scalbn.c Fri Jan 13 21:00:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_scalbn.c,v 1.12 2017/01/13 19:26:03 christos Exp $ */ +/* $NetBSD: t_scalbn.c,v 1.13 2017/01/13 21:00:59 agc Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_scalbn.c,v 1.12 2017/01/13 19:26:03 christos Exp $"); +__RCSID("$NetBSD: t_scalbn.c,v 1.13 2017/01/13 21:00:59 agc Exp $"); #include #include @@ -223,7 +223,7 @@ ATF_TC_BODY(scalbnf_val, tc) double rv; for (i = 0; i < tcnt; i++) { - errno = 0 + errno = 0; rv = scalbnf(tests[i].inval, tests[i].exp); ATF_CHECK_EQ_MSG(errno, tests[i].error, "test %zu: errno %d instead of %d", i, errno,
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Fri Jan 13 19:26:03 UTC 2017 Modified Files: src/tests/lib/libm: t_scalbn.c Log Message: PR/51839: Ngie Cooper: reset errno to 0 before calling scalbn* To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libm/t_scalbn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_scalbn.c diff -u src/tests/lib/libm/t_scalbn.c:1.11 src/tests/lib/libm/t_scalbn.c:1.12 --- src/tests/lib/libm/t_scalbn.c:1.11 Mon Mar 3 05:39:08 2014 +++ src/tests/lib/libm/t_scalbn.c Fri Jan 13 14:26:03 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_scalbn.c,v 1.11 2014/03/03 10:39:08 martin Exp $ */ +/* $NetBSD: t_scalbn.c,v 1.12 2017/01/13 19:26:03 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_scalbn.c,v 1.11 2014/03/03 10:39:08 martin Exp $"); +__RCSID("$NetBSD: t_scalbn.c,v 1.12 2017/01/13 19:26:03 christos Exp $"); #include #include @@ -81,6 +81,7 @@ ATF_TC_BODY(scalbn_val, tc) double rv; for (i = 0; i < tcnt; i++) { + errno = 0 rv = scalbn(tests[i].inval, tests[i].exp); ATF_CHECK_EQ_MSG(errno, tests[i].error, "test %zu: errno %d instead of %d", i, errno, @@ -222,6 +223,7 @@ ATF_TC_BODY(scalbnf_val, tc) double rv; for (i = 0; i < tcnt; i++) { + errno = 0 rv = scalbnf(tests[i].inval, tests[i].exp); ATF_CHECK_EQ_MSG(errno, tests[i].error, "test %zu: errno %d instead of %d", i, errno, @@ -366,6 +368,7 @@ ATF_TC_BODY(scalbnl_val, tc) long double rv; for (i = 0; i < tcnt; i++) { + errno = 0 rv = scalbnl(tests[i].inval, tests[i].exp); ATF_CHECK_EQ_MSG(errno, tests[i].error, "test %zu: errno %d instead of %d", i, errno,
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Fri Jan 13 19:23:40 UTC 2017 Modified Files: src/tests/lib/libm: t_ilogb.c Log Message: PR/51837: Ngie Cooper: add limits.h for INT_MAX To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_ilogb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ilogb.c diff -u src/tests/lib/libm/t_ilogb.c:1.6 src/tests/lib/libm/t_ilogb.c:1.7 --- src/tests/lib/libm/t_ilogb.c:1.6 Fri Aug 26 04:01:55 2016 +++ src/tests/lib/libm/t_ilogb.c Fri Jan 13 14:23:40 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ilogb.c,v 1.6 2016/08/26 08:01:55 christos Exp $ */ +/* $NetBSD: t_ilogb.c,v 1.7 2017/01/13 19:23:40 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -28,15 +28,18 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include +__RCSID("$NetBSD: t_ilogb.c,v 1.7 2017/01/13 19:23:40 christos Exp $"); #include #include +#include #include #ifndef __HAVE_FENV -# define ATF_CHECK_RAISED_INVALID -# define ATF_CHECK_RAISED_NOTHING +# define ATF_CHECK_RAISED_INVALID +# define ATF_CHECK_RAISED_NOTHING #else # define ATF_CHECK_RAISED_INVALID do { \
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Tue Dec 20 06:13:19 UTC 2016 Modified Files: src/tests/lib/libm: Makefile Log Message: define __TEST_FENV in the makefile for t_fe_round should fix vax build (it doesn't have fenv.h) To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.41 src/tests/lib/libm/Makefile:1.42 --- src/tests/lib/libm/Makefile:1.41 Mon Dec 19 17:38:24 2016 +++ src/tests/lib/libm/Makefile Tue Dec 20 06:13:19 2016 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.41 2016/12/19 17:38:24 maya Exp $ +# $NetBSD: Makefile,v 1.42 2016/12/20 06:13:19 maya Exp $ .include @@ -9,6 +9,7 @@ COPTS+= -mfloat-ieee -mieee-with-inexact .endif CPPFLAGS.t_fenv.c+= -D__TEST_FENV +CPPFLAGS.t_fe_round.c+= -D__TEST_FENV CPPFLAGS.t_ilogb.c+= -D__TEST_FENV CPPFLAGS.t_fmod.c+= -I${.CURDIR}/../libc/gen
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Tue Dec 20 06:07:38 UTC 2016 Modified Files: src/tests/lib/libm: t_fe_round.c Log Message: use labs for absolute value of long should fix arm build To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fe_round.c diff -u src/tests/lib/libm/t_fe_round.c:1.1 src/tests/lib/libm/t_fe_round.c:1.2 --- src/tests/lib/libm/t_fe_round.c:1.1 Mon Dec 19 17:38:24 2016 +++ src/tests/lib/libm/t_fe_round.c Tue Dec 20 06:07:38 2016 @@ -79,7 +79,7 @@ ATF_TC_BODY(fe_round, tc) received = lrint(values[i].input); ATF_CHECK_MSG( - (abs(received - values[i].expected) < EPSILON), + (labs(received - values[i].expected) < EPSILON), "lrint rounding wrong, difference too large\n" "input: %f (index %d): got %ld, expected %ld\n", values[i].input, i, received, values[i].expected);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Mon Dec 19 17:38:24 UTC 2016 Modified Files: src/tests/lib/libm: Makefile Added Files: src/tests/lib/libm: t_fe_round.c Log Message: add test for fesetround/fegetround that uses lrint (and tests it a bunch). It doesn't fail on amd64. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/tests/lib/libm/Makefile cvs rdiff -u -r0 -r1.1 src/tests/lib/libm/t_fe_round.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.40 src/tests/lib/libm/Makefile:1.41 --- src/tests/lib/libm/Makefile:1.40 Wed Aug 31 14:05:10 2016 +++ src/tests/lib/libm/Makefile Mon Dec 19 17:38:24 2016 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.40 2016/08/31 14:05:10 maya Exp $ +# $NetBSD: Makefile,v 1.41 2016/12/19 17:38:24 maya Exp $ .include @@ -23,6 +23,7 @@ TESTS_C+= t_cosh TESTS_C+= t_erf TESTS_C+= t_exp TESTS_C+= t_fenv +TESTS_C+= t_fe_round TESTS_C+= t_fmod TESTS_C+= t_hypot TESTS_C+= t_ilogb Added files: Index: src/tests/lib/libm/t_fe_round.c diff -u /dev/null src/tests/lib/libm/t_fe_round.c:1.1 --- /dev/null Mon Dec 19 17:38:24 2016 +++ src/tests/lib/libm/t_fe_round.c Mon Dec 19 17:38:24 2016 @@ -0,0 +1,124 @@ +/* + * Written by Maya Rashish + * Public domain. + * + * Testing IEEE-754 rounding modes (and lrint) + */ + +#include +#include +#ifdef __HAVE_FENV +#include +#include +#include + +/*#pragma STDC FENV_ACCESS ON gcc?? */ + +#define INT 9223L + +#define EPSILON 0.001 + +static const struct { + int round_mode; + double input; + long int expected; +} values[] = { + { FE_DOWNWARD, 3.7, 3}, + { FE_DOWNWARD, -3.7, -4}, + { FE_DOWNWARD, +0, 0}, + { FE_DOWNWARD, -INT-0.01, -INT-1}, + { FE_DOWNWARD, +INT-0.01, INT-1}, + { FE_DOWNWARD, -INT+0.01, -INT}, + { FE_DOWNWARD, +INT+0.01, INT}, +#if 0 /* cpu bugs? */ + { FE_DOWNWARD, -0, -1}, + + { FE_UPWARD, +0, 1}, +#endif + { FE_UPWARD, -0, 0}, + { FE_UPWARD, -123.7, -123}, + { FE_UPWARD, 123.999, 124}, + { FE_UPWARD, -INT-0.01, -INT}, + { FE_UPWARD, +INT-0.01, INT}, + { FE_UPWARD, -INT+0.01, -INT+1}, + { FE_UPWARD, +INT+0.01, INT+1}, + + { FE_TOWARDZERO, 1.99, 1}, + { FE_TOWARDZERO, -1.99, -1}, + { FE_TOWARDZERO, 0.2, 0}, + { FE_TOWARDZERO, INT+0.01, INT}, + { FE_TOWARDZERO, INT-0.01, INT - 1}, + { FE_TOWARDZERO, -INT+0.01, -INT + 1}, + { FE_TOWARDZERO, +0, 0}, + { FE_TOWARDZERO, -0, 0}, + + { FE_TONEAREST, -INT-0.01, -INT}, + { FE_TONEAREST, +INT-0.01, INT}, + { FE_TONEAREST, -INT+0.01, -INT}, + { FE_TONEAREST, +INT+0.01, INT}, + { FE_TONEAREST, -INT-0.501, -INT-1}, + { FE_TONEAREST, +INT-0.501, INT-1}, + { FE_TONEAREST, -INT+0.501, -INT+1}, + { FE_TONEAREST, +INT+0.501, INT+1}, + { FE_TONEAREST, +0, 0}, + { FE_TONEAREST, -0, 0}, +}; + +ATF_TC(fe_round); +ATF_TC_HEAD(fe_round, tc) +{ + atf_tc_set_md_var(tc, "descr","Checking IEEE 754 rounding modes using lrint"); +} + +ATF_TC_BODY(fe_round, tc) +{ + long int received; + + for (unsigned int i = 0; i < __arraycount(values); i++) { + fesetround(values[i].round_mode); + + received = lrint(values[i].input); + ATF_CHECK_MSG( + (abs(received - values[i].expected) < EPSILON), + "lrint rounding wrong, difference too large\n" + "input: %f (index %d): got %ld, expected %ld\n", + values[i].input, i, received, values[i].expected); + + /* Do we get the same rounding mode out? */ + ATF_CHECK_MSG( + (fegetround() == values[i].round_mode), + "Didn't get the same rounding mode out!\n" + "(index %d) fed in %d rounding mode, got %d out\n", + i, fegetround(), values[i].round_mode); + } +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, fe_round); + + return atf_no_error(); +} +#else +ATF_TC(t_nofe_round); + +ATF_TC_HEAD(t_nofe_round, tc) +{ + atf_tc_set_md_var(tc, "descr", + "dummy test case - no fenv.h support"); +} + + +ATF_TC_BODY(t_nofe_round, tc) +{ + atf_tc_skip("no fenv.h support on this architecture"); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, t_nofe_round); + return atf_no_error(); +} + +#endif
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Tue Sep 20 17:19:29 UTC 2016 Modified Files: src/tests/lib/libm: t_casinh.c Log Message: print what went wrong. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_casinh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_casinh.c diff -u src/tests/lib/libm/t_casinh.c:1.1 src/tests/lib/libm/t_casinh.c:1.2 --- src/tests/lib/libm/t_casinh.c:1.1 Wed Aug 31 10:05:10 2016 +++ src/tests/lib/libm/t_casinh.c Tue Sep 20 13:19:28 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: t_casinh.c,v 1.1 2016/08/31 14:05:10 maya Exp $ */ +/* $NetBSD: t_casinh.c,v 1.2 2016/09/20 17:19:28 christos Exp $ */ /* * Written by Maya Rashish @@ -44,8 +44,11 @@ static const struct { #define crude_equality(a,b) ((a == b) || both_nan(a,b)) #define ATF_COMPLEX_EQUAL(a,b) do { \ - ATF_CHECK(crude_equality(creal(a),creal(b)) && \ - crude_equality(cimag(a), cimag(b))); \ + complex double ci = casinh(a); \ + ATF_CHECK_MSG(crude_equality(creal(ci),creal(b)) && \ + crude_equality(cimag(ci), cimag(b)), \ + "for casinh([%g,%g]) = [%g,%g] != [%g,%g]", \ + creal(a), cimag(a), creal(ci), cimag(ci), creal(b), cimag(b)); \ } while (0/*CONSTCOND*/) @@ -65,7 +68,7 @@ ATF_TC_BODY(casinh, tc) IM(input) = values[i].input_im; RE(result) = values[i].result_re; IM(result) = values[i].result_im; - ATF_COMPLEX_EQUAL(casinh(input), result); + ATF_COMPLEX_EQUAL(input, result); } }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Sat Aug 27 10:07:05 UTC 2016 Modified Files: src/tests/lib/libm: t_precision.c Log Message: do the long double tests if we have long double. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_precision.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_precision.c diff -u src/tests/lib/libm/t_precision.c:1.2 src/tests/lib/libm/t_precision.c:1.3 --- src/tests/lib/libm/t_precision.c:1.2 Mon Nov 3 19:20:19 2014 +++ src/tests/lib/libm/t_precision.c Sat Aug 27 06:07:05 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: t_precision.c,v 1.2 2014/11/04 00:20:19 justin Exp $ */ +/* $NetBSD: t_precision.c,v 1.3 2016/08/27 10:07:05 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_precision.c,v 1.2 2014/11/04 00:20:19 justin Exp $"); +__RCSID("$NetBSD: t_precision.c,v 1.3 2016/08/27 10:07:05 christos Exp $"); #include @@ -45,7 +45,9 @@ ATF_TC_HEAD(t_precision, tc) } volatile double x = 1; +#if __HAVE_LONG_DOUBLE volatile long double y = 1; +#endif ATF_TC_BODY(t_precision, tc) { @@ -58,6 +60,7 @@ ATF_TC_BODY(t_precision, tc) x += DBL_EPSILON; ATF_CHECK(x == 2.0); +#if __HAVE_LONG_DOUBLE y += LDBL_EPSILON; ATF_CHECK(y != 1.0L); y -= 1; @@ -65,6 +68,7 @@ ATF_TC_BODY(t_precision, tc) y = 2; y += LDBL_EPSILON; ATF_CHECK(y == 2.0L); +#endif } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Fri Aug 26 08:01:55 UTC 2016 Modified Files: src/tests/lib/libm: t_ilogb.c Log Message: forgot to protect an ilogbl To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_ilogb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ilogb.c diff -u src/tests/lib/libm/t_ilogb.c:1.5 src/tests/lib/libm/t_ilogb.c:1.6 --- src/tests/lib/libm/t_ilogb.c:1.5 Wed Aug 24 06:04:53 2016 +++ src/tests/lib/libm/t_ilogb.c Fri Aug 26 04:01:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ilogb.c,v 1.5 2016/08/24 10:04:53 christos Exp $ */ +/* $NetBSD: t_ilogb.c,v 1.6 2016/08/26 08:01:55 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -65,8 +65,10 @@ ATF_TC_BODY(ilogb, tc) ATF_CHECK_RAISED_INVALID; ATF_CHECK(ilogb(0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; +#endif ATF_CHECK(ilogbf(-0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID;
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Thu Aug 25 00:32:31 UTC 2016 Modified Files: src/tests/lib/libm: t_ldexp.c Log Message: Add a failing case for t_ldexp ldexp(2.0, INT_MAX) should be HUGE_VAL, not 0 To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libm/t_ldexp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ldexp.c diff -u src/tests/lib/libm/t_ldexp.c:1.15 src/tests/lib/libm/t_ldexp.c:1.16 --- src/tests/lib/libm/t_ldexp.c:1.15 Thu Aug 25 00:26:01 2016 +++ src/tests/lib/libm/t_ldexp.c Thu Aug 25 00:32:31 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ldexp.c,v 1.15 2016/08/25 00:26:01 maya Exp $ */ +/* $NetBSD: t_ldexp.c,v 1.16 2016/08/25 00:32:31 maya Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_ldexp.c,v 1.15 2016/08/25 00:26:01 maya Exp $"); +__RCSID("$NetBSD: t_ldexp.c,v 1.16 2016/08/25 00:32:31 maya Exp $"); #include @@ -96,10 +96,12 @@ struct ldexp_test ldexp_overflow[] = { { 1.0, 1023, 1, "inf" }, { 1.0, -1022, 2046, "inf" }, { 1.0, 1025, SKIP, "inf" }, + { 2.0, INT_MAX,SKIP, "inf" }, { -1.0, 1024, SKIP, " -inf" }, { -1.0, 1023, 1, " -inf" }, { -1.0, -1022, 2046, " -inf" }, { -1.0, 1025, SKIP, " -inf" }, + { -2.0, INT_MAX,SKIP, " -inf" }, { 0, 0, 0, NULL } };
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Thu Aug 25 00:26:01 UTC 2016 Modified Files: src/tests/lib/libm: t_ldexp.c Log Message: don't skip the entire test iteration if exp2=SKIP, only the second application of the function this doesn't introduce new failures on amd64 To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libm/t_ldexp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ldexp.c diff -u src/tests/lib/libm/t_ldexp.c:1.14 src/tests/lib/libm/t_ldexp.c:1.15 --- src/tests/lib/libm/t_ldexp.c:1.14 Tue Nov 4 00:20:19 2014 +++ src/tests/lib/libm/t_ldexp.c Thu Aug 25 00:26:01 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ldexp.c,v 1.14 2014/11/04 00:20:19 justin Exp $ */ +/* $NetBSD: t_ldexp.c,v 1.15 2016/08/25 00:26:01 maya Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_ldexp.c,v 1.14 2014/11/04 00:20:19 justin Exp $"); +__RCSID("$NetBSD: t_ldexp.c,v 1.15 2016/08/25 00:26:01 maya Exp $"); #include @@ -170,10 +170,8 @@ run_test(struct ldexp_test *table) v = ldexp(table->x, table->exp1); - if (table->exp2 == SKIP) - continue; - - v = ldexp(v, table->exp2); + if (table->exp2 != SKIP) + v = ldexp(v, table->exp2); (void)snprintf(outbuf, sizeof(outbuf), FORMAT, v);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Wed Aug 24 10:04:53 UTC 2016 Modified Files: src/tests/lib/libm: t_ilogb.c Log Message: fix test; clearing the exception does not return the old exception bitmask. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_ilogb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ilogb.c diff -u src/tests/lib/libm/t_ilogb.c:1.4 src/tests/lib/libm/t_ilogb.c:1.5 --- src/tests/lib/libm/t_ilogb.c:1.4 Wed Aug 24 05:13:44 2016 +++ src/tests/lib/libm/t_ilogb.c Wed Aug 24 06:04:53 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ilogb.c,v 1.4 2016/08/24 09:13:44 christos Exp $ */ +/* $NetBSD: t_ilogb.c,v 1.5 2016/08/24 10:04:53 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -40,15 +40,15 @@ #else # define ATF_CHECK_RAISED_INVALID do { \ - int r; \ - r = feclearexcept(FE_ALL_EXCEPT); \ - ATF_CHECK(r == FE_INVALID); \ + int r = fetestexcept(FE_ALL_EXCEPT); \ + ATF_CHECK_MSG(r == FE_INVALID, "r=%#x != %#x\n", r, FE_INVALID); \ + (void)feclearexcept(FE_ALL_EXCEPT); \ } while (/*CONSTCOND*/0) # define ATF_CHECK_RAISED_NOTHING do { \ - int r; \ - r = feclearexcept(FE_ALL_EXCEPT); \ - ATF_CHECK(r == 0); \ + int r = fetestexcept(FE_ALL_EXCEPT); \ + ATF_CHECK_MSG(r == 0, "r=%#x != 0\n", r); \ + (void)feclearexcept(FE_ALL_EXCEPT); \ } while (/*CONSTCOND*/0) #endif @@ -60,7 +60,6 @@ ATF_TC_HEAD(ilogb, tc) ATF_TC_BODY(ilogb, tc) { - atf_tc_expect_fail("PR lib/51427"); ATF_CHECK(ilogbf(0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID;
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Wed Aug 24 09:13:44 UTC 2016 Modified Files: src/tests/lib/libm: t_ilogb.c Log Message: fix long double To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_ilogb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ilogb.c diff -u src/tests/lib/libm/t_ilogb.c:1.3 src/tests/lib/libm/t_ilogb.c:1.4 --- src/tests/lib/libm/t_ilogb.c:1.3 Tue Aug 23 06:03:44 2016 +++ src/tests/lib/libm/t_ilogb.c Wed Aug 24 05:13:44 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ilogb.c,v 1.3 2016/08/23 10:03:44 christos Exp $ */ +/* $NetBSD: t_ilogb.c,v 1.4 2016/08/24 09:13:44 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -73,38 +73,48 @@ ATF_TC_BODY(ilogb, tc) ATF_CHECK_RAISED_INVALID; ATF_CHECK(ilogb(-0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(-0) == FP_ILOGB0); ATF_CHECK_RAISED_INVALID; +#endif ATF_CHECK(ilogbf(INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; ATF_CHECK(ilogb(INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; +#endif ATF_CHECK(ilogbf(-INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; ATF_CHECK(ilogb(-INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(-INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; +#endif ATF_CHECK(ilogbf(1024) == 10); ATF_CHECK_RAISED_NOTHING; ATF_CHECK(ilogb(1024) == 10); ATF_CHECK_RAISED_NOTHING; +#ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(1024) == 10); ATF_CHECK_RAISED_NOTHING; +#endif #ifndef __vax__ ATF_CHECK(ilogbf(NAN) == FP_ILOGBNAN); ATF_CHECK_RAISED_INVALID; ATF_CHECK(ilogb(NAN) == FP_ILOGBNAN); ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE ATF_CHECK(ilogbl(NAN) == FP_ILOGBNAN); ATF_CHECK_RAISED_INVALID; #endif +#endif } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Tue Aug 23 10:03:44 UTC 2016 Modified Files: src/tests/lib/libm: Makefile t_ilogb.c Log Message: portability fixes To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/tests/lib/libm/Makefile cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_ilogb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.38 src/tests/lib/libm/Makefile:1.39 --- src/tests/lib/libm/Makefile:1.38 Mon Aug 22 04:49:33 2016 +++ src/tests/lib/libm/Makefile Tue Aug 23 06:03:44 2016 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.38 2016/08/22 08:49:33 maya Exp $ +# $NetBSD: Makefile,v 1.39 2016/08/23 10:03:44 christos Exp $ .include @@ -9,6 +9,7 @@ COPTS+= -mfloat-ieee -mieee-with-inexact .endif CPPFLAGS.t_fenv.c+= -D__TEST_FENV +CPPFLAGS.t_ilogb.c+= -D__TEST_FENV CPPFLAGS.t_fmod.c+= -I${.CURDIR}/../libc/gen TESTS_C+= t_acos Index: src/tests/lib/libm/t_ilogb.c diff -u src/tests/lib/libm/t_ilogb.c:1.2 src/tests/lib/libm/t_ilogb.c:1.3 --- src/tests/lib/libm/t_ilogb.c:1.2 Mon Aug 22 06:36:20 2016 +++ src/tests/lib/libm/t_ilogb.c Tue Aug 23 06:03:44 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ilogb.c,v 1.2 2016/08/22 10:36:20 maya Exp $ */ +/* $NetBSD: t_ilogb.c,v 1.3 2016/08/23 10:03:44 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -33,17 +33,24 @@ #include #include -#define ATF_CHECK_RAISED_INVALID do { \ +#ifndef __HAVE_FENV + +# define ATF_CHECK_RAISED_INVALID +# define ATF_CHECK_RAISED_NOTHING + +#else +# define ATF_CHECK_RAISED_INVALID do { \ int r; \ r = feclearexcept(FE_ALL_EXCEPT); \ ATF_CHECK(r == FE_INVALID); \ - } while (0) +} while (/*CONSTCOND*/0) -#define ATF_CHECK_RAISED_NOTHING do { \ +# define ATF_CHECK_RAISED_NOTHING do { \ int r; \ r = feclearexcept(FE_ALL_EXCEPT); \ ATF_CHECK(r == 0); \ - } while (0) +} while (/*CONSTCOND*/0) +#endif ATF_TC(ilogb); ATF_TC_HEAD(ilogb, tc)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: maya Date: Mon Aug 22 10:36:20 UTC 2016 Modified Files: src/tests/lib/libm: t_ilogb.c Log Message: Mistakes were made, compare correct values now. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_ilogb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ilogb.c diff -u src/tests/lib/libm/t_ilogb.c:1.1 src/tests/lib/libm/t_ilogb.c:1.2 --- src/tests/lib/libm/t_ilogb.c:1.1 Mon Aug 22 08:49:33 2016 +++ src/tests/lib/libm/t_ilogb.c Mon Aug 22 10:36:20 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ilogb.c,v 1.1 2016/08/22 08:49:33 maya Exp $ */ +/* $NetBSD: t_ilogb.c,v 1.2 2016/08/22 10:36:20 maya Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -83,11 +83,11 @@ ATF_TC_BODY(ilogb, tc) ATF_CHECK(ilogbl(-INFINITY) == INT_MAX); ATF_CHECK_RAISED_INVALID; - ATF_CHECK(ilogbf(2^20) == 20); + ATF_CHECK(ilogbf(1024) == 10); ATF_CHECK_RAISED_NOTHING; - ATF_CHECK(ilogb(2^20) == 20); + ATF_CHECK(ilogb(1024) == 10); ATF_CHECK_RAISED_NOTHING; - ATF_CHECK(ilogbl(2^20) == 20); + ATF_CHECK(ilogbl(1024) == 10); ATF_CHECK_RAISED_NOTHING; #ifndef __vax__
CVS commit: src/tests/lib/libm
Module Name:src Committed By: gson Date: Sun Jan 24 20:26:47 UTC 2016 Modified Files: src/tests/lib/libm: Makefile Added Files: src/tests/lib/libm: t_hypot.c Log Message: Add some tests of hypot() and hypotf() To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/tests/lib/libm/Makefile cvs rdiff -u -r0 -r1.1 src/tests/lib/libm/t_hypot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.36 src/tests/lib/libm/Makefile:1.37 --- src/tests/lib/libm/Makefile:1.36 Tue Dec 22 14:27:51 2015 +++ src/tests/lib/libm/Makefile Sun Jan 24 20:26:47 2016 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.36 2015/12/22 14:27:51 christos Exp $ +# $NetBSD: Makefile,v 1.37 2016/01/24 20:26:47 gson Exp $ .include @@ -22,6 +22,7 @@ TESTS_C+= t_erf TESTS_C+= t_exp TESTS_C+= t_fenv TESTS_C+= t_fmod +TESTS_C+= t_hypot TESTS_C+= t_infinity TESTS_C+= t_ldexp TESTS_C+= t_log Added files: Index: src/tests/lib/libm/t_hypot.c diff -u /dev/null src/tests/lib/libm/t_hypot.c:1.1 --- /dev/null Sun Jan 24 20:26:47 2016 +++ src/tests/lib/libm/t_hypot.c Sun Jan 24 20:26:47 2016 @@ -0,0 +1,81 @@ +/* $NetBSD: t_hypot.c,v 1.1 2016/01/24 20:26:47 gson Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 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. + */ + +#include +#include + +ATF_TC(hypot_integer); +ATF_TC_HEAD(hypot_integer, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test hypot with integer args"); +} + +ATF_TC_BODY(hypot_integer, tc) +{ + /* volatile so hypotf() won't be evaluated at compile time */ + volatile double a = 5; + volatile double b = 12; + ATF_CHECK(hypot(a, b) == 13.0); +} + +ATF_TC(hypotf_integer); +ATF_TC_HEAD(hypotf_integer, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test hypotf with integer args"); +} + +ATF_TC_BODY(hypotf_integer, tc) +{ + volatile float a = 5; + volatile float b = 12; + ATF_CHECK(hypotf(a, b) == 13.0f); +} + +ATF_TC(pr50698); +ATF_TC_HEAD(pr50698, tc) +{ + atf_tc_set_md_var(tc, "descr", "Check for the bug of PR 50698"); +} + +ATF_TC_BODY(pr50698, tc) +{ + volatile float a = 1e-18f; + float val = hypotf(a, a); + ATF_CHECK(!isinf(val)); + ATF_CHECK(!isnan(val)); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, hypot_integer); + ATF_TP_ADD_TC(tp, hypotf_integer); + ATF_TP_ADD_TC(tp, pr50698); + + return atf_no_error(); +}
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Tue Dec 22 14:27:51 UTC 2015 Modified Files: src/tests/lib/libm: Makefile Log Message: add __TEST_FENV To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.35 src/tests/lib/libm/Makefile:1.36 --- src/tests/lib/libm/Makefile:1.35 Tue Dec 22 09:20:59 2015 +++ src/tests/lib/libm/Makefile Tue Dec 22 09:27:51 2015 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.35 2015/12/22 14:20:59 christos Exp $ +# $NetBSD: Makefile,v 1.36 2015/12/22 14:27:51 christos Exp $ .include @@ -8,6 +8,7 @@ TESTSDIR= ${TESTSBASE}/lib/libm COPTS+= -mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i .endif +CPPFLAGS.t_fenv.c+= -D__TEST_FENV CPPFLAGS.t_fmod.c+= -I${.CURDIR}/../libc/gen TESTS_C+= t_acos
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Tue Dec 22 14:20:59 UTC 2015 Modified Files: src/tests/lib/libm: Makefile t_fenv.c Log Message: put have fenv stuff elsewhere. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/tests/lib/libm/Makefile cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.34 src/tests/lib/libm/Makefile:1.35 --- src/tests/lib/libm/Makefile:1.34 Tue Dec 22 03:26:16 2015 +++ src/tests/lib/libm/Makefile Tue Dec 22 09:20:59 2015 @@ -1,17 +1,9 @@ -# $NetBSD: Makefile,v 1.34 2015/12/22 08:26:16 martin Exp $ +# $NetBSD: Makefile,v 1.35 2015/12/22 14:20:59 christos Exp $ .include TESTSDIR= ${TESTSBASE}/lib/libm -.if ${MACHINE_CPU} == "aarch64" || ${MACHINE_CPU} == "arm" \ -|| ${MACHINE_ARCH} == "hppa" || ${MACHINE_ARCH} == "powerpc" \ -|| ${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64" \ -|| ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" \ -|| ${MACHINE_ARCH} == "mips" -CPPFLAGS+= -DHAVE_FENV_H -.endif - .if ${MACHINE} == "alpha" COPTS+= -mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i .endif Index: src/tests/lib/libm/t_fenv.c diff -u src/tests/lib/libm/t_fenv.c:1.2 src/tests/lib/libm/t_fenv.c:1.3 --- src/tests/lib/libm/t_fenv.c:1.2 Mon Dec 29 14:51:53 2014 +++ src/tests/lib/libm/t_fenv.c Tue Dec 22 09:20:59 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fenv.c,v 1.2 2014/12/29 19:51:53 martin Exp $ */ +/* $NetBSD: t_fenv.c,v 1.3 2015/12/22 14:20:59 christos Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,15 +29,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fenv.c,v 1.2 2014/12/29 19:51:53 martin Exp $"); +__RCSID("$NetBSD: t_fenv.c,v 1.3 2015/12/22 14:20:59 christos Exp $"); #include -#ifdef HAVE_FENV_H +#include +#ifdef __HAVE_FENV #include #include -#include #if __arm__ && !__SOFTFP__
CVS commit: src/tests/lib/libm
Module Name:src Committed By: dholland Date: Tue Sep 8 05:24:27 UTC 2015 Modified Files: src/tests/lib/libm: t_pow.c Log Message: Clear the XFAIL from PR 45391. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_pow.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_pow.c diff -u src/tests/lib/libm/t_pow.c:1.3 src/tests/lib/libm/t_pow.c:1.4 --- src/tests/lib/libm/t_pow.c:1.3 Mon Mar 3 10:39:08 2014 +++ src/tests/lib/libm/t_pow.c Tue Sep 8 05:24:27 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: t_pow.c,v 1.3 2014/03/03 10:39:08 martin Exp $ */ +/* $NetBSD: t_pow.c,v 1.4 2015/09/08 05:24:27 dholland Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_pow.c,v 1.3 2014/03/03 10:39:08 martin Exp $"); +__RCSID("$NetBSD: t_pow.c,v 1.4 2015/09/08 05:24:27 dholland Exp $"); #include #include @@ -280,21 +280,18 @@ ATF_TC_BODY(pow_zero_x, tc) z = pow(+0.0, -4.0); if (z != HUGE_VAL) { - atf_tc_expect_fail("PR port-amd64/45391"); atf_tc_fail_nonfatal("pow(+0.0, -4.0) != HUGE_VAL"); } z = pow(-0.0, -4.0); if (z != HUGE_VAL) { - atf_tc_expect_fail("PR port-amd64/45391"); atf_tc_fail_nonfatal("pow(-0.0, -4.0) != HUGE_VAL"); } z = pow(+0.0, -5.0); if (z != HUGE_VAL) { - atf_tc_expect_fail("PR port-amd64/45391"); atf_tc_fail_nonfatal("pow(+0.0, -5.0) != HUGE_VAL"); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Mon Feb 9 19:39:48 UTC 2015 Modified Files: src/tests/lib/libm: t_log.c Log Message: Remove expected failure and references to port-alpha/46301, now that it is fixed. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libm/t_log.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_log.c diff -u src/tests/lib/libm/t_log.c:1.12 src/tests/lib/libm/t_log.c:1.13 --- src/tests/lib/libm/t_log.c:1.12 Tue Nov 4 00:20:19 2014 +++ src/tests/lib/libm/t_log.c Mon Feb 9 19:39:48 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: t_log.c,v 1.12 2014/11/04 00:20:19 justin Exp $ */ +/* $NetBSD: t_log.c,v 1.13 2015/02/09 19:39:48 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_log.c,v 1.12 2014/11/04 00:20:19 justin Exp $"); +__RCSID("$NetBSD: t_log.c,v 1.13 2015/02/09 19:39:48 martin Exp $"); #include @@ -186,10 +186,6 @@ ATF_TC_BODY(log10f_inf_pos, tc) { const float x = 1.0L / 0.0L; -#if defined(__alpha__) - atf_tc_expect_fail("PR port-alpha/46301"); -#endif - ATF_CHECK(log10f(x) == x); } @@ -562,10 +558,6 @@ ATF_TC_BODY(log2f_inf_pos, tc) { const float x = 1.0L / 0.0L; -#if defined(__alpha__) - atf_tc_expect_fail("PR port-alpha/46301"); -#endif - ATF_CHECK(log2f(x) == x); } @@ -766,10 +758,6 @@ ATF_TC_BODY(logf_inf_pos, tc) { const float x = 1.0L / 0.0L; -#if defined(__alpha__) - atf_tc_expect_fail("PR port-alpha/46301"); -#endif - ATF_CHECK(logf(x) == x); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: snj Date: Tue Jan 20 20:43:10 UTC 2015 Modified Files: src/tests/lib/libm: Makefile Log Message: Remove stale comment about ARM fenv support. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.31 src/tests/lib/libm/Makefile:1.32 --- src/tests/lib/libm/Makefile:1.31 Sat Jan 3 14:23:53 2015 +++ src/tests/lib/libm/Makefile Tue Jan 20 20:43:10 2015 @@ -1,10 +1,9 @@ -# $NetBSD: Makefile,v 1.31 2015/01/03 14:23:53 gson Exp $ +# $NetBSD: Makefile,v 1.32 2015/01/20 20:43:10 snj Exp $ .include TESTSDIR= ${TESTSBASE}/lib/libm -# ARM fenv is incomplete, so we can not enable that here .if ${MACHINE_CPU} == "aarch64" || ${MACHINE_CPU} == "arm" \ || ${MACHINE_ARCH} == "hppa" \ || ${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64" \
CVS commit: src/tests/lib/libm
Module Name:src Committed By: gson Date: Sat Jan 3 14:23:53 UTC 2015 Modified Files: src/tests/lib/libm: Makefile t_fmod.c Log Message: Mark the lib/libm/t_fmod test as an expected failure under QEMU, with a reference to PR misc/44767. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/tests/lib/libm/Makefile cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_fmod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.30 src/tests/lib/libm/Makefile:1.31 --- src/tests/lib/libm/Makefile:1.30 Sat Dec 27 17:55:05 2014 +++ src/tests/lib/libm/Makefile Sat Jan 3 14:23:53 2015 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.30 2014/12/27 17:55:05 martin Exp $ +# $NetBSD: Makefile,v 1.31 2015/01/03 14:23:53 gson Exp $ .include @@ -16,6 +16,8 @@ CPPFLAGS+= -DHAVE_FENV_H COPTS+= -mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i .endif +CPPFLAGS.t_fmod.c+= -I${.CURDIR}/../libc/gen + TESTS_C+= t_acos TESTS_C+= t_asin TESTS_C+= t_atan Index: src/tests/lib/libm/t_fmod.c diff -u src/tests/lib/libm/t_fmod.c:1.2 src/tests/lib/libm/t_fmod.c:1.3 --- src/tests/lib/libm/t_fmod.c:1.2 Thu Feb 27 17:26:02 2014 +++ src/tests/lib/libm/t_fmod.c Sat Jan 3 14:23:53 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fmod.c,v 1.2 2014/02/27 17:26:02 joerg Exp $ */ +/* $NetBSD: t_fmod.c,v 1.3 2015/01/03 14:23:53 gson Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -33,6 +33,8 @@ #include #include +#include "isqemu.h" + ATF_TC(fmod); ATF_TC_HEAD(fmod, tc) { @@ -41,6 +43,9 @@ ATF_TC_HEAD(fmod, tc) ATF_TC_BODY(fmod, tc) { + if (isQEMU()) + atf_tc_expect_fail("PR misc/44767"); + ATF_CHECK(fmodf(2.0, 1.0) == 0); ATF_CHECK(fmod(2.0, 1.0) == 0); ATF_CHECK(fmodl(2.0, 1.0) == 0);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Mon Dec 29 19:51:53 UTC 2014 Modified Files: src/tests/lib/libm: t_fenv.c Log Message: Skip rounding mode tests on ARM FPUs that do not allow configuration of them. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_fenv.c diff -u src/tests/lib/libm/t_fenv.c:1.1 src/tests/lib/libm/t_fenv.c:1.2 --- src/tests/lib/libm/t_fenv.c:1.1 Sun Dec 21 15:37:03 2014 +++ src/tests/lib/libm/t_fenv.c Mon Dec 29 19:51:53 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fenv.c,v 1.1 2014/12/21 15:37:03 martin Exp $ */ +/* $NetBSD: t_fenv.c,v 1.2 2014/12/29 19:51:53 martin Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fenv.c,v 1.1 2014/12/21 15:37:03 martin Exp $"); +__RCSID("$NetBSD: t_fenv.c,v 1.2 2014/12/29 19:51:53 martin Exp $"); #include @@ -46,13 +46,24 @@ __RCSID("$NetBSD: t_fenv.c,v 1.1 2014/12 * skip these tests if running on them and compiled for * hard float. */ -#define FPU_PREREQ() \ +#define FPU_EXC_PREREQ() \ if (0 == fpsetmask(fpsetmask(FP_X_INV))) \ atf_tc_skip("FPU does not implement exception handling"); + + /* + * Same as above: some don't allow configuring the rounding mode. + */ +#define FPU_RND_PREREQ() \ + if (0 == fpsetround(fpsetround(FP_RZ)))\ + atf_tc_skip("FPU does not implement configurable " \ + "rounding modes"); #endif -#ifndef FPU_PREREQ -#define FPU_PREREQ() /* nothing */ +#ifndef FPU_EXC_PREREQ +#define FPU_EXC_PREREQ() /* nothing */ +#endif +#ifndef FPU_RND_PREREQ +#define FPU_RND_PREREQ() /* nothing */ #endif @@ -67,6 +78,8 @@ ATF_TC_HEAD(fegetround, tc) ATF_TC_BODY(fegetround, tc) { + FPU_RND_PREREQ(); + fpsetround(FP_RZ); ATF_CHECK(fegetround() == FE_TOWARDZERO); fpsetround(FP_RM); @@ -88,6 +101,8 @@ ATF_TC_HEAD(fesetround, tc) ATF_TC_BODY(fesetround, tc) { + FPU_RND_PREREQ(); + fesetround(FE_TOWARDZERO); ATF_CHECK(fpgetround() == FP_RZ); fesetround(FE_DOWNWARD); @@ -109,7 +124,7 @@ ATF_TC_HEAD(fegetexcept, tc) ATF_TC_BODY(fegetexcept, tc) { - FPU_PREREQ(); + FPU_EXC_PREREQ(); fpsetmask(0); ATF_CHECK(fegetexcept() == 0); @@ -145,7 +160,7 @@ ATF_TC_HEAD(feenableexcept, tc) ATF_TC_BODY(feenableexcept, tc) { - FPU_PREREQ(); + FPU_EXC_PREREQ(); fedisableexcept(FE_ALL_EXCEPT); ATF_CHECK(fpgetmask() == 0);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Sat Dec 27 17:55:05 UTC 2014 Modified Files: src/tests/lib/libm: Makefile Log Message: Enable fenv.h on arm again To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.29 src/tests/lib/libm/Makefile:1.30 --- src/tests/lib/libm/Makefile:1.29 Sat Dec 27 16:54:03 2014 +++ src/tests/lib/libm/Makefile Sat Dec 27 17:55:05 2014 @@ -1,11 +1,11 @@ -# $NetBSD: Makefile,v 1.29 2014/12/27 16:54:03 martin Exp $ +# $NetBSD: Makefile,v 1.30 2014/12/27 17:55:05 martin Exp $ .include TESTSDIR= ${TESTSBASE}/lib/libm # ARM fenv is incomplete, so we can not enable that here -.if ${MACHINE_CPU} == "aarch64" \ +.if ${MACHINE_CPU} == "aarch64" || ${MACHINE_CPU} == "arm" \ || ${MACHINE_ARCH} == "hppa" \ || ${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64" \ || ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Mon Dec 22 11:21:08 UTC 2014 Modified Files: src/tests/lib/libm: Makefile Log Message: Disabel fenv tests for arm, the implementation is incomplete. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.27 src/tests/lib/libm/Makefile:1.28 --- src/tests/lib/libm/Makefile:1.27 Sun Dec 21 15:37:03 2014 +++ src/tests/lib/libm/Makefile Mon Dec 22 11:21:08 2014 @@ -1,10 +1,11 @@ -# $NetBSD: Makefile,v 1.27 2014/12/21 15:37:03 martin Exp $ +# $NetBSD: Makefile,v 1.28 2014/12/22 11:21:08 martin Exp $ .include TESTSDIR= ${TESTSBASE}/lib/libm -.if ${MACHINE_CPU} == "aarch64" || ${MACHINE_CPU} == "arm" \ +# ARM fenv is incomplete, so we can not enable that here +.if ${MACHINE_CPU} == "aarch64" \ || ${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64" \ || ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" CPPFLAGS+= -DHAVE_FENV_H
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Sun Dec 21 15:37:03 UTC 2014 Modified Files: src/tests/lib/libm: Makefile Added Files: src/tests/lib/libm: t_fenv.c Log Message: Add a test program for basic fenv.h rounding mode/exception mask testing. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/tests/lib/libm/Makefile cvs rdiff -u -r0 -r1.1 src/tests/lib/libm/t_fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.26 src/tests/lib/libm/Makefile:1.27 --- src/tests/lib/libm/Makefile:1.26 Sun Aug 10 11:30:51 2014 +++ src/tests/lib/libm/Makefile Sun Dec 21 15:37:03 2014 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.26 2014/08/10 11:30:51 martin Exp $ +# $NetBSD: Makefile,v 1.27 2014/12/21 15:37:03 martin Exp $ .include @@ -23,6 +23,7 @@ TESTS_C+= t_cos TESTS_C+= t_cosh TESTS_C+= t_erf TESTS_C+= t_exp +TESTS_C+= t_fenv TESTS_C+= t_fmod TESTS_C+= t_infinity TESTS_C+= t_ldexp Added files: Index: src/tests/lib/libm/t_fenv.c diff -u /dev/null src/tests/lib/libm/t_fenv.c:1.1 --- /dev/null Sun Dec 21 15:37:03 2014 +++ src/tests/lib/libm/t_fenv.c Sun Dec 21 15:37:03 2014 @@ -0,0 +1,205 @@ +/* $NetBSD: t_fenv.c,v 1.1 2014/12/21 15:37:03 martin Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Martin Husemann. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 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. + */ +#include +__RCSID("$NetBSD: t_fenv.c,v 1.1 2014/12/21 15:37:03 martin Exp $"); + +#include + +#ifdef HAVE_FENV_H + +#include +#include +#include + + +#if __arm__ && !__SOFTFP__ + /* + * Some NEON fpus do not implement IEEE exception handling, + * skip these tests if running on them and compiled for + * hard float. + */ +#define FPU_PREREQ() \ + if (0 == fpsetmask(fpsetmask(FP_X_INV))) \ + atf_tc_skip("FPU does not implement exception handling"); +#endif + +#ifndef FPU_PREREQ +#define FPU_PREREQ() /* nothing */ +#endif + + +ATF_TC(fegetround); + +ATF_TC_HEAD(fegetround, tc) +{ + atf_tc_set_md_var(tc, "descr", + "verify the fegetround() function agrees with the legacy " + "fpsetround"); +} + +ATF_TC_BODY(fegetround, tc) +{ + fpsetround(FP_RZ); + ATF_CHECK(fegetround() == FE_TOWARDZERO); + fpsetround(FP_RM); + ATF_CHECK(fegetround() == FE_DOWNWARD); + fpsetround(FP_RN); + ATF_CHECK(fegetround() == FE_TONEAREST); + fpsetround(FP_RP); + ATF_CHECK(fegetround() == FE_UPWARD); +} + +ATF_TC(fesetround); + +ATF_TC_HEAD(fesetround, tc) +{ + atf_tc_set_md_var(tc, "descr", + "verify the fesetround() function agrees with the legacy " + "fpgetround"); +} + +ATF_TC_BODY(fesetround, tc) +{ + fesetround(FE_TOWARDZERO); + ATF_CHECK(fpgetround() == FP_RZ); + fesetround(FE_DOWNWARD); + ATF_CHECK(fpgetround() == FP_RM); + fesetround(FE_TONEAREST); + ATF_CHECK(fpgetround() == FP_RN); + fesetround(FE_UPWARD); + ATF_CHECK(fpgetround() == FP_RP); +} + +ATF_TC(fegetexcept); + +ATF_TC_HEAD(fegetexcept, tc) +{ + atf_tc_set_md_var(tc, "descr", + "verify the fegetexcept() function agrees with the legacy " + "fpsetmask()"); +} + +ATF_TC_BODY(fegetexcept, tc) +{ + FPU_PREREQ(); + + fpsetmask(0); + ATF_CHECK(fegetexcept() == 0); + + fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP); + ATF_CHECK(fegetexcept() == (FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW + |FE_UNDERFLOW|FE_INEXACT)); + + fpsetmask(FP_X_INV); + ATF_CHECK(fegetexcept() == FE_INVALID); + + fpsetmask(FP_X_DZ); + ATF_CHECK(fegetexcept() == FE_DIVBYZERO); + + fpsetmask(FP_X_OFL); + ATF_CHECK(feg
CVS commit: src/tests/lib/libm
Module Name:src Committed By: gson Date: Tue Oct 7 16:53:44 UTC 2014 Modified Files: src/tests/lib/libm: t_exp.c Log Message: In the exp2_values test case, provide separate expected return values for the float case, reflecting the actual exp2f() argument value after rounding to float precision. Fixes PR lib/49256. Thanks to Makoto Kamada and Tetsuya Isaki for the analysis. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_exp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_exp.c diff -u src/tests/lib/libm/t_exp.c:1.7 src/tests/lib/libm/t_exp.c:1.8 --- src/tests/lib/libm/t_exp.c:1.7 Mon Mar 17 11:08:11 2014 +++ src/tests/lib/libm/t_exp.c Tue Oct 7 16:53:44 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exp.c,v 1.7 2014/03/17 11:08:11 martin Exp $ */ +/* $NetBSD: t_exp.c,v 1.8 2014/10/07 16:53:44 gson Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -141,42 +141,40 @@ ATF_LIBM_TEST(exp2_values, "Test exp2(x) { static const struct { double x; - double y; + double d_y; + float f_y; double d_eps; double f_eps; } v[] = { #if __DBL_MAX_EXP__ > 128 /* The largest double constant */ - { 0x1.fp9, 0x1.ffd3ap1023, + { 0x1.fp9, 0x1.ffd3ap1023, 0.00, 0x1p969, 0.0 }, /* The largest float constant */ - { 0x1.fep6, 0x1.4ep+127, 6e30, 0.0 }, + { 0x1.fep6, 0x1.4ep+127, 0x1.4ep+127, 6e30, 0.0 }, #endif #ifdef T_LIBM_PLUS_INF - { T_LIBM_PLUS_INF, T_LIBM_PLUS_INF, 0.0, 0.0 }, + { T_LIBM_PLUS_INF, T_LIBM_PLUS_INF, T_LIBM_PLUS_INF, 0.0, 0.0 }, #endif /* The few values from the old tests */ /* Results from i386/amd64, d_eps needed on i386 */ - { 1.1, 0x1.125fbee250664p+1, 0x1p-52, 0x1.8p-22 }, - { 2.2, 0x1.2611186bae675p+2, 0x1p-51, 0x1.8p-21 }, - { 3.3, 0x1.3b2c47bff8328p+3, 0x1p-50, 0x1.8p-20 }, - { 4.4, 0x1.51cb453b9536ep+4, 0x1p-49, 0x1.8p-19 }, - { 5.5, 0x1.6a09e667f3bcdp+5, 0x1p-48, 0x1.8p-18 }, - { 6.6, 0x1.8406003b2ae5bp+6, 0x1p-47, 0x1.8p-17 }, - /* - * These two currently fail for 'float'. - * 8.8 is definitely out by more than it should be. - */ - { 7.7, 0x1.9fdf8bcce533ep+7, 0x1p-46, 0x1.8p-16 }, - { 8.8, 0x1.bdb8cdadbe124p+8, 0x1p-45, 0x1.8p-15 }, + /* f_y values calculated using py-mpmath */ + { 1.1, 0x1.125fbee250664p+1, 0x1.125fc0p+1, 0x1p-52, 0x1.8p-22 }, + { 2.2, 0x1.2611186bae675p+2, 0x1.26111ap+2, 0x1p-51, 0x1.8p-21 }, + { 3.3, 0x1.3b2c47bff8328p+3, 0x1.3b2c48p+3, 0x1p-50, 0x1.8p-20 }, + { 4.4, 0x1.51cb453b9536ep+4, 0x1.51cb46p+4, 0x1p-49, 0x1.8p-19 }, + { 5.5, 0x1.6a09e667f3bcdp+5, 0x1.6a09e6p+5, 0x1p-48, 0x1.8p-18 }, + { 6.6, 0x1.8406003b2ae5bp+6, 0x1.8405fep+6, 0x1p-47, 0x1.8p-17 }, + { 7.7, 0x1.9fdf8bcce533ep+7, 0x1.9fdf88p+7, 0x1p-46, 0x1.8p-16 }, + { 8.8, 0x1.bdb8cdadbe124p+8, 0x1.bdb8d2p+8, 0x1p-45, 0x1.8p-15 }, }; unsigned int i; for (i = 0; i < __arraycount(v); i++) { - T_LIBM_CHECK(i, exp2, v[i].x, v[i].y, v[i].d_eps); + T_LIBM_CHECK(i, exp2, v[i].x, v[i].d_y, v[i].d_eps); if (i > 1) - T_LIBM_CHECK(i, exp2f, v[i].x, v[i].y, v[i].f_eps); + T_LIBM_CHECK(i, exp2f, v[i].x, v[i].f_y, v[i].f_eps); } }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Sun May 18 10:47:38 UTC 2014 Modified Files: src/tests/lib/libm: Makefile Log Message: Re-enable alpha IEEE compiler options To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.23 src/tests/lib/libm/Makefile:1.24 --- src/tests/lib/libm/Makefile:1.23 Mon May 5 18:08:33 2014 +++ src/tests/lib/libm/Makefile Sun May 18 10:47:38 2014 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.23 2014/05/05 18:08:33 martin Exp $ +# $NetBSD: Makefile,v 1.24 2014/05/18 10:47:38 martin Exp $ .include @@ -11,7 +11,7 @@ CPPFLAGS+= -DHAVE_FENV_H .endif .if ${MACHINE} == "alpha" -# COPTS+= -mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i +COPTS+= -mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i .endif TESTS_C+= t_acos
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Mon Apr 28 08:46:35 UTC 2014 Modified Files: src/tests/lib/libm: Makefile Log Message: Tune COPTS for alpha To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.21 src/tests/lib/libm/Makefile:1.22 --- src/tests/lib/libm/Makefile:1.21 Mon Mar 3 12:15:27 2014 +++ src/tests/lib/libm/Makefile Mon Apr 28 08:46:35 2014 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.21 2014/03/03 12:15:27 martin Exp $ +# $NetBSD: Makefile,v 1.22 2014/04/28 08:46:35 martin Exp $ .include @@ -10,6 +10,10 @@ TESTSDIR= ${TESTSBASE}/lib/libm CPPFLAGS+= -DHAVE_FENV_H .endif +.if ${MACHINE} == "alpha" +COPTS+= -mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i +.endif + TESTS_C+= t_acos TESTS_C+= t_asin TESTS_C+= t_atan
CVS commit: src/tests/lib/libm
Module Name:src Committed By: joerg Date: Tue Mar 25 17:30:15 UTC 2014 Modified Files: src/tests/lib/libm: t_libm.h Log Message: Consistently use long double. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_libm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_libm.h diff -u src/tests/lib/libm/t_libm.h:1.5 src/tests/lib/libm/t_libm.h:1.6 --- src/tests/lib/libm/t_libm.h:1.5 Sun Mar 16 22:49:27 2014 +++ src/tests/lib/libm/t_libm.h Tue Mar 25 17:30:14 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_libm.h,v 1.5 2014/03/16 22:49:27 dsl Exp $ */ +/* $NetBSD: t_libm.h,v 1.6 2014/03/25 17:30:14 joerg Exp $ */ /* * Check result of fn(arg) is correct within the bounds. @@ -7,12 +7,15 @@ * be out of range for the function - so save and print as 'long double'. * (otherwise you can get 'inf != inf' reported!) */ -#define T_LIBM_CHECK(subtest, fn, arg, expect, epsilon) do { \ +#define T_LIBM_CHECK(subtest, fn, arg, expect_, epsilon_) do { \ + long double epsilon = epsilon_; \ + long double expect = expect_; \ long double r = fn(arg); \ - double e = fabs(r - expect); \ + long double e = fabsl(r - expect); \ if (r != expect && e > epsilon) \ atf_tc_fail_nonfatal( \ - "subtest %u: " #fn "(%g) is %Lg (%.14La) not %g (%.13a), error %g (%.6a) > %g", \ + "subtest %u: " #fn "(%g) is %Lg (%.14La) " \ + "not %Lg (%.13La), error %Lg (%.6La) > %Lg", \ subtest, arg, r, r, expect, expect, e, e, epsilon); \ } while (0)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Mon Mar 17 11:08:11 UTC 2014 Modified Files: src/tests/lib/libm: t_atan.c t_exp.c Log Message: Handle VAX To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libm/t_atan.c cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_exp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_atan.c diff -u src/tests/lib/libm/t_atan.c:1.14 src/tests/lib/libm/t_atan.c:1.15 --- src/tests/lib/libm/t_atan.c:1.14 Sat Mar 8 17:05:47 2014 +++ src/tests/lib/libm/t_atan.c Mon Mar 17 11:08:11 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_atan.c,v 1.14 2014/03/08 17:05:47 martin Exp $ */ +/* $NetBSD: t_atan.c,v 1.15 2014/03/17 11:08:11 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -57,11 +57,11 @@ static const struct { */ ATF_LIBM_TEST(atan_nan, "Test atan/atanf(NaN) == NaN") { -#ifdef __vax__ - atf_tc_skip("no NaN in vax floating point format"); -#else +#ifdef T_LIBM_NAN T_LIBM_CHECK_NAN(0, atan, T_LIBM_NAN); T_LIBM_CHECK_NAN(0, atanf, T_LIBM_NAN); +#else + atf_tc_skip("no NaN on this machine"); #endif } Index: src/tests/lib/libm/t_exp.c diff -u src/tests/lib/libm/t_exp.c:1.6 src/tests/lib/libm/t_exp.c:1.7 --- src/tests/lib/libm/t_exp.c:1.6 Sun Mar 16 22:51:19 2014 +++ src/tests/lib/libm/t_exp.c Mon Mar 17 11:08:11 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exp.c,v 1.6 2014/03/16 22:51:19 dsl Exp $ */ +/* $NetBSD: t_exp.c,v 1.7 2014/03/17 11:08:11 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -55,14 +55,22 @@ static const struct { */ ATF_LIBM_TEST(exp2_is_nan, "Test exp2(x) == NaN") { +#ifdef T_LIBM_NAN T_LIBM_CHECK_NAN(0, exp2, T_LIBM_NAN); T_LIBM_CHECK_NAN(0, exp2f, T_LIBM_NAN); +#else + atf_tc_skip("no NaN on this machine"); +#endif } ATF_LIBM_TEST(exp2_is_plus_zero, "Test exp2(x) == +0.0") { +#ifdef T_LIBM_MINUS_INF T_LIBM_CHECK_PLUS_ZERO(0, exp2, T_LIBM_MINUS_INF); T_LIBM_CHECK_PLUS_ZERO(0, exp2f, T_LIBM_MINUS_INF); +#else + atf_tc_skip("no +/-Inf on this machine"); +#endif } ATF_LIBM_TEST(exp2_powers, "Test exp2(x) is correct for some integer x") @@ -79,7 +87,10 @@ ATF_LIBM_TEST(exp2_powers, "Test exp2(x) { 100, 0x1p100, 0x1p100 }, { 125, 0x1p125, 0x1p125 }, { 126, 0x1p126, 0x1p126 }, +#if __DBL_MAX_EXP__ > 129 { 127, 0x1p127, 0x1p127 }, +#endif +#ifdef T_LIBM_PLUS_INF { 128, 0x1p128, T_LIBM_PLUS_INF }, { 129, 0x1p129, T_LIBM_PLUS_INF }, { 1000, 0x1p1000, T_LIBM_PLUS_INF }, @@ -92,11 +103,13 @@ ATF_LIBM_TEST(exp2_powers, "Test exp2(x) { 16383, T_LIBM_PLUS_INF, T_LIBM_PLUS_INF }, { 16384, T_LIBM_PLUS_INF, T_LIBM_PLUS_INF }, { 16385, T_LIBM_PLUS_INF, T_LIBM_PLUS_INF }, +#endif { -1, 0x1p-1, 0x1p-1 }, { -2, 0x1p-2, 0x1p-2 }, { -100, 0x1p-100, 0x1p-100 }, { -127, 0x1p-127, 0x1p-127 }, { -128, 0x1p-128, 0x1p-128 }, +#if __LDBL_MIN_EXP__ < -129 { -300, 0x1p-300, 0.0}, { -400, 0x1p-400, 0.0}, {-1000, 0x1p-1000, 0.0}, @@ -108,6 +121,7 @@ ATF_LIBM_TEST(exp2_powers, "Test exp2(x) {-1060, 0x1p-1060, 0.0}, /* This is the smallest result gcc will allow */ {-1074, 0x1p-1074, 0.0}, +#endif {-1075, 0x0, 0.0}, {-1080, 0x0, 0.0}, {-2000, 0x0, 0.0}, @@ -131,12 +145,14 @@ ATF_LIBM_TEST(exp2_values, "Test exp2(x) double d_eps; double f_eps; } v[] = { +#if __DBL_MAX_EXP__ > 128 /* The largest double constant */ { 0x1.fp9, 0x1.ffd3ap1023, 0x1p969, 0.0 }, /* The largest float constant */ { 0x1.fep6, 0x1.4ep+127, 6e30, 0.0 }, -#ifndef __vax__ +#endif +#ifdef T_LIBM_PLUS_INF { T_LIBM_PLUS_INF, T_LIBM_PLUS_INF, 0.0, 0.0 }, #endif
CVS commit: src/tests/lib/libm
Module Name:src Committed By: dsl Date: Sun Mar 16 22:51:19 UTC 2014 Modified Files: src/tests/lib/libm: t_exp.c Log Message: Add a lot more tests for exp2() and exp2f(). exp2f(7.7) and exp2f(8.8) seem too far from their expected values (especially the latter). exp2(-1023) and below are badly broken. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_exp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_exp.c diff -u src/tests/lib/libm/t_exp.c:1.5 src/tests/lib/libm/t_exp.c:1.6 --- src/tests/lib/libm/t_exp.c:1.5 Mon Mar 3 10:39:08 2014 +++ src/tests/lib/libm/t_exp.c Sun Mar 16 22:51:19 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exp.c,v 1.5 2014/03/03 10:39:08 martin Exp $ */ +/* $NetBSD: t_exp.c,v 1.6 2014/03/16 22:51:19 dsl Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -31,6 +31,7 @@ #include #include +#include "t_libm.h" /* y = exp(x) */ static const struct { @@ -50,197 +51,119 @@ static const struct { }; /* - * exp2(3) + * exp2/exp2f(3) */ -ATF_TC(exp2_nan); -ATF_TC_HEAD(exp2_nan, tc) +ATF_LIBM_TEST(exp2_is_nan, "Test exp2(x) == NaN") { - atf_tc_set_md_var(tc, "descr", "Test exp2(NaN) == NaN"); + T_LIBM_CHECK_NAN(0, exp2, T_LIBM_NAN); + T_LIBM_CHECK_NAN(0, exp2f, T_LIBM_NAN); } -ATF_TC_BODY(exp2_nan, tc) +ATF_LIBM_TEST(exp2_is_plus_zero, "Test exp2(x) == +0.0") { - const double x = 0.0L / 0.0L; - - if (isnan(exp2(x)) == 0) - atf_tc_fail_nonfatal("exp2(NaN) != NaN"); -} - -ATF_TC(exp2_inf_neg); -ATF_TC_HEAD(exp2_inf_neg, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test exp2(-Inf) == +0.0"); -} - -ATF_TC_BODY(exp2_inf_neg, tc) -{ - const double x = -1.0L / 0.0L; - double y = exp2(x); - - if (fabs(y) > 0.0 || signbit(y) != 0) - atf_tc_fail_nonfatal("exp2(-Inf) != +0.0"); -} - -ATF_TC(exp2_inf_pos); -ATF_TC_HEAD(exp2_inf_pos, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test exp2(+Inf) == +Inf"); -} - -ATF_TC_BODY(exp2_inf_pos, tc) -{ - const double x = 1.0L / 0.0L; - double y = exp2(x); - - if (isinf(y) == 0 || signbit(y) != 0) - atf_tc_fail_nonfatal("exp2(+Inf) != +Inf"); -} - -ATF_TC(exp2_product); -ATF_TC_HEAD(exp2_product, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test exp2(x + y) == exp2(x) * exp2(y)"); -} - -ATF_TC_BODY(exp2_product, tc) -{ - const double x[] = { 0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8 }; - const double y[] = { 8.8, 7.7, 6.6, 5.5, 4.4, 3.3, 2.2, 1.1, 0.0 }; - const double eps = 1.0e-11; - size_t i; - - for (i = 0; i < __arraycount(x); i++) { - - if (fabs(exp2(x[i] + y[i]) - (exp2(x[i]) * exp2(y[i]))) > eps) - atf_tc_fail_nonfatal("exp2(%0.01f + %0.01f) != exp2(" - "%0.01f) * exp2(%0.01f)", x[i], y[i], x[i], y[i]); + T_LIBM_CHECK_PLUS_ZERO(0, exp2, T_LIBM_MINUS_INF); + T_LIBM_CHECK_PLUS_ZERO(0, exp2f, T_LIBM_MINUS_INF); +} + +ATF_LIBM_TEST(exp2_powers, "Test exp2(x) is correct for some integer x") +{ + static const struct { + double x; + double d_y; + double f_y; + } v[] = { + { +0.0, 1.0, 1.0 }, + { -0.0, 1.0, 1.0 }, + {1, 0x1p1, 0x1p1 }, + {2, 0x1p2, 0x1p2 }, + { 100, 0x1p100, 0x1p100 }, + { 125, 0x1p125, 0x1p125 }, + { 126, 0x1p126, 0x1p126 }, + { 127, 0x1p127, 0x1p127 }, + { 128, 0x1p128, T_LIBM_PLUS_INF }, + { 129, 0x1p129, T_LIBM_PLUS_INF }, + { 1000, 0x1p1000, T_LIBM_PLUS_INF }, + { 1020, 0x1p1020, T_LIBM_PLUS_INF }, + { 1023, 0x1p1023, T_LIBM_PLUS_INF }, + { 1024, T_LIBM_PLUS_INF, T_LIBM_PLUS_INF }, + { 1030, T_LIBM_PLUS_INF, T_LIBM_PLUS_INF }, + { 1050, T_LIBM_PLUS_INF, T_LIBM_PLUS_INF }, + { 2000, T_LIBM_PLUS_INF, T_LIBM_PLUS_INF }, + { 16383, T_LIBM_PLUS_INF, T_LIBM_PLUS_INF }, + { 16384, T_LIBM_PLUS_INF, T_LIBM_PLUS_INF }, + { 16385, T_LIBM_PLUS_INF, T_LIBM_PLUS_INF }, + { -1, 0x1p-1, 0x1p-1 }, + { -2, 0x1p-2, 0x1p-2 }, + { -100, 0x1p-100, 0x1p-100 }, + { -127, 0x1p-127, 0x1p-127 }, + { -128, 0x1p-128, 0x1p-128 }, + { -300, 0x1p-300, 0.0}, + { -400, 0x1p-400, 0.0}, + {-1000, 0x1p-1000, 0.0}, + {-1022, 0x1p-1022, 0.0}, + /* These should be denormal numbers */ + {-1023, 0x1p-1023, 0.0}, + {-1024, 0x1p-1024, 0.0}, + {-1040, 0x1p-1040, 0.0}, + {-1060, 0x1p-1060, 0.0}, + /* This is the smallest result gcc will allow */ + {-1074, 0x1p-1074, 0.0}, + {-1075, 0x0, 0.0}, + {-1080, 0x0, 0.0}, + {-2000, 0x0, 0.0}, + {-16382, 0x0, 0.0}, + {-16383, 0x0, 0.0}, + {-16384, 0x0, 0.0}, + }; + unsigned int i; + + for (i = 0; i < __arraycount(v); i++) { + T_LIBM_CHECK(i, exp2, v[i].x, v[i].d_y, 0.0); + T_LIBM_CHECK(i, exp2f, v[i].x, v[i].f_y, 0.0); } } -ATF_TC(exp2_zero_neg); -ATF_TC_HEAD(exp2_zero_neg, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test exp2(-0.0) == 1.0"); -} - -ATF_TC_BODY(exp2_zero_neg, tc) -{ - const double x = -0.0L; - - if (fabs(exp2(x) - 1.0) > 0.0) - atf_tc_fail_nonfa
CVS commit: src/tests/lib/libm
Module Name:src Committed By: dsl Date: Sun Mar 16 22:49:27 UTC 2014 Modified Files: src/tests/lib/libm: t_libm.h Log Message: Print the result as a 'long double' - on i386 a return value that should be infinity might just be too large for 'double' and won't get converted until it has to be saved to memory. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_libm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_libm.h diff -u src/tests/lib/libm/t_libm.h:1.4 src/tests/lib/libm/t_libm.h:1.5 --- src/tests/lib/libm/t_libm.h:1.4 Sun Mar 16 18:42:21 2014 +++ src/tests/lib/libm/t_libm.h Sun Mar 16 22:49:27 2014 @@ -1,15 +1,18 @@ -/* $NetBSD: t_libm.h,v 1.4 2014/03/16 18:42:21 dsl Exp $ */ +/* $NetBSD: t_libm.h,v 1.5 2014/03/16 22:49:27 dsl Exp $ */ /* * Check result of fn(arg) is correct within the bounds. * Should be ok to do the checks using 'double' for 'float' functions. + * On i386 float and double values are returned on the x87 stack and might + * be out of range for the function - so save and print as 'long double'. + * (otherwise you can get 'inf != inf' reported!) */ #define T_LIBM_CHECK(subtest, fn, arg, expect, epsilon) do { \ - double r = fn(arg); \ + long double r = fn(arg); \ double e = fabs(r - expect); \ if (r != expect && e > epsilon) \ atf_tc_fail_nonfatal( \ - "subtest %u: " #fn "(%g) is %g (%.13a) not %g (%.13a), error %g (%.6a) > %g", \ + "subtest %u: " #fn "(%g) is %Lg (%.14La) not %g (%.13a), error %g (%.6a) > %g", \ subtest, arg, r, r, expect, expect, e, e, epsilon); \ } while (0)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: dsl Date: Sun Mar 16 18:42:21 UTC 2014 Modified Files: src/tests/lib/libm: t_libm.h Log Message: Check that the result isn't equaly to the expected value before checking the absolute size of the error term. If the expected result is +/-infinity it should compare equal, but the result of the subtract may not be zero. Also print the result and error values in fp hex to make it easier to see how may lsb bits are incorrect. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_libm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_libm.h diff -u src/tests/lib/libm/t_libm.h:1.3 src/tests/lib/libm/t_libm.h:1.4 --- src/tests/lib/libm/t_libm.h:1.3 Fri Mar 7 12:46:47 2014 +++ src/tests/lib/libm/t_libm.h Sun Mar 16 18:42:21 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_libm.h,v 1.3 2014/03/07 12:46:47 martin Exp $ */ +/* $NetBSD: t_libm.h,v 1.4 2014/03/16 18:42:21 dsl Exp $ */ /* * Check result of fn(arg) is correct within the bounds. @@ -7,10 +7,10 @@ #define T_LIBM_CHECK(subtest, fn, arg, expect, epsilon) do { \ double r = fn(arg); \ double e = fabs(r - expect); \ - if (e > epsilon) \ + if (r != expect && e > epsilon) \ atf_tc_fail_nonfatal( \ - "subtest %u: " #fn "(%g) is %g not %g (error %g > %g)", \ - subtest, arg, r, expect, e, epsilon); \ + "subtest %u: " #fn "(%g) is %g (%.13a) not %g (%.13a), error %g (%.6a) > %g", \ + subtest, arg, r, r, expect, expect, e, e, epsilon); \ } while (0) /* Check that the result of fn(arg) is NaN */
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Wed Mar 12 21:40:07 UTC 2014 Modified Files: src/tests/lib/libm: t_ldexp.c t_sqrt.c Log Message: Avoid double constants out of range To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libm/t_ldexp.c cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_sqrt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ldexp.c diff -u src/tests/lib/libm/t_ldexp.c:1.12 src/tests/lib/libm/t_ldexp.c:1.13 --- src/tests/lib/libm/t_ldexp.c:1.12 Mon Mar 3 10:39:08 2014 +++ src/tests/lib/libm/t_ldexp.c Wed Mar 12 21:40:07 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ldexp.c,v 1.12 2014/03/03 10:39:08 martin Exp $ */ +/* $NetBSD: t_ldexp.c,v 1.13 2014/03/12 21:40:07 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_ldexp.c,v 1.12 2014/03/03 10:39:08 martin Exp $"); +__RCSID("$NetBSD: t_ldexp.c,v 1.13 2014/03/12 21:40:07 martin Exp $"); #include @@ -196,7 +196,11 @@ ATF_TC_HEAD(ldexp_exp2, tc) ATF_TC_BODY(ldexp_exp2, tc) { const double n[] = { 1, 2, 3, 10, 50, 100 }; +#if __DBL_MIN_10_EXP__ <= -40 const double eps = 1.0e-40; +#else + const double eps = __DBL_MIN__*4.0; +#endif const double x = 12.0; double y; size_t i; Index: src/tests/lib/libm/t_sqrt.c diff -u src/tests/lib/libm/t_sqrt.c:1.6 src/tests/lib/libm/t_sqrt.c:1.7 --- src/tests/lib/libm/t_sqrt.c:1.6 Mon Mar 3 10:39:08 2014 +++ src/tests/lib/libm/t_sqrt.c Wed Mar 12 21:40:07 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sqrt.c,v 1.6 2014/03/03 10:39:08 martin Exp $ */ +/* $NetBSD: t_sqrt.c,v 1.7 2014/03/12 21:40:07 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_sqrt.c,v 1.6 2014/03/03 10:39:08 martin Exp $"); +__RCSID("$NetBSD: t_sqrt.c,v 1.7 2014/03/12 21:40:07 martin Exp $"); #include #include @@ -62,7 +62,11 @@ ATF_TC_HEAD(sqrt_pow, tc) ATF_TC_BODY(sqrt_pow, tc) { const double x[] = { 0.0, 0.005, 1.0, 99.0, 123.123, . }; +#if __DBL_MIN_10_EXP__ <= -40 const double eps = 1.0e-40; +#else + const double eps = __DBL_MIN__*4.0; +#endif double y, z; size_t i;
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Sat Mar 8 17:05:47 UTC 2014 Modified Files: src/tests/lib/libm: t_atan.c Log Message: no NaN tests for vax To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libm/t_atan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_atan.c diff -u src/tests/lib/libm/t_atan.c:1.13 src/tests/lib/libm/t_atan.c:1.14 --- src/tests/lib/libm/t_atan.c:1.13 Fri Mar 7 12:46:47 2014 +++ src/tests/lib/libm/t_atan.c Sat Mar 8 17:05:47 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_atan.c,v 1.13 2014/03/07 12:46:47 martin Exp $ */ +/* $NetBSD: t_atan.c,v 1.14 2014/03/08 17:05:47 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -57,8 +57,12 @@ static const struct { */ ATF_LIBM_TEST(atan_nan, "Test atan/atanf(NaN) == NaN") { +#ifdef __vax__ + atf_tc_skip("no NaN in vax floating point format"); +#else T_LIBM_CHECK_NAN(0, atan, T_LIBM_NAN); T_LIBM_CHECK_NAN(0, atanf, T_LIBM_NAN); +#endif } ATF_LIBM_TEST(atan_inrange, "Test atan/atanf(x) for some values")
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Fri Mar 7 12:46:48 UTC 2014 Modified Files: src/tests/lib/libm: t_atan.c t_libm.h Log Message: Vax does not do +/- INF. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libm/t_atan.c cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_libm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_atan.c diff -u src/tests/lib/libm/t_atan.c:1.12 src/tests/lib/libm/t_atan.c:1.13 --- src/tests/lib/libm/t_atan.c:1.12 Wed Mar 5 20:15:41 2014 +++ src/tests/lib/libm/t_atan.c Fri Mar 7 12:46:47 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_atan.c,v 1.12 2014/03/05 20:15:41 dsl Exp $ */ +/* $NetBSD: t_atan.c,v 1.13 2014/03/07 12:46:47 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,8 +37,11 @@ static const struct { double x; double y; } values[] = { +#ifndef __vax__ + /* vax has no +/- INF */ { T_LIBM_MINUS_INF, -M_PI / 2 }, { T_LIBM_PLUS_INF, M_PI / 2 }, +#endif { -100, -1.560796660108231, }, { -10, -1.471127674303735, }, { -1, -M_PI / 4, }, Index: src/tests/lib/libm/t_libm.h diff -u src/tests/lib/libm/t_libm.h:1.2 src/tests/lib/libm/t_libm.h:1.3 --- src/tests/lib/libm/t_libm.h:1.2 Wed Mar 5 20:14:46 2014 +++ src/tests/lib/libm/t_libm.h Fri Mar 7 12:46:47 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_libm.h,v 1.2 2014/03/05 20:14:46 dsl Exp $ */ +/* $NetBSD: t_libm.h,v 1.3 2014/03/07 12:46:47 martin Exp $ */ /* * Check result of fn(arg) is correct within the bounds. @@ -43,9 +43,11 @@ } while (0) /* Some useful constants (for test vectors) */ +#ifndef __vax__ /* no NAN nor +/- INF on vax */ #define T_LIBM_NAN (0.0 / 0.0) #define T_LIBM_PLUS_INF (+1.0 / 0.0) #define T_LIBM_MINUS_INF (-1.0 / 0.0) +#endif /* One line definition of a simple test */ #define ATF_LIBM_TEST(name, description) \
CVS commit: src/tests/lib/libm
Module Name:src Committed By: dsl Date: Wed Mar 5 20:15:41 UTC 2014 Modified Files: src/tests/lib/libm: t_atan.c Log Message: A couple of the atan tests are randomly failing. Print the incorrect value. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libm/t_atan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_atan.c diff -u src/tests/lib/libm/t_atan.c:1.11 src/tests/lib/libm/t_atan.c:1.12 --- src/tests/lib/libm/t_atan.c:1.11 Mon Mar 3 10:39:08 2014 +++ src/tests/lib/libm/t_atan.c Wed Mar 5 20:15:41 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_atan.c,v 1.11 2014/03/03 10:39:08 martin Exp $ */ +/* $NetBSD: t_atan.c,v 1.12 2014/03/05 20:15:41 dsl Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -31,11 +31,14 @@ #include #include +#include "t_libm.h" static const struct { double x; double y; } values[] = { + { T_LIBM_MINUS_INF, -M_PI / 2 }, + { T_LIBM_PLUS_INF, M_PI / 2 }, { -100, -1.560796660108231, }, { -10, -1.471127674303735, }, { -1, -M_PI / 4, }, @@ -49,212 +52,43 @@ static const struct { /* * atan(3) */ -ATF_TC(atan_nan); -ATF_TC_HEAD(atan_nan, tc) +ATF_LIBM_TEST(atan_nan, "Test atan/atanf(NaN) == NaN") { - atf_tc_set_md_var(tc, "descr", "Test atan(NaN) == NaN"); + T_LIBM_CHECK_NAN(0, atan, T_LIBM_NAN); + T_LIBM_CHECK_NAN(0, atanf, T_LIBM_NAN); } -ATF_TC_BODY(atan_nan, tc) +ATF_LIBM_TEST(atan_inrange, "Test atan/atanf(x) for some values") { - const double x = 0.0L / 0.0L; - - if (isnan(atan(x)) == 0) - atf_tc_fail_nonfatal("atan(NaN) != NaN"); -} - -ATF_TC(atan_inf_neg); -ATF_TC_HEAD(atan_inf_neg, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test atan(-Inf) == -pi/2"); -} - -ATF_TC_BODY(atan_inf_neg, tc) -{ - const double x = -1.0L / 0.0L; - const double eps = 1.0e-15; - - if (fabs(atan(x) + M_PI_2) > eps) - atf_tc_fail_nonfatal("atan(-Inf) != -pi/2"); -} - -ATF_TC(atan_inf_pos); -ATF_TC_HEAD(atan_inf_pos, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test atan(+Inf) == pi/2"); -} - -ATF_TC_BODY(atan_inf_pos, tc) -{ - const double x = +1.0L / 0.0L; - const double eps = 1.0e-15; - - if (fabs(atan(x) - M_PI_2) > eps) - atf_tc_fail_nonfatal("atan(+Inf) != pi/2"); -} - -ATF_TC(atan_inrange); -ATF_TC_HEAD(atan_inrange, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test atan(x) for some values"); -} - -ATF_TC_BODY(atan_inrange, tc) -{ - const double eps = 1.0e-15; - size_t i; - - for (i = 0; i < __arraycount(values); i++) { - if (fabs(atan(values[i].x) - values[i].y) > eps) - atf_tc_fail_nonfatal("atan(%g) != %g", -values[i].x, values[i].y); - } -} - -ATF_TC(atan_zero_neg); -ATF_TC_HEAD(atan_zero_neg, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test atan(-0.0) == -0.0"); -} - -ATF_TC_BODY(atan_zero_neg, tc) -{ - const double x = -0.0L; - double y = atan(x); - - if (fabs(y) > 0.0 || signbit(y) == 0) - atf_tc_fail_nonfatal("atan(-0.0) != -0.0"); -} - -ATF_TC(atan_zero_pos); -ATF_TC_HEAD(atan_zero_pos, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test atan(+0.0) == +0.0"); -} - -ATF_TC_BODY(atan_zero_pos, tc) -{ - const double x = 0.0L; - double y = atan(x); - - if (fabs(y) > 0.0 || signbit(y) != 0) - atf_tc_fail_nonfatal("atan(+0.0) != +0.0"); -} - -/* - * atanf(3) - */ -ATF_TC(atanf_nan); -ATF_TC_HEAD(atanf_nan, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test atanf(NaN) == NaN"); -} - -ATF_TC_BODY(atanf_nan, tc) -{ - const float x = 0.0L / 0.0L; - - if (isnan(atanf(x)) == 0) - atf_tc_fail_nonfatal("atanf(NaN) != NaN"); -} - -ATF_TC(atanf_inf_neg); -ATF_TC_HEAD(atanf_inf_neg, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test atanf(-Inf) == -pi/2"); -} - -ATF_TC_BODY(atanf_inf_neg, tc) -{ - const float x = -1.0L / 0.0L; - const float eps = 1.0e-7; - - if (fabsf(atanf(x) + (float)M_PI_2) > eps) - atf_tc_fail_nonfatal("atanf(-Inf) != -pi/2"); -} - -ATF_TC(atanf_inf_pos); -ATF_TC_HEAD(atanf_inf_pos, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test atanf(+Inf) == pi/2"); -} - -ATF_TC_BODY(atanf_inf_pos, tc) -{ - const float x = +1.0L / 0.0L; - const float eps = 1.0e-7; - - if (fabsf(atanf(x) - (float)M_PI_2) > eps) - atf_tc_fail_nonfatal("atanf(+Inf) != pi/2"); -} - -ATF_TC(atanf_inrange); -ATF_TC_HEAD(atanf_inrange, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test atanf(x) for some values"); -} - -ATF_TC_BODY(atanf_inrange, tc) -{ - const float eps = 1.0e-7; - float x; - float y; - size_t i; + unsigned int i; for (i = 0; i < __arraycount(values); i++) { - x = values[i].x; - y = values[i].y; - if (fabs(atanf(x) - y) > eps) - atf_tc_fail_nonfatal("atan(%g) != %g", x, y); + T_LIBM_CHECK(i, atan, values[i].x, values[i].y, 1.0e-15); + T_LIBM_CHECK(i, atanf, values[i].x, values[i].y, 1.0e-7); } } -ATF_TC(atanf_zero_neg); -ATF_TC_HEAD(atanf_zero_neg, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test atanf(-0.0) == -0.0"); -} - -ATF_TC_BODY(atanf_zero_neg, tc) +ATF_LIBM_TEST(atan_zero_neg, "Test atan/atanf(-0.0) ==
CVS commit: src/tests/lib/libm
Module Name:src Committed By: dsl Date: Wed Mar 5 20:14:46 UTC 2014 Modified Files: src/tests/lib/libm: t_acos.c t_libm.h Log Message: Fix some typos. Make the infinity and nan constants 'double' not 'long double'. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_acos.c cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_libm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_acos.c diff -u src/tests/lib/libm/t_acos.c:1.9 src/tests/lib/libm/t_acos.c:1.10 --- src/tests/lib/libm/t_acos.c:1.9 Wed Mar 5 19:43:46 2014 +++ src/tests/lib/libm/t_acos.c Wed Mar 5 20:14:46 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_acos.c,v 1.9 2014/03/05 19:43:46 dsl Exp $ */ +/* $NetBSD: t_acos.c,v 1.10 2014/03/05 20:14:46 dsl Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ * acos(3) and acosf(3) */ -AFT_LIBM_TEST(acos_is_nan, "Test acos/acosf(x) == NaN, x = NaN, +/-Inf, ![-1..1]") +ATF_LIBM_TEST(acos_is_nan, "Test acos/acosf(x) == NaN, x = NaN, +/-Inf, ![-1..1]") { static const double x[] = { -1.1, 1.1, @@ -59,7 +59,7 @@ AFT_LIBM_TEST(acos_is_nan, "Test acos/ac } } -AFT_LIBM_TEST(acos_inrange, "Test acos/acosf(x) for some valid values") +ATF_LIBM_TEST(acos_inrange, "Test acos/acosf(x) for some valid values") { static const struct { double x; @@ -88,7 +88,7 @@ AFT_LIBM_TEST(acos_inrange, "Test acos/a } } -AFT_LIBM_TEST(acos_is_plus_zero, "Test acosf(1.0) == +0.0") +ATF_LIBM_TEST(acos_is_plus_zero, "Test acosf(1.0) == +0.0") { T_LIBM_CHECK_PLUS_ZERO(0, acos, 1.0); T_LIBM_CHECK_PLUS_ZERO(0, acosf, 1.0); Index: src/tests/lib/libm/t_libm.h diff -u src/tests/lib/libm/t_libm.h:1.1 src/tests/lib/libm/t_libm.h:1.2 --- src/tests/lib/libm/t_libm.h:1.1 Wed Mar 5 19:43:46 2014 +++ src/tests/lib/libm/t_libm.h Wed Mar 5 20:14:46 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_libm.h,v 1.1 2014/03/05 19:43:46 dsl Exp $ */ +/* $NetBSD: t_libm.h,v 1.2 2014/03/05 20:14:46 dsl Exp $ */ /* * Check result of fn(arg) is correct within the bounds. @@ -43,12 +43,12 @@ } while (0) /* Some useful constants (for test vectors) */ -#define T_LIBM_NAN (0.0L / 0.0L) -#define T_LIBM_PLUS_INF (+1.0L / 0.0L) -#define T_LIBM_MINUS_INF (-1.0L / 0.0L) +#define T_LIBM_NAN (0.0 / 0.0) +#define T_LIBM_PLUS_INF (+1.0 / 0.0) +#define T_LIBM_MINUS_INF (-1.0 / 0.0) /* One line definition of a simple test */ -#define AFT_LIBM_TEST(name, description) \ +#define ATF_LIBM_TEST(name, description) \ ATF_TC(name); \ ATF_TC_HEAD(name, tc) { atf_tc_set_md_var(tc, "descr", description); } \ ATF_TC_BODY(name, tc)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: dsl Date: Wed Mar 5 19:43:46 UTC 2014 Modified Files: src/tests/lib/libm: t_acos.c Added Files: src/tests/lib/libm: t_libm.h Log Message: Move the #defines that simplified the test definitions and checks into a separate header than can be used by the other libm tests. Make the subtest index 'unsigned int' so that simple constants (eg 0) print correctly. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libm/t_acos.c cvs rdiff -u -r0 -r1.1 src/tests/lib/libm/t_libm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_acos.c diff -u src/tests/lib/libm/t_acos.c:1.8 src/tests/lib/libm/t_acos.c:1.9 --- src/tests/lib/libm/t_acos.c:1.8 Mon Mar 3 18:21:33 2014 +++ src/tests/lib/libm/t_acos.c Wed Mar 5 19:43:46 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_acos.c,v 1.8 2014/03/03 18:21:33 dsl Exp $ */ +/* $NetBSD: t_acos.c,v 1.9 2014/03/05 19:43:46 dsl Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -31,55 +31,24 @@ #include #include - -/* - * Check result of fn(arg) is correct within the bounds. - * Should be ok to do the checks using 'double' for 'float' functions. - */ -#define T_LIBM_CHECK(subtest, fn, arg, expect, epsilon) do { \ - double r = fn(arg); \ - double e = fabs(r - expect); \ - if (e > epsilon) \ - atf_tc_fail_nonfatal( \ - "subtest %zu: " #fn "(%g) is %g not %g (error %g > %g)", \ - subtest, arg, r, expect, e, epsilon); \ -} while (0) - -/* Check that the result of fn(arg) is NaN */ -#ifndef __vax__ -#define T_LIBM_CHECK_NAN(subtest, fn, arg) do { \ - double r = fn(arg); \ - if (!isnan(r)) \ - atf_tc_fail_nonfatal("subtest %zu: " #fn "(%g) is %g not NaN", \ - subtest, arg, r); \ -} while (0) -#else -/* vax doesn't support NaN */ -#define T_LIBM_CHECK_NAN(subtest, fn, arg) (void)(arg) -#endif - -#define AFT_LIBM_TEST(name, description) \ -ATF_TC(name); \ -ATF_TC_HEAD(name, tc) { atf_tc_set_md_var(tc, "descr", description); } \ -ATF_TC_BODY(name, tc) +#include "t_libm.h" /* * acos(3) and acosf(3) */ -AFT_LIBM_TEST(acos_nan, "Test acos/acosf(x) == NaN, x = NaN, +/-Inf, ![-1..1]") +AFT_LIBM_TEST(acos_is_nan, "Test acos/acosf(x) == NaN, x = NaN, +/-Inf, ![-1..1]") { static const double x[] = { -1.1, 1.1, -1.001, 1.001, -1.1, 1.1, #ifndef __vax__ - 0.0L / 0.0L, /* NAN */ - -1.0L / 0.0L, /* -Inf */ - +1.0L / 0.0L, /* +Inf */ + T_LIBM_NAN, + T_LIBM_MINUS_INF, T_LIBM_PLUS_INF, #endif }; - size_t i; + unsigned int i; for (i = 0; i < __arraycount(x); i++) { T_LIBM_CHECK_NAN(i, acos, x[i]); @@ -105,7 +74,7 @@ AFT_LIBM_TEST(acos_inrange, "Test acos/a { 0.5, 1.047197551196598, }, { 0.99, 0.141539473324427, }, }; - size_t i; + unsigned int i; /* * Note that acos(x) might be calculated as atan2(sqrt(1-x*x),x). @@ -119,29 +88,18 @@ AFT_LIBM_TEST(acos_inrange, "Test acos/a } } -AFT_LIBM_TEST(acos_one_pos, "Test acos(1.0) == +0.0") -{ - const double y = acos(1.0); - - if (fabs(y) > 0.0 || signbit(y) != 0) - atf_tc_fail_nonfatal("acos(1.0) != +0.0"); -} - -AFT_LIBM_TEST(acosf_one_pos, "Test acosf(1.0) == +0.0") +AFT_LIBM_TEST(acos_is_plus_zero, "Test acosf(1.0) == +0.0") { - const float y = acosf(1.0); - - if (fabsf(y) > 0.0 || signbit(y) != 0) - atf_tc_fail_nonfatal("acosf(1.0) != +0.0"); + T_LIBM_CHECK_PLUS_ZERO(0, acos, 1.0); + T_LIBM_CHECK_PLUS_ZERO(0, acosf, 1.0); } ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, acos_nan); ATF_TP_ADD_TC(tp, acos_inrange); - ATF_TP_ADD_TC(tp, acos_one_pos); - ATF_TP_ADD_TC(tp, acosf_one_pos); + ATF_TP_ADD_TC(tp, acos_is_nan); + ATF_TP_ADD_TC(tp, acos_is_plus_zero); return atf_no_error(); } Added files: Index: src/tests/lib/libm/t_libm.h diff -u /dev/null src/tests/lib/libm/t_libm.h:1.1 --- /dev/null Wed Mar 5 19:43:46 2014 +++ src/tests/lib/libm/t_libm.h Wed Mar 5 19:43:46 2014 @@ -0,0 +1,54 @@ +/* $NetBSD: t_libm.h,v 1.1 2014/03/05 19:43:46 dsl Exp $ */ + +/* + * Check result of fn(arg) is correct within the bounds. + * Should be ok to do the checks using 'double' for 'float' functions. + */ +#define T_LIBM_CHECK(subtest, fn, arg, expect, epsilon) do { \ + double r = fn(arg); \ + double e = fabs(r - expect); \ + if (e > epsilon) \ + atf_tc_fail_nonfatal( \ + "subtest %u: " #fn "(%g) is %g not %g (error %g > %g)", \ + subtest, arg, r, expect, e, epsilon); \ +} while (0) + +/* Check that the result of fn(arg) is NaN */ +#ifndef __vax__ +#define T_LIBM_CHECK_NAN(subtest, fn, arg) do { \ + double r = fn(arg); \ + if (!isnan(r)) \ + atf_tc_fail_nonfatal("subtest %u: " #fn "(%g) is %g not NaN", \ + subtest, arg, r); \ +} while (0) +#else +/* vax doesn't support NaN */ +#define T_LIBM_CHECK_NAN(subtest, fn, arg) (void)(arg) +#endif + +/* Check that the result of fn(arg) is +0.0 */ +#define T_LIBM_CH
CVS commit: src/tests/lib/libm
Module Name:src Committed By: dsl Date: Mon Mar 3 18:21:33 UTC 2014 Modified Files: src/tests/lib/libm: t_acos.c Log Message: Remove the print of the rounding mode. It was added in case it was non-zero - which it isn't. It still isn't clear why acos(-1) gives the wrong result on some amd64 systems. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_acos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_acos.c diff -u src/tests/lib/libm/t_acos.c:1.7 src/tests/lib/libm/t_acos.c:1.8 --- src/tests/lib/libm/t_acos.c:1.7 Mon Mar 3 10:38:36 2014 +++ src/tests/lib/libm/t_acos.c Mon Mar 3 18:21:33 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_acos.c,v 1.7 2014/03/03 10:38:36 martin Exp $ */ +/* $NetBSD: t_acos.c,v 1.8 2014/03/03 18:21:33 dsl Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -32,24 +32,10 @@ #include #include -#ifdef HAVE_FENV_H -#include -#endif - /* * Check result of fn(arg) is correct within the bounds. * Should be ok to do the checks using 'double' for 'float' functions. */ -#ifdef HAVE_FENV_H -#define T_LIBM_CHECK(subtest, fn, arg, expect, epsilon) do { \ - double r = fn(arg); \ - double e = fabs(r - expect); \ - if (e > epsilon) \ - atf_tc_fail_nonfatal( \ - "subtest %zu: " #fn "(%g) is %g not %g (error %g > %g), roundmode %x", \ - subtest, arg, r, expect, e, epsilon, fegetround()); \ -} while (0) -#else #define T_LIBM_CHECK(subtest, fn, arg, expect, epsilon) do { \ double r = fn(arg); \ double e = fabs(r - expect); \ @@ -58,7 +44,6 @@ "subtest %zu: " #fn "(%g) is %g not %g (error %g > %g)", \ subtest, arg, r, expect, e, epsilon); \ } while (0) -#endif /* Check that the result of fn(arg) is NaN */ #ifndef __vax__
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Mon Mar 3 12:15:27 UTC 2014 Modified Files: src/tests/lib/libm: Makefile Log Message: Define HAVE_FENV_H on architectures that support it. What a mess, we need a central place for this! To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.20 src/tests/lib/libm/Makefile:1.21 --- src/tests/lib/libm/Makefile:1.20 Tue Nov 12 16:48:39 2013 +++ src/tests/lib/libm/Makefile Mon Mar 3 12:15:27 2014 @@ -1,9 +1,15 @@ -# $NetBSD: Makefile,v 1.20 2013/11/12 16:48:39 joerg Exp $ +# $NetBSD: Makefile,v 1.21 2014/03/03 12:15:27 martin Exp $ .include TESTSDIR= ${TESTSBASE}/lib/libm +.if ${MACHINE} == "sparc" || ${MACHINE} == "i386" \ + || ${MACHINE} == "amd64" || ${MACHINE_CPU} == "arm" \ + || ${MACHINE} == "sparc64" +CPPFLAGS+= -DHAVE_FENV_H +.endif + TESTS_C+= t_acos TESTS_C+= t_asin TESTS_C+= t_atan
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Mon Mar 3 10:38:36 UTC 2014 Modified Files: src/tests/lib/libm: t_acos.c Log Message: Fix build for platforms w/o fenv.h. Remove some bogus #ifdef __vax__ (and add a few, hopefully non-bogus, new ones). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_acos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_acos.c diff -u src/tests/lib/libm/t_acos.c:1.6 src/tests/lib/libm/t_acos.c:1.7 --- src/tests/lib/libm/t_acos.c:1.6 Sun Mar 2 22:40:45 2014 +++ src/tests/lib/libm/t_acos.c Mon Mar 3 10:38:36 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_acos.c,v 1.6 2014/03/02 22:40:45 dsl Exp $ */ +/* $NetBSD: t_acos.c,v 1.7 2014/03/03 10:38:36 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -31,12 +31,16 @@ #include #include + +#ifdef HAVE_FENV_H #include +#endif /* * Check result of fn(arg) is correct within the bounds. * Should be ok to do the checks using 'double' for 'float' functions. */ +#ifdef HAVE_FENV_H #define T_LIBM_CHECK(subtest, fn, arg, expect, epsilon) do { \ double r = fn(arg); \ double e = fabs(r - expect); \ @@ -45,6 +49,16 @@ "subtest %zu: " #fn "(%g) is %g not %g (error %g > %g), roundmode %x", \ subtest, arg, r, expect, e, epsilon, fegetround()); \ } while (0) +#else +#define T_LIBM_CHECK(subtest, fn, arg, expect, epsilon) do { \ + double r = fn(arg); \ + double e = fabs(r - expect); \ + if (e > epsilon) \ + atf_tc_fail_nonfatal( \ + "subtest %zu: " #fn "(%g) is %g not %g (error %g > %g)", \ + subtest, arg, r, expect, e, epsilon); \ +} while (0) +#endif /* Check that the result of fn(arg) is NaN */ #ifndef __vax__ @@ -74,9 +88,11 @@ AFT_LIBM_TEST(acos_nan, "Test acos/acosf -1.1, 1.1, -1.001, 1.001, -1.1, 1.1, +#ifndef __vax__ 0.0L / 0.0L, /* NAN */ -1.0L / 0.0L, /* -Inf */ +1.0L / 0.0L, /* +Inf */ +#endif }; size_t i; @@ -120,22 +136,18 @@ AFT_LIBM_TEST(acos_inrange, "Test acos/a AFT_LIBM_TEST(acos_one_pos, "Test acos(1.0) == +0.0") { -#ifndef __vax__ const double y = acos(1.0); if (fabs(y) > 0.0 || signbit(y) != 0) atf_tc_fail_nonfatal("acos(1.0) != +0.0"); -#endif } AFT_LIBM_TEST(acosf_one_pos, "Test acosf(1.0) == +0.0") { -#ifndef __vax__ const float y = acosf(1.0); if (fabsf(y) > 0.0 || signbit(y) != 0) atf_tc_fail_nonfatal("acosf(1.0) != +0.0"); -#endif } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libm
Module Name:src Committed By: dsl Date: Sun Mar 2 22:40:45 UTC 2014 Modified Files: src/tests/lib/libm: t_acos.c Log Message: Include the subtest number in any error output. Also temporarily print the rounding mode. I think that acos(-1) is ending up with the wrong sign because the test is being run with 'round towards -ve infinity' set. I think it getting set somewhere and causing this test to fail. The acos() code probably needs fixing - it shouldn't depend on the round mode like this. But first I want to know if this if the error. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_acos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_acos.c diff -u src/tests/lib/libm/t_acos.c:1.5 src/tests/lib/libm/t_acos.c:1.6 --- src/tests/lib/libm/t_acos.c:1.5 Sat Mar 1 21:08:39 2014 +++ src/tests/lib/libm/t_acos.c Sun Mar 2 22:40:45 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_acos.c,v 1.5 2014/03/01 21:08:39 dsl Exp $ */ +/* $NetBSD: t_acos.c,v 1.6 2014/03/02 22:40:45 dsl Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -31,29 +31,32 @@ #include #include +#include /* * Check result of fn(arg) is correct within the bounds. * Should be ok to do the checks using 'double' for 'float' functions. */ -#define T_LIBM_CHECK(fn, arg, expect, epsilon) do { \ +#define T_LIBM_CHECK(subtest, fn, arg, expect, epsilon) do { \ double r = fn(arg); \ double e = fabs(r - expect); \ if (e > epsilon) \ - atf_tc_fail_nonfatal(#fn "(%g) is %g not %g (error %g > %g)", \ - arg, r, expect, e, epsilon); \ + atf_tc_fail_nonfatal( \ + "subtest %zu: " #fn "(%g) is %g not %g (error %g > %g), roundmode %x", \ + subtest, arg, r, expect, e, epsilon, fegetround()); \ } while (0) /* Check that the result of fn(arg) is NaN */ #ifndef __vax__ -#define T_LIBM_CHECK_NAN(fn, arg) do { \ +#define T_LIBM_CHECK_NAN(subtest, fn, arg) do { \ double r = fn(arg); \ if (!isnan(r)) \ - atf_tc_fail_nonfatal(#fn "(%g) is %g not NaN", arg, r); \ + atf_tc_fail_nonfatal("subtest %zu: " #fn "(%g) is %g not NaN", \ + subtest, arg, r); \ } while (0) #else /* vax doesn't support NaN */ -#define T_LIBM_CHECK_NAN(fn, arg) (void)(arg) +#define T_LIBM_CHECK_NAN(subtest, fn, arg) (void)(arg) #endif #define AFT_LIBM_TEST(name, description) \ @@ -78,11 +81,11 @@ AFT_LIBM_TEST(acos_nan, "Test acos/acosf size_t i; for (i = 0; i < __arraycount(x); i++) { - T_LIBM_CHECK_NAN(acos, x[i]); + T_LIBM_CHECK_NAN(i, acos, x[i]); if (i < 2) /* Values are too small for float */ continue; - T_LIBM_CHECK_NAN(acosf, x[i]); + T_LIBM_CHECK_NAN(i, acosf, x[i]); } } @@ -104,14 +107,14 @@ AFT_LIBM_TEST(acos_inrange, "Test acos/a size_t i; /* - * Note that acos(x) might be calcualted as atan((1-x*x)/x). - * This means that acos(-1) is atan(-0.0), if the sign is lost - * the value will be 0 (atan(+0)) not M_PI. + * Note that acos(x) might be calculated as atan2(sqrt(1-x*x),x). + * This means that acos(-1) is atan2(+0,-1), if the sign is wrong + * the value will be -M_PI (atan2(-0,-1)) not M_PI. */ for (i = 0; i < __arraycount(values); i++) { - T_LIBM_CHECK(acos, values[i].x, values[i].y, 1.0e-15); - T_LIBM_CHECK(acosf, values[i].x, values[i].y, 1.0e-5); + T_LIBM_CHECK(i, acos, values[i].x, values[i].y, 1.0e-15); + T_LIBM_CHECK(i, acosf, values[i].x, values[i].y, 1.0e-5); } }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: dsl Date: Sat Mar 1 21:08:39 UTC 2014 Modified Files: src/tests/lib/libm: t_acos.c Log Message: Some of the acos() tests seem to fail on some systems. Sorting out why isn't helped by the tests not reporting the erronous value. Change the 'boilerplate' pattern used so that all the values are output. Reduce the amount of faffy red tape as well. Some of these reductions could be shared with other libm tests, but for the moment they are defined in this file. All these tests pass on my amd64 system, and when I run amd64 qemu. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_acos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_acos.c diff -u src/tests/lib/libm/t_acos.c:1.4 src/tests/lib/libm/t_acos.c:1.5 --- src/tests/lib/libm/t_acos.c:1.4 Tue Apr 9 12:11:04 2013 +++ src/tests/lib/libm/t_acos.c Sat Mar 1 21:08:39 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_acos.c,v 1.4 2013/04/09 12:11:04 isaki Exp $ */ +/* $NetBSD: t_acos.c,v 1.5 2014/03/01 21:08:39 dsl Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -32,188 +32,100 @@ #include #include -static const struct { - double x; - double y; -} values[] = { - { -1,M_PI, }, - { -0.99, 3.53180265366, }, - { -0.5, 2.094395102393195, }, - { -0.1, 1.670963747956456, }, - { 0,M_PI / 2, }, - { 0.1, 1.47062890567, }, - { 0.5, 1.047197551196598, }, - { 0.99, 0.141539473324427, }, -}; - /* - * acos(3) + * Check result of fn(arg) is correct within the bounds. + * Should be ok to do the checks using 'double' for 'float' functions. */ -ATF_TC(acos_nan); -ATF_TC_HEAD(acos_nan, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test acos(NaN) == NaN"); -} - -ATF_TC_BODY(acos_nan, tc) -{ -#ifndef __vax__ - const double x = 0.0L / 0.0L; - - if (isnan(acos(x)) == 0) - atf_tc_fail_nonfatal("acos(NaN) != NaN"); -#endif -} - -ATF_TC(acos_inf_neg); -ATF_TC_HEAD(acos_inf_neg, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test acos(-Inf) == NaN"); -} - -ATF_TC_BODY(acos_inf_neg, tc) -{ -#ifndef __vax__ - const double x = -1.0L / 0.0L; - - if (isnan(acos(x)) == 0) - atf_tc_fail_nonfatal("acos(-Inf) != NaN"); -#endif -} - -ATF_TC(acos_inf_pos); -ATF_TC_HEAD(acos_inf_pos, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test acos(+Inf) == NaN"); -} +#define T_LIBM_CHECK(fn, arg, expect, epsilon) do { \ + double r = fn(arg); \ + double e = fabs(r - expect); \ + if (e > epsilon) \ + atf_tc_fail_nonfatal(#fn "(%g) is %g not %g (error %g > %g)", \ + arg, r, expect, e, epsilon); \ +} while (0) + +/* Check that the result of fn(arg) is NaN */ +#ifndef __vax__ +#define T_LIBM_CHECK_NAN(fn, arg) do { \ + double r = fn(arg); \ + if (!isnan(r)) \ + atf_tc_fail_nonfatal(#fn "(%g) is %g not NaN", arg, r); \ +} while (0) +#else +/* vax doesn't support NaN */ +#define T_LIBM_CHECK_NAN(fn, arg) (void)(arg) +#endif + +#define AFT_LIBM_TEST(name, description) \ +ATF_TC(name); \ +ATF_TC_HEAD(name, tc) { atf_tc_set_md_var(tc, "descr", description); } \ +ATF_TC_BODY(name, tc) -ATF_TC_BODY(acos_inf_pos, tc) -{ -#ifndef __vax__ - const double x = 1.0L / 0.0L; - - if (isnan(acos(x)) == 0) - atf_tc_fail_nonfatal("acos(+Inf) != NaN"); -#endif -} - -ATF_TC(acos_one_pos); -ATF_TC_HEAD(acos_one_pos, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test acos(1.0) == +0.0"); -} - -ATF_TC_BODY(acos_one_pos, tc) -{ -#ifndef __vax__ - const double y = acos(1.0); - - if (fabs(y) > 0.0 || signbit(y) != 0) - atf_tc_fail_nonfatal("acos(1.0) != +0.0"); -#endif -} - -ATF_TC(acos_range); -ATF_TC_HEAD(acos_range, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test acos(x) == NaN, x < -1, x > 1"); -} +/* + * acos(3) and acosf(3) + */ -ATF_TC_BODY(acos_range, tc) +AFT_LIBM_TEST(acos_nan, "Test acos/acosf(x) == NaN, x = NaN, +/-Inf, ![-1..1]") { -#ifndef __vax__ - const double x[] = { -1.1, -1.1, 1.1, 1.1 }; + static const double x[] = { + -1.1, 1.1, + -1.001, 1.001, + -1.1, 1.1, + 0.0L / 0.0L, /* NAN */ + -1.0L / 0.0L, /* -Inf */ + +1.0L / 0.0L, /* +Inf */ + }; size_t i; for (i = 0; i < __arraycount(x); i++) { - - if (isnan(acos(x[i])) == 0) - atf_tc_fail_nonfatal("acos(%f) != NaN", x[i]); + T_LIBM_CHECK_NAN(acos, x[i]); + if (i < 2) + /* Values are too small for float */ + continue; + T_LIBM_CHECK_NAN(acosf, x[i]); } -#endif -} - -ATF_TC(acos_inrange); -ATF_TC_HEAD(acos_inrange, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test acos(x) for some values"); } -ATF_TC_BODY(acos_inrange, tc) +AFT_LIBM_TEST(acos_inrange, "Test acos/acosf(x) for some valid values") { -#ifndef __vax__ - const double eps = 1.0e-15; - double x; - double y; + static const struct { + double x; + double y; + } values[] = { + { -1,M_PI, }, + { -0.99, 3.53180265366, }, + { -0.5, 2.094395102393195, }, + {
CVS commit: src/tests/lib/libm
Module Name:src Committed By: joerg Date: Thu Feb 27 17:26:02 UTC 2014 Modified Files: src/tests/lib/libm: t_atan.c t_exp.c t_fmod.c t_log.c Log Message: Avoid promotion in subexpressions. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_atan.c \ src/tests/lib/libm/t_log.c cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_exp.c cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_fmod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_atan.c diff -u src/tests/lib/libm/t_atan.c:1.9 src/tests/lib/libm/t_atan.c:1.10 --- src/tests/lib/libm/t_atan.c:1.9 Fri Jun 14 05:39:28 2013 +++ src/tests/lib/libm/t_atan.c Thu Feb 27 17:26:02 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_atan.c,v 1.9 2013/06/14 05:39:28 isaki Exp $ */ +/* $NetBSD: t_atan.c,v 1.10 2014/02/27 17:26:02 joerg Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -184,7 +184,7 @@ ATF_TC_BODY(atanf_inf_neg, tc) const float x = -1.0L / 0.0L; const float eps = 1.0e-7; - if (fabsf(atanf(x) + M_PI_2) > eps) + if (fabsf(atanf(x) + (float)M_PI_2) > eps) atf_tc_fail_nonfatal("atanf(-Inf) != -pi/2"); #endif } @@ -201,7 +201,7 @@ ATF_TC_BODY(atanf_inf_pos, tc) const float x = +1.0L / 0.0L; const float eps = 1.0e-7; - if (fabsf(atanf(x) - M_PI_2) > eps) + if (fabsf(atanf(x) - (float)M_PI_2) > eps) atf_tc_fail_nonfatal("atanf(+Inf) != pi/2"); #endif } Index: src/tests/lib/libm/t_log.c diff -u src/tests/lib/libm/t_log.c:1.9 src/tests/lib/libm/t_log.c:1.10 --- src/tests/lib/libm/t_log.c:1.9 Sun Feb 9 21:26:07 2014 +++ src/tests/lib/libm/t_log.c Thu Feb 27 17:26:02 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_log.c,v 1.9 2014/02/09 21:26:07 jmmv Exp $ */ +/* $NetBSD: t_log.c,v 1.10 2014/02/27 17:26:02 joerg Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_log.c,v 1.9 2014/02/09 21:26:07 jmmv Exp $"); +__RCSID("$NetBSD: t_log.c,v 1.10 2014/02/27 17:26:02 joerg Exp $"); #include #include @@ -809,7 +809,7 @@ ATF_TC_BODY(logf_base, tc) { const float eps = 1.0e-7; - if (fabsf(logf(M_E) - 1.0) > eps) + if (fabsf(logf(M_E) - 1.0f) > eps) atf_tc_fail_nonfatal("logf(e) != 1"); } Index: src/tests/lib/libm/t_exp.c diff -u src/tests/lib/libm/t_exp.c:1.3 src/tests/lib/libm/t_exp.c:1.4 --- src/tests/lib/libm/t_exp.c:1.3 Tue Apr 9 11:42:56 2013 +++ src/tests/lib/libm/t_exp.c Thu Feb 27 17:26:02 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exp.c,v 1.3 2013/04/09 11:42:56 isaki Exp $ */ +/* $NetBSD: t_exp.c,v 1.4 2014/02/27 17:26:02 joerg Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -245,7 +245,7 @@ ATF_TC_BODY(exp2f_zero_neg, tc) #ifndef __vax__ const float x = -0.0L; - if (fabsf(exp2f(x) - 1.0) > 0.0) + if (fabsf(exp2f(x) - 1.0f) > 0.0) atf_tc_fail_nonfatal("exp2f(-0.0) != 1.0"); #endif } @@ -261,7 +261,7 @@ ATF_TC_BODY(exp2f_zero_pos, tc) #ifndef __vax__ const float x = 0.0L; - if (fabsf(exp2f(x) - 1.0) > 0.0) + if (fabsf(exp2f(x) - 1.0f) > 0.0) atf_tc_fail_nonfatal("exp2f(+0.0) != 1.0"); #endif } @@ -465,7 +465,7 @@ ATF_TC_BODY(expf_zero_neg, tc) #ifndef __vax__ const float x = -0.0L; - if (fabsf(expf(x) - 1.0) > 0.0) + if (fabsf(expf(x) - 1.0f) > 0.0) atf_tc_fail_nonfatal("expf(-0.0) != 1.0"); #endif } @@ -481,7 +481,7 @@ ATF_TC_BODY(expf_zero_pos, tc) #ifndef __vax__ const float x = 0.0L; - if (fabsf(expf(x) - 1.0) > 0.0) + if (fabsf(expf(x) - 1.0f) > 0.0) atf_tc_fail_nonfatal("expf(+0.0) != 1.0"); #endif } Index: src/tests/lib/libm/t_fmod.c diff -u src/tests/lib/libm/t_fmod.c:1.1 src/tests/lib/libm/t_fmod.c:1.2 --- src/tests/lib/libm/t_fmod.c:1.1 Tue Nov 12 16:48:39 2013 +++ src/tests/lib/libm/t_fmod.c Thu Feb 27 17:26:02 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fmod.c,v 1.1 2013/11/12 16:48:39 joerg Exp $ */ +/* $NetBSD: t_fmod.c,v 1.2 2014/02/27 17:26:02 joerg Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -49,7 +49,7 @@ ATF_TC_BODY(fmod, tc) ATF_CHECK(fmod(2.0, 0.5) == 0); ATF_CHECK(fmodl(2.0, 0.5) == 0); - ATF_CHECK(fabsf(fmodf(1.0, 0.1) - 0.1) <= 55 * FLT_EPSILON); + ATF_CHECK(fabsf(fmodf(1.0, 0.1) - 0.1f) <= 55 * FLT_EPSILON); ATF_CHECK(fabs(fmod(1.0, 0.1) - 0.1) <= 55 * DBL_EPSILON); ATF_CHECK(fabsl(fmodl(1.0, 0.1L) - 0.1L) <= 55 * LDBL_EPSILON); }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Fri Nov 22 17:19:14 UTC 2013 Modified Files: src/tests/lib/libm: t_sqrt.c Log Message: Adjust expected epsilon for sqrtl <-> powl comparisions for defects in powl (which actually is pow for now) To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_sqrt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_sqrt.c diff -u src/tests/lib/libm/t_sqrt.c:1.4 src/tests/lib/libm/t_sqrt.c:1.5 --- src/tests/lib/libm/t_sqrt.c:1.4 Tue Nov 19 19:24:33 2013 +++ src/tests/lib/libm/t_sqrt.c Fri Nov 22 17:19:14 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sqrt.c,v 1.4 2013/11/19 19:24:33 joerg Exp $ */ +/* $NetBSD: t_sqrt.c,v 1.5 2013/11/22 17:19:14 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,10 +29,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_sqrt.c,v 1.4 2013/11/19 19:24:33 joerg Exp $"); +__RCSID("$NetBSD: t_sqrt.c,v 1.5 2013/11/22 17:19:14 martin Exp $"); #include #include +#include #include /* @@ -288,7 +289,7 @@ ATF_TC_BODY(sqrtl_powl, tc) { #ifndef __vax__ const long double x[] = { 0.0, 0.005, 1.0, 99.0, 123.123, . }; - const long double eps = 1.0e-30; + const long double eps = 5.0*DBL_EPSILON; /* XXX powl == pow for now */ volatile long double y, z; size_t i;
CVS commit: src/tests/lib/libm
Module Name:src Committed By: isaki Date: Fri Jun 14 05:39:28 UTC 2013 Modified Files: src/tests/lib/libm: t_atan.c Log Message: Remove header files which became unnecessary in 1.7. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libm/t_atan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_atan.c diff -u src/tests/lib/libm/t_atan.c:1.8 src/tests/lib/libm/t_atan.c:1.9 --- src/tests/lib/libm/t_atan.c:1.8 Tue Apr 9 12:11:04 2013 +++ src/tests/lib/libm/t_atan.c Fri Jun 14 05:39:28 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_atan.c,v 1.8 2013/04/09 12:11:04 isaki Exp $ */ +/* $NetBSD: t_atan.c,v 1.9 2013/06/14 05:39:28 isaki Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -30,10 +30,7 @@ */ #include -#include #include -#include -#include static const struct { double x;
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Fri May 24 11:47:13 UTC 2013 Modified Files: src/tests/lib/libm: t_scalbn.c Log Message: Backout previous - real fix for vax libm upcoming. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_scalbn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_scalbn.c diff -u src/tests/lib/libm/t_scalbn.c:1.9 src/tests/lib/libm/t_scalbn.c:1.10 --- src/tests/lib/libm/t_scalbn.c:1.9 Thu May 23 20:45:47 2013 +++ src/tests/lib/libm/t_scalbn.c Fri May 24 11:47:13 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_scalbn.c,v 1.9 2013/05/23 20:45:47 christos Exp $ */ +/* $NetBSD: t_scalbn.c,v 1.10 2013/05/24 11:47:13 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_scalbn.c,v 1.9 2013/05/23 20:45:47 christos Exp $"); +__RCSID("$NetBSD: t_scalbn.c,v 1.10 2013/05/24 11:47:13 martin Exp $"); #include #include @@ -75,7 +75,6 @@ ATF_TC_HEAD(scalbn_val, tc) ATF_TC_BODY(scalbn_val, tc) { -#ifndef __vax__ const struct testcase *tests = test_vals; const size_t tcnt = __arraycount(test_vals); size_t i; @@ -90,7 +89,6 @@ ATF_TC_BODY(scalbn_val, tc) "test %zu: return value %g instead of %g (difference %g)", i, rv, tests[i].result, tests[i].result-rv); } -#endif } ATF_TC(scalbn_nan);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: christos Date: Thu May 23 20:45:47 UTC 2013 Modified Files: src/tests/lib/libm: t_scalbn.c Log Message: vaxinate the new tests. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libm/t_scalbn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_scalbn.c diff -u src/tests/lib/libm/t_scalbn.c:1.8 src/tests/lib/libm/t_scalbn.c:1.9 --- src/tests/lib/libm/t_scalbn.c:1.8 Mon May 20 08:21:42 2013 +++ src/tests/lib/libm/t_scalbn.c Thu May 23 16:45:47 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_scalbn.c,v 1.8 2013/05/20 12:21:42 martin Exp $ */ +/* $NetBSD: t_scalbn.c,v 1.9 2013/05/23 20:45:47 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_scalbn.c,v 1.8 2013/05/20 12:21:42 martin Exp $"); +__RCSID("$NetBSD: t_scalbn.c,v 1.9 2013/05/23 20:45:47 christos Exp $"); #include #include @@ -75,6 +75,7 @@ ATF_TC_HEAD(scalbn_val, tc) ATF_TC_BODY(scalbn_val, tc) { +#ifndef __vax__ const struct testcase *tests = test_vals; const size_t tcnt = __arraycount(test_vals); size_t i; @@ -89,6 +90,7 @@ ATF_TC_BODY(scalbn_val, tc) "test %zu: return value %g instead of %g (difference %g)", i, rv, tests[i].result, tests[i].result-rv); } +#endif } ATF_TC(scalbn_nan); @@ -228,6 +230,7 @@ ATF_TC_HEAD(scalbnf_val, tc) ATF_TC_BODY(scalbnf_val, tc) { +#ifndef __vax__ const struct testcase *tests = test_vals; const size_t tcnt = __arraycount(test_vals); size_t i; @@ -242,6 +245,7 @@ ATF_TC_BODY(scalbnf_val, tc) "test %zu: return value %g instead of %g (difference %g)", i, rv, tests[i].result, tests[i].result-rv); } +#endif } ATF_TC(scalbnf_nan);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: martin Date: Mon May 20 12:21:42 UTC 2013 Modified Files: src/tests/lib/libm: t_scalbn.c Log Message: Add a few test cases to test "ordinary" values with the various scalbn variants. While there, make some spuriously failing tests print out the broken values on failure. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_scalbn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_scalbn.c diff -u src/tests/lib/libm/t_scalbn.c:1.7 src/tests/lib/libm/t_scalbn.c:1.8 --- src/tests/lib/libm/t_scalbn.c:1.7 Tue Sep 13 07:07:32 2011 +++ src/tests/lib/libm/t_scalbn.c Mon May 20 12:21:42 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_scalbn.c,v 1.7 2011/09/13 07:07:32 jruoho Exp $ */ +/* $NetBSD: t_scalbn.c,v 1.8 2013/05/20 12:21:42 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,18 +29,68 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_scalbn.c,v 1.7 2011/09/13 07:07:32 jruoho Exp $"); +__RCSID("$NetBSD: t_scalbn.c,v 1.8 2013/05/20 12:21:42 martin Exp $"); #include #include +#include +#include #include static const int exps[] = { 0, 1, -1, 100, -100 }; +/* tests here do not require specific precision, so we just use double */ +struct testcase { + int exp; + double inval; + double result; + int error; +}; +struct testcase test_vals[] = { + { 0, 1.00085, 1.00085, 0 }, + { 0, 0.99755, 0.99755, 0 }, + { 0, -1.00085, -1.00085, 0 }, + { 0, -0.99755, -0.99755, 0 }, + { 1, 1.00085, 2.0* 1.00085, 0 }, + { 1, 0.99755, 2.0* 0.99755, 0 }, + { 1, -1.00085, 2.0* -1.00085, 0 }, + { 1, -0.99755, 2.0* -0.99755, 0 }, + + /* + * We could add more corner test cases here, but we would have to + * add some ifdefs for the exact format and use a reliable + * generator program - bail for now and only do trivial stuff above. + */ +}; + /* * scalbn(3) */ +ATF_TC(scalbn_val); +ATF_TC_HEAD(scalbn_val, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test scalbn() for a few values"); +} + +ATF_TC_BODY(scalbn_val, tc) +{ + const struct testcase *tests = test_vals; + const size_t tcnt = __arraycount(test_vals); + size_t i; + double rv; + + for (i = 0; i < tcnt; i++) { + rv = scalbn(tests[i].inval, tests[i].exp); + ATF_CHECK_EQ_MSG(errno, tests[i].error, + "test %zu: errno %d instead of %d", i, errno, + tests[i].error); + ATF_CHECK_MSG(fabs(rv-tests[i].result)<2.0*DBL_EPSILON, + "test %zu: return value %g instead of %g (difference %g)", + i, rv, tests[i].result, tests[i].result-rv); + } +} + ATF_TC(scalbn_nan); ATF_TC_HEAD(scalbn_nan, tc) { @@ -113,7 +163,9 @@ ATF_TC_BODY(scalbn_ldexp, tc) for (i = 0; i < __arraycount(exps); i++) { y = scalbn(x, exps[i]); - ATF_CHECK(y == ldexp(x, exps[i])); + ATF_CHECK_MSG(y == ldexp(x, exps[i]), "test %zu: exponent=%d, " + "y=%g, expected %g (diff: %g)", i, exps[i], y, + ldexp(x, exps[i]), y - ldexp(x, exps[i])); } #endif #endif @@ -168,6 +220,30 @@ ATF_TC_BODY(scalbn_zero_pos, tc) /* * scalbnf(3) */ +ATF_TC(scalbnf_val); +ATF_TC_HEAD(scalbnf_val, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test scalbnf() for a few values"); +} + +ATF_TC_BODY(scalbnf_val, tc) +{ + const struct testcase *tests = test_vals; + const size_t tcnt = __arraycount(test_vals); + size_t i; + double rv; + + for (i = 0; i < tcnt; i++) { + rv = scalbnf(tests[i].inval, tests[i].exp); + ATF_CHECK_EQ_MSG(errno, tests[i].error, + "test %zu: errno %d instead of %d", i, errno, + tests[i].error); + ATF_CHECK_MSG(fabs(rv-tests[i].result)<2.0*FLT_EPSILON, + "test %zu: return value %g instead of %g (difference %g)", + i, rv, tests[i].result, tests[i].result-rv); + } +} + ATF_TC(scalbnf_nan); ATF_TC_HEAD(scalbnf_nan, tc) { @@ -240,7 +316,9 @@ ATF_TC_BODY(scalbnf_ldexpf, tc) for (i = 0; i < __arraycount(exps); i++) { y = scalbnf(x, exps[i]); - ATF_CHECK(y == ldexpf(x, exps[i])); + ATF_CHECK_MSG(y == ldexpf(x, exps[i]), + "test %zu: exponent=%d, y=%g ldexpf returns %g (diff: %g)", + i, exps[i], y, ldexpf(x, exps[i]), y-ldexpf(x, exps[i])); } #endif #endif @@ -295,6 +373,34 @@ ATF_TC_BODY(scalbnf_zero_pos, tc) /* * scalbnl(3) */ +ATF_TC(scalbnl_val); +ATF_TC_HEAD(scalbnl_val, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test scalbnl() for a few values"); +} + +ATF_TC_BODY(scalbnl_val, tc) +{ +#ifndef __HAVE_LONG_DOUBLE + atf_tc_skip("Requires long double support"); +#else + const struct testcase *tests = test_vals; + const size_t tcnt = __arraycount(test_vals); + size_t i; + long double rv; + + for (i = 0; i < tcnt; i++) { + rv = scalbnl(tests[i].inval, tests[i].exp); + ATF_CHECK_EQ_MSG(errno, tests[i].error, + "test %zu: errno %d instead of %d", i, errno, + tests[i].error); + ATF_CHECK_MSG(fabsl(rv-(long double)tests[i].result)<2.0*LDBL_EPSILON, + "test %zu: return value %Lg
CVS commit: src/tests/lib/libm
Module Name:src Committed By: isaki Date: Tue Apr 9 12:11:04 UTC 2013 Modified Files: src/tests/lib/libm: t_acos.c t_asin.c t_atan.c t_cosh.c t_sinh.c Log Message: Use a pre-calculated value as expected result, instead of comparing it in a mathematical formula. PR lib/46434 (and see also 46433). To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_acos.c cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_asin.c cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_atan.c cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_cosh.c \ src/tests/lib/libm/t_sinh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_acos.c diff -u src/tests/lib/libm/t_acos.c:1.3 src/tests/lib/libm/t_acos.c:1.4 --- src/tests/lib/libm/t_acos.c:1.3 Fri Mar 23 23:45:31 2012 +++ src/tests/lib/libm/t_acos.c Tue Apr 9 12:11:04 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_acos.c,v 1.3 2012/03/23 23:45:31 matt Exp $ */ +/* $NetBSD: t_acos.c,v 1.4 2013/04/09 12:11:04 isaki Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -32,6 +32,20 @@ #include #include +static const struct { + double x; + double y; +} values[] = { + { -1,M_PI, }, + { -0.99, 3.53180265366, }, + { -0.5, 2.094395102393195, }, + { -0.1, 1.670963747956456, }, + { 0,M_PI / 2, }, + { 0.1, 1.47062890567, }, + { 0.5, 1.047197551196598, }, + { 0.99, 0.141539473324427, }, +}; + /* * acos(3) */ @@ -119,28 +133,25 @@ ATF_TC_BODY(acos_range, tc) #endif } -ATF_TC(acos_cos); -ATF_TC_HEAD(acos_cos, tc) +ATF_TC(acos_inrange); +ATF_TC_HEAD(acos_inrange, tc) { - atf_tc_set_md_var(tc, "descr", "Test acos(cos(x)) == x"); + atf_tc_set_md_var(tc, "descr", "Test acos(x) for some values"); } -ATF_TC_BODY(acos_cos, tc) +ATF_TC_BODY(acos_inrange, tc) { #ifndef __vax__ - const double x[] = { 0.0, 1.0, M_PI / 2, M_PI / 3, M_PI / 6 }; const double eps = 1.0e-15; + double x; double y; size_t i; - for (i = 0; i < __arraycount(x); i++) { - - y = acos(cos(x[i])); - - if (fabs(y - x[i]) > eps) - atf_tc_fail_nonfatal( - "acos(cos(%0.03f)) != %0.03f (eps=%0.03e)", - x[i], x[i], fabs(y - x[i])); + for (i = 0; i < __arraycount(values); i++) { + x = values[i].x; + y = values[i].y; + if (fabs(acos(x) - y) > eps) + atf_tc_fail_nonfatal("acos(%g) != %g", x, y); } #endif } @@ -232,28 +243,25 @@ ATF_TC_BODY(acosf_range, tc) #endif } -ATF_TC(acosf_cosf); -ATF_TC_HEAD(acosf_cosf, tc) +ATF_TC(acosf_inrange); +ATF_TC_HEAD(acosf_inrange, tc) { - atf_tc_set_md_var(tc, "descr", "Test acosf(cosf(x)) == x"); + atf_tc_set_md_var(tc, "descr", "Test acosf(x) for some values"); } -ATF_TC_BODY(acosf_cosf, tc) +ATF_TC_BODY(acosf_inrange, tc) { #ifndef __vax__ - const float x[] = { 0.0, 1.0, M_PI / 2, M_PI / 3, M_PI / 6 }; const float eps = 1.0e-5; + float x; float y; size_t i; - for (i = 0; i < __arraycount(x); i++) { - - y = acosf(cosf(x[i])); - - if (fabsf(y - x[i]) > eps) - atf_tc_fail_nonfatal( - "acosf(cosf(%0.03f)) != %0.03f (eps=%0.03e)", - x[i], x[i], fabs(y - x[i])); + for (i = 0; i < __arraycount(values); i++) { + x = values[i].x; + y = values[i].y; + if (fabsf(acosf(x) - y) > eps) + atf_tc_fail_nonfatal("acosf(%g) != %g", x, y); } #endif } @@ -266,14 +274,14 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, acos_inf_pos); ATF_TP_ADD_TC(tp, acos_one_pos); ATF_TP_ADD_TC(tp, acos_range); - ATF_TP_ADD_TC(tp, acos_cos); + ATF_TP_ADD_TC(tp, acos_inrange); ATF_TP_ADD_TC(tp, acosf_nan); ATF_TP_ADD_TC(tp, acosf_inf_neg); ATF_TP_ADD_TC(tp, acosf_inf_pos); ATF_TP_ADD_TC(tp, acosf_one_pos); ATF_TP_ADD_TC(tp, acosf_range); - ATF_TP_ADD_TC(tp, acosf_cosf); + ATF_TP_ADD_TC(tp, acosf_inrange); return atf_no_error(); } Index: src/tests/lib/libm/t_asin.c diff -u src/tests/lib/libm/t_asin.c:1.1 src/tests/lib/libm/t_asin.c:1.2 --- src/tests/lib/libm/t_asin.c:1.1 Sat Sep 17 18:08:35 2011 +++ src/tests/lib/libm/t_asin.c Tue Apr 9 12:11:04 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_asin.c,v 1.1 2011/09/17 18:08:35 jruoho Exp $ */ +/* $NetBSD: t_asin.c,v 1.2 2013/04/09 12:11:04 isaki Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -32,6 +32,20 @@ #include #include +static const struct { + double x; + double y; +} values[] = { + { -1.0, -M_PI / 2, }, + { -0.9, -1.119769514998634, }, + { -0.5, -M_PI / 6, }, + { -0.1, -0.1001674211615598, }, + { 0.1, 0.1001674211615598, }, + { 0.5, M_PI / 6, }, + { 0.9, 1.119769514998634, }, + { 1.0, M_PI / 2, }, +}; + /* * asin(3) */ @@ -103,27 +117,24 @@ ATF_TC_BODY(asin_range, tc) #endif } -ATF_TC(asin_sin); -ATF_TC_HEAD(asin_sin, tc) +ATF_TC(asin_inrange); +ATF_TC_HEAD(asin_inrange, tc) { - atf_tc_set_md_var(tc, "descr", "Test asin(sin(x)) == x"); + atf_tc_set_md_var(tc, "descr", "Test asin(x) for some values"); } -ATF_TC_BODY(asin_sin, tc) +ATF_TC_BODY(a
CVS commit: src/tests/lib/libm
Module Name:src Committed By: isaki Date: Tue Apr 9 11:42:56 UTC 2013 Modified Files: src/tests/lib/libm: t_exp.c Log Message: Tune the epsilon about each value for exp{,f}_product. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_exp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_exp.c diff -u src/tests/lib/libm/t_exp.c:1.2 src/tests/lib/libm/t_exp.c:1.3 --- src/tests/lib/libm/t_exp.c:1.2 Wed May 30 15:14:10 2012 +++ src/tests/lib/libm/t_exp.c Tue Apr 9 11:42:56 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exp.c,v 1.2 2012/05/30 15:14:10 jruoho Exp $ */ +/* $NetBSD: t_exp.c,v 1.3 2013/04/09 11:42:56 isaki Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -36,16 +36,17 @@ static const struct { double x; double y; + double e; } exp_values[] = { - { -10, 0.4539992976248485e-4, }, - { -5, 0.6737946999085467e-2, }, - { -1, 0.3678794411714423, }, - { -0.1, 0.9048374180359595, }, - {0, 1., }, - { 0.1, 1.1051709180756477, }, - {1, 2.7182818284590452, }, - {5, 148.41315910257660, }, - { 10, 22026.465794806718, }, + { -10, 0.4539992976248485e-4, 1e-4, }, + { -5, 0.6737946999085467e-2, 1e-2, }, + { -1, 0.3678794411714423,1e-1, }, + { -0.1, 0.9048374180359595,1e-1, }, + {0, 1.,1,}, + { 0.1, 1.1051709180756477,1,}, + {1, 2.7182818284590452,1,}, + {5, 148.41315910257660,1e2, }, + { 10, 22026.465794806718,1e4, }, }; /* @@ -327,14 +328,15 @@ ATF_TC_HEAD(exp_product, tc) ATF_TC_BODY(exp_product, tc) { #ifndef __vax__ + double eps; double x; double y; - const double eps = 1.0e-11; size_t i; for (i = 0; i < __arraycount(exp_values); i++) { x = exp_values[i].x; y = exp_values[i].y; + eps = 1e-15 * exp_values[i].e; if (fabs(exp(x) - y) > eps) atf_tc_fail_nonfatal("exp(%0.01f) != %18.18e", x, y); @@ -436,14 +438,15 @@ ATF_TC_HEAD(expf_product, tc) ATF_TC_BODY(expf_product, tc) { #ifndef __vax__ + float eps; float x; float y; - const float eps = 1.0e-2; size_t i; for (i = 0; i < __arraycount(exp_values); i++) { x = exp_values[i].x; y = exp_values[i].y; + eps = 1e-6 * exp_values[i].e; if (fabsf(expf(x) - y) > eps) atf_tc_fail_nonfatal("expf(%0.01f) != %18.18e", x, y);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: isaki Date: Thu Mar 21 02:10:52 UTC 2013 Modified Files: src/tests/lib/libm: t_atan.c Log Message: Fix and revive test of atan_inf_neg, atan_inf_pos and atan_tan on i386. PR port-i386/46108. The machine epsilon 1.0e-40 is too severe and nonsense for double because DBL_EPSILON is about 2.2e-16 . I think that 1.0e-15 is enough good, in this case. XXX However, test of atan_tan should be replaced for other reasons. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_atan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_atan.c diff -u src/tests/lib/libm/t_atan.c:1.6 src/tests/lib/libm/t_atan.c:1.7 --- src/tests/lib/libm/t_atan.c:1.6 Sun Mar 11 06:36:05 2012 +++ src/tests/lib/libm/t_atan.c Thu Mar 21 02:10:52 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_atan.c,v 1.6 2012/03/11 06:36:05 jruoho Exp $ */ +/* $NetBSD: t_atan.c,v 1.7 2013/03/21 02:10:52 isaki Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -64,11 +64,7 @@ ATF_TC_BODY(atan_inf_neg, tc) { #ifndef __vax__ const double x = -1.0L / 0.0L; - const double eps = 1.0e-40; - - if (strcmp(atf_config_get("atf_arch"), "i386") == 0 && - system("cpuctl identify 0 | grep -q QEMU") != 0) - atf_tc_expect_fail("PR port-i386/46108"); + const double eps = 1.0e-15; if (fabs(atan(x) + M_PI_2) > eps) atf_tc_fail_nonfatal("atan(-Inf) != -pi/2"); @@ -85,11 +81,7 @@ ATF_TC_BODY(atan_inf_pos, tc) { #ifndef __vax__ const double x = +1.0L / 0.0L; - const double eps = 1.0e-40; - - if (strcmp(atf_config_get("atf_arch"), "i386") == 0 && - system("cpuctl identify 0 | grep -q QEMU") != 0) - atf_tc_expect_fail("PR port-i386/46108"); + const double eps = 1.0e-15; if (fabs(atan(x) - M_PI_2) > eps) atf_tc_fail_nonfatal("atan(+Inf) != pi/2"); @@ -106,14 +98,10 @@ ATF_TC_BODY(atan_tan, tc) { #ifndef __vax__ const double x[] = { 0.0, 1.0, M_PI / 2, M_PI / 3, M_PI / 6 }; - const double eps = 1.0e-40; + const double eps = 1.0e-15; double y; size_t i; - if (strcmp(atf_config_get("atf_arch"), "i386") == 0 && - system("cpuctl identify 0 | grep -q QEMU") != 0) - atf_tc_expect_fail("PR port-i386/46108"); - for (i = 0; i < __arraycount(x); i++) { y = atan(tan(x[i]));
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Wed May 30 15:14:11 UTC 2012 Modified Files: src/tests/lib/libm: t_exp.c Log Message: Add patch from Tetsuya Isaki in PR lib/46433. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_exp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_exp.c diff -u src/tests/lib/libm/t_exp.c:1.1 src/tests/lib/libm/t_exp.c:1.2 --- src/tests/lib/libm/t_exp.c:1.1 Sun Sep 18 05:19:18 2011 +++ src/tests/lib/libm/t_exp.c Wed May 30 15:14:10 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exp.c,v 1.1 2011/09/18 05:19:18 jruoho Exp $ */ +/* $NetBSD: t_exp.c,v 1.2 2012/05/30 15:14:10 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -32,6 +32,22 @@ #include #include +/* y = exp(x) */ +static const struct { + double x; + double y; +} exp_values[] = { + { -10, 0.4539992976248485e-4, }, + { -5, 0.6737946999085467e-2, }, + { -1, 0.3678794411714423, }, + { -0.1, 0.9048374180359595, }, + {0, 1., }, + { 0.1, 1.1051709180756477, }, + {1, 2.7182818284590452, }, + {5, 148.41315910257660, }, + { 10, 22026.465794806718, }, +}; + /* * exp2(3) */ @@ -305,22 +321,23 @@ ATF_TC_BODY(exp_inf_pos, tc) ATF_TC(exp_product); ATF_TC_HEAD(exp_product, tc) { - atf_tc_set_md_var(tc, "descr", "Test exp(x + y) == exp(x) * exp(y)"); + atf_tc_set_md_var(tc, "descr", "Test some selected exp(x)"); } ATF_TC_BODY(exp_product, tc) { #ifndef __vax__ - const double x[] = { 0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8 }; - const double y[] = { 8.8, 7.7, 6.6, 5.5, 4.4, 3.3, 2.2, 1.1, 0.0 }; + double x; + double y; const double eps = 1.0e-11; size_t i; - for (i = 0; i < __arraycount(x); i++) { + for (i = 0; i < __arraycount(exp_values); i++) { + x = exp_values[i].x; + y = exp_values[i].y; - if (fabs(exp(x[i] + y[i]) - (exp(x[i]) * exp(y[i]))) > eps) - atf_tc_fail_nonfatal("exp(%0.01f + %0.01f) != exp(" - "%0.01f) * exp(%0.01f)", x[i], y[i], x[i], y[i]); + if (fabs(exp(x) - y) > eps) + atf_tc_fail_nonfatal("exp(%0.01f) != %18.18e", x, y); } #endif } @@ -413,22 +430,23 @@ ATF_TC_BODY(expf_inf_pos, tc) ATF_TC(expf_product); ATF_TC_HEAD(expf_product, tc) { - atf_tc_set_md_var(tc, "descr", "Test expf(x+y) == expf(x) * expf(y)"); + atf_tc_set_md_var(tc, "descr", "Test some selected expf(x)"); } ATF_TC_BODY(expf_product, tc) { #ifndef __vax__ - const float x[] = { 0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8 }; - const float y[] = { 8.8, 7.7, 6.6, 5.5, 4.4, 3.3, 2.2, 1.1, 0.0 }; + float x; + float y; const float eps = 1.0e-2; size_t i; - for (i = 0; i < __arraycount(x); i++) { + for (i = 0; i < __arraycount(exp_values); i++) { + x = exp_values[i].x; + y = exp_values[i].y; - if (fabsf(expf(x[i] + y[i]) - (expf(x[i]) * expf(y[i]))) > eps) - atf_tc_fail_nonfatal("expf(%0.01f + %0.01f) != expf(" - "%0.01f) * expf(%0.01f)", x[i], y[i], x[i], y[i]); + if (fabsf(expf(x) - y) > eps) + atf_tc_fail_nonfatal("expf(%0.01f) != %18.18e", x, y); } #endif }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Sun Apr 8 09:36:04 UTC 2012 Modified Files: src/tests/lib/libm: t_log.c Log Message: Remove one xfail that does not seem to fail (on alpha). To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_log.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_log.c diff -u src/tests/lib/libm/t_log.c:1.7 src/tests/lib/libm/t_log.c:1.8 --- src/tests/lib/libm/t_log.c:1.7 Fri Apr 6 08:07:32 2012 +++ src/tests/lib/libm/t_log.c Sun Apr 8 09:36:04 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_log.c,v 1.7 2012/04/06 08:07:32 jruoho Exp $ */ +/* $NetBSD: t_log.c,v 1.8 2012/04/08 09:36:04 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_log.c,v 1.7 2012/04/06 08:07:32 jruoho Exp $"); +__RCSID("$NetBSD: t_log.c,v 1.8 2012/04/08 09:36:04 jruoho Exp $"); #include #include @@ -409,9 +409,6 @@ ATF_TC_BODY(log1pf_inf_pos, tc) #ifndef __vax__ const float x = 1.0L / 0.0L; - if (strcmp(atf_config_get("atf_arch"), "alpha") == 0) - atf_tc_expect_fail("PR port-alpha/46301"); - ATF_CHECK(log1pf(x) == x); #endif }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Fri Apr 6 08:07:32 UTC 2012 Modified Files: src/tests/lib/libm: t_log.c Log Message: Point to PR port-alpha/46301 when failing on Alpha. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_log.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_log.c diff -u src/tests/lib/libm/t_log.c:1.6 src/tests/lib/libm/t_log.c:1.7 --- src/tests/lib/libm/t_log.c:1.6 Sun Feb 5 17:52:55 2012 +++ src/tests/lib/libm/t_log.c Fri Apr 6 08:07:32 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_log.c,v 1.6 2012/02/05 17:52:55 matt Exp $ */ +/* $NetBSD: t_log.c,v 1.7 2012/04/06 08:07:32 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,11 +29,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_log.c,v 1.6 2012/02/05 17:52:55 matt Exp $"); +__RCSID("$NetBSD: t_log.c,v 1.7 2012/04/06 08:07:32 jruoho Exp $"); #include -#include +#include + #include +#include +#include /* * log10(3) @@ -201,6 +204,9 @@ ATF_TC_BODY(log10f_inf_pos, tc) #ifndef __vax__ const float x = 1.0L / 0.0L; + if (strcmp(atf_config_get("atf_arch"), "alpha") == 0) + atf_tc_expect_fail("PR port-alpha/46301"); + ATF_CHECK(log10f(x) == x); #endif } @@ -403,6 +409,9 @@ ATF_TC_BODY(log1pf_inf_pos, tc) #ifndef __vax__ const float x = 1.0L / 0.0L; + if (strcmp(atf_config_get("atf_arch"), "alpha") == 0) + atf_tc_expect_fail("PR port-alpha/46301"); + ATF_CHECK(log1pf(x) == x); #endif } @@ -621,6 +630,9 @@ ATF_TC_BODY(log2f_inf_pos, tc) #ifndef __vax__ const float x = 1.0L / 0.0L; + if (strcmp(atf_config_get("atf_arch"), "alpha") == 0) + atf_tc_expect_fail("PR port-alpha/46301"); + ATF_CHECK(log2f(x) == x); #endif } @@ -845,6 +857,9 @@ ATF_TC_BODY(logf_inf_pos, tc) #ifndef __vax__ const float x = 1.0L / 0.0L; + if (strcmp(atf_config_get("atf_arch"), "alpha") == 0) + atf_tc_expect_fail("PR port-alpha/46301"); + ATF_CHECK(logf(x) == x); #endif }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: matt Date: Fri Mar 23 23:45:31 UTC 2012 Modified Files: src/tests/lib/libm: t_acos.c Log Message: If one of the tests with eps fails, print the failing eps. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_acos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_acos.c diff -u src/tests/lib/libm/t_acos.c:1.2 src/tests/lib/libm/t_acos.c:1.3 --- src/tests/lib/libm/t_acos.c:1.2 Sun Sep 18 04:48:38 2011 +++ src/tests/lib/libm/t_acos.c Fri Mar 23 23:45:31 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_acos.c,v 1.2 2011/09/18 04:48:38 jruoho Exp $ */ +/* $NetBSD: t_acos.c,v 1.3 2012/03/23 23:45:31 matt Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -138,8 +138,9 @@ ATF_TC_BODY(acos_cos, tc) y = acos(cos(x[i])); if (fabs(y - x[i]) > eps) - atf_tc_fail_nonfatal("acos(cos(%0.03f)) != %0.03f", - x[i], x[i]); + atf_tc_fail_nonfatal( + "acos(cos(%0.03f)) != %0.03f (eps=%0.03e)", + x[i], x[i], fabs(y - x[i])); } #endif } @@ -250,8 +251,9 @@ ATF_TC_BODY(acosf_cosf, tc) y = acosf(cosf(x[i])); if (fabsf(y - x[i]) > eps) - atf_tc_fail_nonfatal("acosf(cosf(%0.03f)) != %0.03f", - x[i], x[i]); + atf_tc_fail_nonfatal( + "acosf(cosf(%0.03f)) != %0.03f (eps=%0.03e)", + x[i], x[i], fabs(y - x[i])); } #endif }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Sun Mar 11 06:36:05 UTC 2012 Modified Files: src/tests/lib/libm: t_atan.c Log Message: And finally, fix boolean logic in the previous. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_atan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_atan.c diff -u src/tests/lib/libm/t_atan.c:1.5 src/tests/lib/libm/t_atan.c:1.6 --- src/tests/lib/libm/t_atan.c:1.5 Sun Mar 11 06:32:53 2012 +++ src/tests/lib/libm/t_atan.c Sun Mar 11 06:36:05 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_atan.c,v 1.5 2012/03/11 06:32:53 jruoho Exp $ */ +/* $NetBSD: t_atan.c,v 1.6 2012/03/11 06:36:05 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ ATF_TC_BODY(atan_inf_neg, tc) const double eps = 1.0e-40; if (strcmp(atf_config_get("atf_arch"), "i386") == 0 && - system("cpuctl identify 0 | grep -q QEMU") == 0) + system("cpuctl identify 0 | grep -q QEMU") != 0) atf_tc_expect_fail("PR port-i386/46108"); if (fabs(atan(x) + M_PI_2) > eps) @@ -88,7 +88,7 @@ ATF_TC_BODY(atan_inf_pos, tc) const double eps = 1.0e-40; if (strcmp(atf_config_get("atf_arch"), "i386") == 0 && - system("cpuctl identify 0 | grep -q QEMU") == 0) + system("cpuctl identify 0 | grep -q QEMU") != 0) atf_tc_expect_fail("PR port-i386/46108"); if (fabs(atan(x) - M_PI_2) > eps) @@ -111,7 +111,7 @@ ATF_TC_BODY(atan_tan, tc) size_t i; if (strcmp(atf_config_get("atf_arch"), "i386") == 0 && - system("cpuctl identify 0 | grep -q QEMU") == 0) + system("cpuctl identify 0 | grep -q QEMU") != 0) atf_tc_expect_fail("PR port-i386/46108"); for (i = 0; i < __arraycount(x); i++) {
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Sun Mar 11 06:32:53 UTC 2012 Modified Files: src/tests/lib/libm: t_atan.c Log Message: Fix previous: curiously enough, i386/qemu is not affected, so use the "system(3) hack" to identify Qemu. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_atan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_atan.c diff -u src/tests/lib/libm/t_atan.c:1.4 src/tests/lib/libm/t_atan.c:1.5 --- src/tests/lib/libm/t_atan.c:1.4 Sat Mar 10 20:11:01 2012 +++ src/tests/lib/libm/t_atan.c Sun Mar 11 06:32:53 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_atan.c,v 1.4 2012/03/10 20:11:01 jruoho Exp $ */ +/* $NetBSD: t_atan.c,v 1.5 2012/03/11 06:32:53 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -32,6 +32,7 @@ #include #include #include +#include #include /* @@ -65,7 +66,8 @@ ATF_TC_BODY(atan_inf_neg, tc) const double x = -1.0L / 0.0L; const double eps = 1.0e-40; - if (strcmp(atf_config_get("atf_arch"), "i386") == 0) + if (strcmp(atf_config_get("atf_arch"), "i386") == 0 && + system("cpuctl identify 0 | grep -q QEMU") == 0) atf_tc_expect_fail("PR port-i386/46108"); if (fabs(atan(x) + M_PI_2) > eps) @@ -85,7 +87,8 @@ ATF_TC_BODY(atan_inf_pos, tc) const double x = +1.0L / 0.0L; const double eps = 1.0e-40; - if (strcmp(atf_config_get("atf_arch"), "i386") == 0) + if (strcmp(atf_config_get("atf_arch"), "i386") == 0 && + system("cpuctl identify 0 | grep -q QEMU") == 0) atf_tc_expect_fail("PR port-i386/46108"); if (fabs(atan(x) - M_PI_2) > eps) @@ -107,7 +110,8 @@ ATF_TC_BODY(atan_tan, tc) double y; size_t i; - if (strcmp(atf_config_get("atf_arch"), "i386") == 0) + if (strcmp(atf_config_get("atf_arch"), "i386") == 0 && + system("cpuctl identify 0 | grep -q QEMU") == 0) atf_tc_expect_fail("PR port-i386/46108"); for (i = 0; i < __arraycount(x); i++) {
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Sat Mar 10 20:11:01 UTC 2012 Modified Files: src/tests/lib/libm: t_atan.c Log Message: Point to PR port-i386/46108 when failing on i386. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_atan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_atan.c diff -u src/tests/lib/libm/t_atan.c:1.3 src/tests/lib/libm/t_atan.c:1.4 --- src/tests/lib/libm/t_atan.c:1.3 Tue Feb 28 08:58:39 2012 +++ src/tests/lib/libm/t_atan.c Sat Mar 10 20:11:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_atan.c,v 1.3 2012/02/28 08:58:39 pgoyette Exp $ */ +/* $NetBSD: t_atan.c,v 1.4 2012/03/10 20:11:01 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -30,7 +30,9 @@ */ #include +#include #include +#include /* * atan(3) @@ -63,6 +65,9 @@ ATF_TC_BODY(atan_inf_neg, tc) const double x = -1.0L / 0.0L; const double eps = 1.0e-40; + if (strcmp(atf_config_get("atf_arch"), "i386") == 0) + atf_tc_expect_fail("PR port-i386/46108"); + if (fabs(atan(x) + M_PI_2) > eps) atf_tc_fail_nonfatal("atan(-Inf) != -pi/2"); #endif @@ -80,6 +85,9 @@ ATF_TC_BODY(atan_inf_pos, tc) const double x = +1.0L / 0.0L; const double eps = 1.0e-40; + if (strcmp(atf_config_get("atf_arch"), "i386") == 0) + atf_tc_expect_fail("PR port-i386/46108"); + if (fabs(atan(x) - M_PI_2) > eps) atf_tc_fail_nonfatal("atan(+Inf) != pi/2"); #endif @@ -99,6 +107,9 @@ ATF_TC_BODY(atan_tan, tc) double y; size_t i; + if (strcmp(atf_config_get("atf_arch"), "i386") == 0) + atf_tc_expect_fail("PR port-i386/46108"); + for (i = 0; i < __arraycount(x); i++) { y = atan(tan(x[i]));
CVS commit: src/tests/lib/libm
Module Name:src Committed By: pgoyette Date: Tue Feb 28 08:58:39 UTC 2012 Modified Files: src/tests/lib/libm: t_atan.c Log Message: Remove an escape sequence that was introduced by accident. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_atan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_atan.c diff -u src/tests/lib/libm/t_atan.c:1.2 src/tests/lib/libm/t_atan.c:1.3 --- src/tests/lib/libm/t_atan.c:1.2 Tue Feb 28 06:09:48 2012 +++ src/tests/lib/libm/t_atan.c Tue Feb 28 08:58:39 2012 @@ -1,4 +1,4 @@ -B0;259;0c/* $NetBSD: t_atan.c,v 1.2 2012/02/28 06:09:48 jruoho Exp $ */ +/* $NetBSD: t_atan.c,v 1.3 2012/02/28 08:58:39 pgoyette Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc.
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Tue Feb 28 06:09:49 UTC 2012 Modified Files: src/tests/lib/libm: t_atan.c Log Message: Fix wrong type. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_atan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_atan.c diff -u src/tests/lib/libm/t_atan.c:1.1 src/tests/lib/libm/t_atan.c:1.2 --- src/tests/lib/libm/t_atan.c:1.1 Sat Sep 17 18:08:35 2011 +++ src/tests/lib/libm/t_atan.c Tue Feb 28 06:09:48 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_atan.c,v 1.1 2011/09/17 18:08:35 jruoho Exp $ */ +B0;259;0c/* $NetBSD: t_atan.c,v 1.2 2012/02/28 06:09:48 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ ATF_TC_BODY(atan_inf_neg, tc) { #ifndef __vax__ const double x = -1.0L / 0.0L; - const float eps = 1.0e-40; + const double eps = 1.0e-40; if (fabs(atan(x) + M_PI_2) > eps) atf_tc_fail_nonfatal("atan(-Inf) != -pi/2"); @@ -78,7 +78,7 @@ ATF_TC_BODY(atan_inf_pos, tc) { #ifndef __vax__ const double x = +1.0L / 0.0L; - const float eps = 1.0e-40; + const double eps = 1.0e-40; if (fabs(atan(x) - M_PI_2) > eps) atf_tc_fail_nonfatal("atan(+Inf) != pi/2");
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Mon Feb 13 05:09:01 UTC 2012 Modified Files: src/tests/lib/libm: t_sqrt.c Log Message: Fix wrong error failure message. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_sqrt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_sqrt.c diff -u src/tests/lib/libm/t_sqrt.c:1.2 src/tests/lib/libm/t_sqrt.c:1.3 --- src/tests/lib/libm/t_sqrt.c:1.2 Sat Nov 19 12:46:41 2011 +++ src/tests/lib/libm/t_sqrt.c Mon Feb 13 05:09:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sqrt.c,v 1.2 2011/11/19 12:46:41 mlelstv Exp $ */ +/* $NetBSD: t_sqrt.c,v 1.3 2012/02/13 05:09:01 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_sqrt.c,v 1.2 2011/11/19 12:46:41 mlelstv Exp $"); +__RCSID("$NetBSD: t_sqrt.c,v 1.3 2012/02/13 05:09:01 jruoho Exp $"); #include #include @@ -75,7 +75,7 @@ ATF_TC_BODY(sqrt_pow, tc) if (fabs(y - z) > eps) atf_tc_fail_nonfatal("sqrt(%0.03f) != " - "pow(%0.03f, 1/3)\n", x[i], x[i]); + "pow(%0.03f, 1/2)\n", x[i], x[i]); } #endif }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: matt Date: Sun Feb 5 17:52:55 UTC 2012 Modified Files: src/tests/lib/libm: t_log.c Log Message: Change eps to fit within the VAX FP range. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_log.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_log.c diff -u src/tests/lib/libm/t_log.c:1.5 src/tests/lib/libm/t_log.c:1.6 --- src/tests/lib/libm/t_log.c:1.5 Sun Sep 18 04:49:11 2011 +++ src/tests/lib/libm/t_log.c Sun Feb 5 17:52:55 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_log.c,v 1.5 2011/09/18 04:49:11 jruoho Exp $ */ +/* $NetBSD: t_log.c,v 1.6 2012/02/05 17:52:55 matt Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_log.c,v 1.5 2011/09/18 04:49:11 jruoho Exp $"); +__RCSID("$NetBSD: t_log.c,v 1.6 2012/02/05 17:52:55 matt Exp $"); #include #include @@ -684,7 +684,7 @@ ATF_TC_HEAD(log_base, tc) ATF_TC_BODY(log_base, tc) { - const double eps = 1.0e-40; + const double eps = 1.0e-38; if (fabs(log(M_E) - 1.0) > eps) atf_tc_fail_nonfatal("log(e) != 1");
CVS commit: src/tests/lib/libm
Module Name:src Committed By: mlelstv Date: Sat Nov 19 12:46:41 UTC 2011 Modified Files: src/tests/lib/libm: t_sqrt.c Log Message: The compiler is allowed to use intermediate higher precision for float arithmetic, which may cause differences smaller than float precision but still much larger than eps = 1e-30. Forcing intermediate results to volatile variables removes the excess precision. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_sqrt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_sqrt.c diff -u src/tests/lib/libm/t_sqrt.c:1.1 src/tests/lib/libm/t_sqrt.c:1.2 --- src/tests/lib/libm/t_sqrt.c:1.1 Sun Oct 16 08:25:40 2011 +++ src/tests/lib/libm/t_sqrt.c Sat Nov 19 12:46:41 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sqrt.c,v 1.1 2011/10/16 08:25:40 jruoho Exp $ */ +/* $NetBSD: t_sqrt.c,v 1.2 2011/11/19 12:46:41 mlelstv Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_sqrt.c,v 1.1 2011/10/16 08:25:40 jruoho Exp $"); +__RCSID("$NetBSD: t_sqrt.c,v 1.2 2011/11/19 12:46:41 mlelstv Exp $"); #include #include @@ -177,7 +177,7 @@ ATF_TC_BODY(sqrtf_powf, tc) #ifndef __vax__ const float x[] = { 0.0, 0.005, 1.0, 99.0, 123.123, . }; const float eps = 1.0e-30; - float y, z; + volatile float y, z; size_t i; for (i = 0; i < __arraycount(x); i++) { @@ -187,7 +187,7 @@ ATF_TC_BODY(sqrtf_powf, tc) if (fabsf(y - z) > eps) atf_tc_fail_nonfatal("sqrtf(%0.03f) != " - "powf(%0.03f, 1/3)\n", x[i], x[i]); + "powf(%0.03f, 1/2)\n", x[i], x[i]); } #endif }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Tue Oct 18 14:16:42 UTC 2011 Modified Files: src/tests/lib/libm: t_cosh.c t_sinh.c Log Message: Reduce tolerance even more. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_cosh.c \ src/tests/lib/libm/t_sinh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_cosh.c diff -u src/tests/lib/libm/t_cosh.c:1.3 src/tests/lib/libm/t_cosh.c:1.4 --- src/tests/lib/libm/t_cosh.c:1.3 Tue Oct 18 04:51:01 2011 +++ src/tests/lib/libm/t_cosh.c Tue Oct 18 14:16:42 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_cosh.c,v 1.3 2011/10/18 04:51:01 jruoho Exp $ */ +/* $NetBSD: t_cosh.c,v 1.4 2011/10/18 14:16:42 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_cosh.c,v 1.3 2011/10/18 04:51:01 jruoho Exp $"); +__RCSID("$NetBSD: t_cosh.c,v 1.4 2011/10/18 14:16:42 jruoho Exp $"); #include #include @@ -163,7 +163,7 @@ ATF_TC_BODY(coshf_def, tc) { #ifndef __vax__ const double x[] = { 0.005, 0.05, 0.0, 1.0, 10.0, 20.0 }; - const float eps = 1.0e-7; + const float eps = 1.0e-3; float y, z; size_t i; Index: src/tests/lib/libm/t_sinh.c diff -u src/tests/lib/libm/t_sinh.c:1.3 src/tests/lib/libm/t_sinh.c:1.4 --- src/tests/lib/libm/t_sinh.c:1.3 Tue Oct 18 04:51:01 2011 +++ src/tests/lib/libm/t_sinh.c Tue Oct 18 14:16:42 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sinh.c,v 1.3 2011/10/18 04:51:01 jruoho Exp $ */ +/* $NetBSD: t_sinh.c,v 1.4 2011/10/18 14:16:42 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_sinh.c,v 1.3 2011/10/18 04:51:01 jruoho Exp $"); +__RCSID("$NetBSD: t_sinh.c,v 1.4 2011/10/18 14:16:42 jruoho Exp $"); #include #include @@ -48,7 +48,7 @@ ATF_TC_BODY(sinh_def, tc) { #ifndef __vax__ const double x[] = { 0.005, 0.05, 0.0, 1.0, 10.0, 20.0 }; - const double eps = 1.0e-8; + const double eps = 1.0e-4; double y, z; size_t i; @@ -165,7 +165,7 @@ ATF_TC_BODY(sinhf_def, tc) { #ifndef __vax__ const float x[] = { 0.005, 0.05, 0.0, 1.0, 10.0, 20.0 }; - const float eps = 1.0e-4; + const float eps = 1.0e-2; float y, z; size_t i;
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Tue Oct 18 04:51:01 UTC 2011 Modified Files: src/tests/lib/libm: t_cosh.c t_sinh.c Log Message: Adjust and add some printfs. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libm/t_cosh.c \ src/tests/lib/libm/t_sinh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_cosh.c diff -u src/tests/lib/libm/t_cosh.c:1.2 src/tests/lib/libm/t_cosh.c:1.3 --- src/tests/lib/libm/t_cosh.c:1.2 Sun Oct 16 13:42:22 2011 +++ src/tests/lib/libm/t_cosh.c Tue Oct 18 04:51:01 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_cosh.c,v 1.2 2011/10/16 13:42:22 jruoho Exp $ */ +/* $NetBSD: t_cosh.c,v 1.3 2011/10/18 04:51:01 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_cosh.c,v 1.2 2011/10/16 13:42:22 jruoho Exp $"); +__RCSID("$NetBSD: t_cosh.c,v 1.3 2011/10/18 04:51:01 jruoho Exp $"); #include #include @@ -47,7 +47,7 @@ ATF_TC_HEAD(cosh_def, tc) ATF_TC_BODY(cosh_def, tc) { #ifndef __vax__ - const double x[] = { -9.0, -1.0, -0.05, 0.0, 1.0, 10.0, 20.0 }; + const double x[] = { 0.005, 0.05, 0.0, 1.0, 10.0, 20.0 }; const double eps = 1.0e-8; double y, z; size_t i; @@ -57,6 +57,10 @@ ATF_TC_BODY(cosh_def, tc) y = cosh(x[i]); z = (exp(x[i]) + exp(-x[i])) / 2; + (void)fprintf(stderr, + "cosh(%0.03f) = %f\n(exp(%0.03f) + " + "exp(-%0.03f)) / 2 = %f\n", x[i], y, x[i], x[i], z); + if (fabs(y - z) > eps) atf_tc_fail_nonfatal("cosh(%0.03f) != %0.03f\n", x[i], z); @@ -158,7 +162,7 @@ ATF_TC_HEAD(coshf_def, tc) ATF_TC_BODY(coshf_def, tc) { #ifndef __vax__ - const float x[] = { -9.0, -1.0, -0.05, 0.0, 1.0, 10.0, 20.0 }; + const double x[] = { 0.005, 0.05, 0.0, 1.0, 10.0, 20.0 }; const float eps = 1.0e-7; float y, z; size_t i; @@ -168,6 +172,10 @@ ATF_TC_BODY(coshf_def, tc) y = coshf(x[i]); z = (expf(x[i]) + expf(-x[i])) / 2; + (void)fprintf(stderr, + "coshf(%0.03f) = %f\n(expf(%0.03f) + " + "expf(-%0.03f)) / 2 = %f\n", x[i], y, x[i], x[i], z); + if (fabsf(y - z) > eps) atf_tc_fail_nonfatal("coshf(%0.03f) != %0.03f\n", x[i], z); Index: src/tests/lib/libm/t_sinh.c diff -u src/tests/lib/libm/t_sinh.c:1.2 src/tests/lib/libm/t_sinh.c:1.3 --- src/tests/lib/libm/t_sinh.c:1.2 Sun Oct 16 13:42:22 2011 +++ src/tests/lib/libm/t_sinh.c Tue Oct 18 04:51:01 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sinh.c,v 1.2 2011/10/16 13:42:22 jruoho Exp $ */ +/* $NetBSD: t_sinh.c,v 1.3 2011/10/18 04:51:01 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_sinh.c,v 1.2 2011/10/16 13:42:22 jruoho Exp $"); +__RCSID("$NetBSD: t_sinh.c,v 1.3 2011/10/18 04:51:01 jruoho Exp $"); #include #include @@ -47,7 +47,7 @@ ATF_TC_HEAD(sinh_def, tc) ATF_TC_BODY(sinh_def, tc) { #ifndef __vax__ - const double x[] = { -9.0, -1.0, -0.05, 0.0, 1.0, 10.0, 20.0 }; + const double x[] = { 0.005, 0.05, 0.0, 1.0, 10.0, 20.0 }; const double eps = 1.0e-8; double y, z; size_t i; @@ -57,6 +57,10 @@ ATF_TC_BODY(sinh_def, tc) y = sinh(x[i]); z = (exp(x[i]) - exp(-x[i])) / 2; + (void)fprintf(stderr, + "sinh(%0.03f) = %f\n(exp(%0.03f) - " + "exp(-%0.03f)) / 2 = %f\n", x[i], y, x[i], x[i], z); + if (fabs(y - z) > eps) atf_tc_fail_nonfatal("sinh(%0.03f) != %0.03f\n", x[i], z); @@ -160,7 +164,7 @@ ATF_TC_HEAD(sinhf_def, tc) ATF_TC_BODY(sinhf_def, tc) { #ifndef __vax__ - const float x[] = { -9.0, -1.0, -0.05, 0.0, 1.0, 10.0, 20.0 }; + const float x[] = { 0.005, 0.05, 0.0, 1.0, 10.0, 20.0 }; const float eps = 1.0e-4; float y, z; size_t i; @@ -170,6 +174,10 @@ ATF_TC_BODY(sinhf_def, tc) y = sinhf(x[i]); z = (expf(x[i]) - expf(-x[i])) / 2; + (void)fprintf(stderr, + "sinhf(%0.03f) = %f\n(expf(%0.03f) - " + "expf(-%0.03f)) / 2 = %f\n", x[i], y, x[i], x[i], z); + if (fabsf(y - z) > eps) atf_tc_fail_nonfatal("sinhf(%0.03f) != %0.03f\n", x[i], z);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Sun Oct 16 13:43:26 UTC 2011 Modified Files: src/tests/lib/libm: Makefile Log Message: Remove 't_rint' as it was committed accidentally. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.16 src/tests/lib/libm/Makefile:1.17 --- src/tests/lib/libm/Makefile:1.16 Sun Oct 16 13:42:22 2011 +++ src/tests/lib/libm/Makefile Sun Oct 16 13:43:26 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.16 2011/10/16 13:42:22 jruoho Exp $ +# $NetBSD: Makefile,v 1.17 2011/10/16 13:43:26 jruoho Exp $ .include @@ -17,7 +17,6 @@ TESTS_C+= t_infinity TESTS_C+= t_ldexp TESTS_C+= t_log TESTS_C+= t_pow -TESTS_C+= t_rint TESTS_C+= t_round TESTS_C+= t_scalbn TESTS_C+= t_sin
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Sun Oct 16 13:42:22 UTC 2011 Modified Files: src/tests/lib/libm: Makefile t_cosh.c t_sinh.c Log Message: As couple of checks fails on i386/qemu, reduce tolerance. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libm/Makefile cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_cosh.c \ src/tests/lib/libm/t_sinh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.15 src/tests/lib/libm/Makefile:1.16 --- src/tests/lib/libm/Makefile:1.15 Sun Oct 16 08:25:55 2011 +++ src/tests/lib/libm/Makefile Sun Oct 16 13:42:22 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.15 2011/10/16 08:25:55 jruoho Exp $ +# $NetBSD: Makefile,v 1.16 2011/10/16 13:42:22 jruoho Exp $ .include @@ -17,6 +17,7 @@ TESTS_C+= t_infinity TESTS_C+= t_ldexp TESTS_C+= t_log TESTS_C+= t_pow +TESTS_C+= t_rint TESTS_C+= t_round TESTS_C+= t_scalbn TESTS_C+= t_sin @@ -28,4 +29,8 @@ TESTS_C+= t_tanh LDADD+= -lm #COPTS+= -Wfloat-equal +.if ${MACHINE_ARCH} == "alpha" +COPTS+= -mieee +.endif + .include Index: src/tests/lib/libm/t_cosh.c diff -u src/tests/lib/libm/t_cosh.c:1.1 src/tests/lib/libm/t_cosh.c:1.2 --- src/tests/lib/libm/t_cosh.c:1.1 Sun Oct 16 07:40:47 2011 +++ src/tests/lib/libm/t_cosh.c Sun Oct 16 13:42:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_cosh.c,v 1.1 2011/10/16 07:40:47 jruoho Exp $ */ +/* $NetBSD: t_cosh.c,v 1.2 2011/10/16 13:42:22 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_cosh.c,v 1.1 2011/10/16 07:40:47 jruoho Exp $"); +__RCSID("$NetBSD: t_cosh.c,v 1.2 2011/10/16 13:42:22 jruoho Exp $"); #include #include @@ -48,7 +48,7 @@ ATF_TC_BODY(cosh_def, tc) { #ifndef __vax__ const double x[] = { -9.0, -1.0, -0.05, 0.0, 1.0, 10.0, 20.0 }; - const double eps = 1.0e-16; + const double eps = 1.0e-8; double y, z; size_t i; Index: src/tests/lib/libm/t_sinh.c diff -u src/tests/lib/libm/t_sinh.c:1.1 src/tests/lib/libm/t_sinh.c:1.2 --- src/tests/lib/libm/t_sinh.c:1.1 Sun Oct 16 07:40:47 2011 +++ src/tests/lib/libm/t_sinh.c Sun Oct 16 13:42:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sinh.c,v 1.1 2011/10/16 07:40:47 jruoho Exp $ */ +/* $NetBSD: t_sinh.c,v 1.2 2011/10/16 13:42:22 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_sinh.c,v 1.1 2011/10/16 07:40:47 jruoho Exp $"); +__RCSID("$NetBSD: t_sinh.c,v 1.2 2011/10/16 13:42:22 jruoho Exp $"); #include #include @@ -48,7 +48,7 @@ ATF_TC_BODY(sinh_def, tc) { #ifndef __vax__ const double x[] = { -9.0, -1.0, -0.05, 0.0, 1.0, 10.0, 20.0 }; - const double eps = 1.0e-16; + const double eps = 1.0e-8; double y, z; size_t i; @@ -161,7 +161,7 @@ ATF_TC_BODY(sinhf_def, tc) { #ifndef __vax__ const float x[] = { -9.0, -1.0, -0.05, 0.0, 1.0, 10.0, 20.0 }; - const float eps = 1.0e-7; + const float eps = 1.0e-4; float y, z; size_t i;
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Sun Oct 16 08:25:55 UTC 2011 Modified Files: src/tests/lib/libm: Makefile Log Message: Add t_sqrt and t_cbrt. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.14 src/tests/lib/libm/Makefile:1.15 --- src/tests/lib/libm/Makefile:1.14 Sun Oct 16 07:40:48 2011 +++ src/tests/lib/libm/Makefile Sun Oct 16 08:25:55 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.14 2011/10/16 07:40:48 jruoho Exp $ +# $NetBSD: Makefile,v 1.15 2011/10/16 08:25:55 jruoho Exp $ .include @@ -7,6 +7,7 @@ TESTSDIR= ${TESTSBASE}/lib/libm TESTS_C+= t_acos TESTS_C+= t_asin TESTS_C+= t_atan +TESTS_C+= t_cbrt TESTS_C+= t_ceil TESTS_C+= t_cos TESTS_C+= t_cosh @@ -20,6 +21,7 @@ TESTS_C+= t_round TESTS_C+= t_scalbn TESTS_C+= t_sin TESTS_C+= t_sinh +TESTS_C+= t_sqrt TESTS_C+= t_tan TESTS_C+= t_tanh
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Fri Sep 23 13:48:28 UTC 2011 Modified Files: src/tests/lib/libm: t_pow.c Log Message: More bugs in pow(3); cases for PR port-amd64/45391. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_pow.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_pow.c diff -u src/tests/lib/libm/t_pow.c:1.1 src/tests/lib/libm/t_pow.c:1.2 --- src/tests/lib/libm/t_pow.c:1.1 Sat Sep 17 08:15:43 2011 +++ src/tests/lib/libm/t_pow.c Fri Sep 23 13:48:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_pow.c,v 1.1 2011/09/17 08:15:43 jruoho Exp $ */ +/* $NetBSD: t_pow.c,v 1.2 2011/09/23 13:48:28 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_pow.c,v 1.1 2011/09/17 08:15:43 jruoho Exp $"); +__RCSID("$NetBSD: t_pow.c,v 1.2 2011/09/23 13:48:28 jruoho Exp $"); #include #include @@ -296,13 +296,29 @@ */ z = pow(+0.0, -4.0); - if (z != -HUGE_VAL) - atf_tc_fail_nonfatal("pow(+0.0, -4.0) != -HUGE_VAL"); + if (z != HUGE_VAL) { + atf_tc_expect_fail("PR port-amd64/45391"); + atf_tc_fail_nonfatal("pow(+0.0, -4.0) != HUGE_VAL"); + } z = pow(-0.0, -4.0); + if (z != HUGE_VAL) { + atf_tc_expect_fail("PR port-amd64/45391"); + atf_tc_fail_nonfatal("pow(-0.0, -4.0) != HUGE_VAL"); + } + + z = pow(+0.0, -5.0); + + if (z != HUGE_VAL) { + atf_tc_expect_fail("PR port-amd64/45391"); + atf_tc_fail_nonfatal("pow(+0.0, -5.0) != HUGE_VAL"); + } + + z = pow(-0.0, -5.0); + if (z != -HUGE_VAL) - atf_tc_fail_nonfatal("pow(-0.0, -4.0) != -HUGE_VAL"); + atf_tc_fail_nonfatal("pow(-0.0, -5.0) != -HUGE_VAL"); #endif } @@ -604,13 +620,29 @@ */ z = powf(+0.0, -4.0); - if (z != -HUGE_VAL) - atf_tc_fail_nonfatal("powf(+0.0, -4.0) != -HUGE_VAL"); + if (z != HUGE_VALF) { + atf_tc_expect_fail("PR port-amd64/45391"); + atf_tc_fail_nonfatal("powf(+0.0, -4.0) != HUGE_VALF"); + } z = powf(-0.0, -4.0); - if (z != -HUGE_VAL) - atf_tc_fail_nonfatal("powf(-0.0, -4.0) != -HUGE_VAL"); + if (z != HUGE_VALF) { + atf_tc_expect_fail("PR port-amd64/45391"); + atf_tc_fail_nonfatal("powf(-0.0, -4.0) != HUGE_VALF"); + } + + z = powf(+0.0, -5.0); + + if (z != HUGE_VALF) { + atf_tc_expect_fail("PR port-amd64/45391"); + atf_tc_fail_nonfatal("powf(+0.0, -5.0) != HUGE_VALF"); + } + + z = powf(-0.0, -5.0); + + if (z != -HUGE_VALF) + atf_tc_fail_nonfatal("powf(-0.0, -5.0) != -HUGE_VALF"); #endif }
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Sun Sep 18 04:49:11 UTC 2011 Modified Files: src/tests/lib/libm: t_log.c Log Message: Add few basic checks. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_log.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_log.c diff -u src/tests/lib/libm/t_log.c:1.4 src/tests/lib/libm/t_log.c:1.5 --- src/tests/lib/libm/t_log.c:1.4 Tue Sep 13 04:24:30 2011 +++ src/tests/lib/libm/t_log.c Sun Sep 18 04:49:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_log.c,v 1.4 2011/09/13 04:24:30 jruoho Exp $ */ +/* $NetBSD: t_log.c,v 1.5 2011/09/18 04:49:11 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_log.c,v 1.4 2011/09/13 04:24:30 jruoho Exp $"); +__RCSID("$NetBSD: t_log.c,v 1.5 2011/09/18 04:49:11 jruoho Exp $"); #include #include @@ -38,6 +38,17 @@ /* * log10(3) */ +ATF_TC(log10_base); +ATF_TC_HEAD(log10_base, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test log10(10) == 1"); +} + +ATF_TC_BODY(log10_base, tc) +{ + ATF_CHECK(log10(10.0) == 1.0); +} + ATF_TC(log10_nan); ATF_TC_HEAD(log10_nan, tc) { @@ -136,6 +147,17 @@ /* * log10f(3) */ +ATF_TC(log10f_base); +ATF_TC_HEAD(log10f_base, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test log10f(10) == 1"); +} + +ATF_TC_BODY(log10f_base, tc) +{ + ATF_CHECK(log10f(10.0) == 1.0); +} + ATF_TC(log10f_nan); ATF_TC_HEAD(log10f_nan, tc) { @@ -436,6 +458,17 @@ /* * log2(3) */ +ATF_TC(log2_base); +ATF_TC_HEAD(log2_base, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test log2(2) == 1"); +} + +ATF_TC_BODY(log2_base, tc) +{ + ATF_CHECK(log2(2.0) == 1.0); +} + ATF_TC(log2_nan); ATF_TC_HEAD(log2_nan, tc) { @@ -534,6 +567,17 @@ /* * log2f(3) */ +ATF_TC(log2f_base); +ATF_TC_HEAD(log2f_base, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test log2f(2) == 1"); +} + +ATF_TC_BODY(log2f_base, tc) +{ + ATF_CHECK(log2f(2.0) == 1.0); +} + ATF_TC(log2f_nan); ATF_TC_HEAD(log2f_nan, tc) { @@ -632,6 +676,20 @@ /* * log(3) */ +ATF_TC(log_base); +ATF_TC_HEAD(log_base, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test log(e) == 1"); +} + +ATF_TC_BODY(log_base, tc) +{ + const double eps = 1.0e-40; + + if (fabs(log(M_E) - 1.0) > eps) + atf_tc_fail_nonfatal("log(e) != 1"); +} + ATF_TC(log_nan); ATF_TC_HEAD(log_nan, tc) { @@ -727,10 +785,23 @@ #endif } - /* * logf(3) */ +ATF_TC(logf_base); +ATF_TC_HEAD(logf_base, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test logf(e) == 1"); +} + +ATF_TC_BODY(logf_base, tc) +{ + const float eps = 1.0e-7; + + if (fabsf(logf(M_E) - 1.0) > eps) + atf_tc_fail_nonfatal("logf(e) != 1"); +} + ATF_TC(logf_nan); ATF_TC_HEAD(logf_nan, tc) { @@ -829,6 +900,7 @@ ATF_TP_ADD_TCS(tp) { + ATF_TP_ADD_TC(tp, log10_base); ATF_TP_ADD_TC(tp, log10_nan); ATF_TP_ADD_TC(tp, log10_inf_neg); ATF_TP_ADD_TC(tp, log10_inf_pos); @@ -836,6 +908,7 @@ ATF_TP_ADD_TC(tp, log10_zero_neg); ATF_TP_ADD_TC(tp, log10_zero_pos); + ATF_TP_ADD_TC(tp, log10f_base); ATF_TP_ADD_TC(tp, log10f_nan); ATF_TP_ADD_TC(tp, log10f_inf_neg); ATF_TP_ADD_TC(tp, log10f_inf_pos); @@ -857,6 +930,7 @@ ATF_TP_ADD_TC(tp, log1pf_zero_neg); ATF_TP_ADD_TC(tp, log1pf_zero_pos); + ATF_TP_ADD_TC(tp, log2_base); ATF_TP_ADD_TC(tp, log2_nan); ATF_TP_ADD_TC(tp, log2_inf_neg); ATF_TP_ADD_TC(tp, log2_inf_pos); @@ -864,6 +938,7 @@ ATF_TP_ADD_TC(tp, log2_zero_neg); ATF_TP_ADD_TC(tp, log2_zero_pos); + ATF_TP_ADD_TC(tp, log2f_base); ATF_TP_ADD_TC(tp, log2f_nan); ATF_TP_ADD_TC(tp, log2f_inf_neg); ATF_TP_ADD_TC(tp, log2f_inf_pos); @@ -871,6 +946,7 @@ ATF_TP_ADD_TC(tp, log2f_zero_neg); ATF_TP_ADD_TC(tp, log2f_zero_pos); + ATF_TP_ADD_TC(tp, log_base); ATF_TP_ADD_TC(tp, log_nan); ATF_TP_ADD_TC(tp, log_inf_neg); ATF_TP_ADD_TC(tp, log_inf_pos); @@ -878,6 +954,7 @@ ATF_TP_ADD_TC(tp, log_zero_neg); ATF_TP_ADD_TC(tp, log_zero_pos); + ATF_TP_ADD_TC(tp, logf_base); ATF_TP_ADD_TC(tp, logf_nan); ATF_TP_ADD_TC(tp, logf_inf_neg); ATF_TP_ADD_TC(tp, logf_inf_pos);
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Sun Sep 18 04:48:38 UTC 2011 Modified Files: src/tests/lib/libm: t_acos.c Log Message: Reduce tolerance to see whether still acosf(cosf(x)) != x on i386/qemu. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_acos.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_acos.c diff -u src/tests/lib/libm/t_acos.c:1.1 src/tests/lib/libm/t_acos.c:1.2 --- src/tests/lib/libm/t_acos.c:1.1 Sat Sep 17 18:08:35 2011 +++ src/tests/lib/libm/t_acos.c Sun Sep 18 04:48:38 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_acos.c,v 1.1 2011/09/17 18:08:35 jruoho Exp $ */ +/* $NetBSD: t_acos.c,v 1.2 2011/09/18 04:48:38 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -241,7 +241,7 @@ { #ifndef __vax__ const float x[] = { 0.0, 1.0, M_PI / 2, M_PI / 3, M_PI / 6 }; - const float eps = 1.0e-15; + const float eps = 1.0e-5; float y; size_t i;
CVS commit: src/tests/lib/libm
Module Name:src Committed By: jruoho Date: Sat Sep 17 12:12:19 UTC 2011 Modified Files: src/tests/lib/libm: t_ceil.c Log Message: Add more cases. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_ceil.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libm/t_ceil.c diff -u src/tests/lib/libm/t_ceil.c:1.6 src/tests/lib/libm/t_ceil.c:1.7 --- src/tests/lib/libm/t_ceil.c:1.6 Mon Sep 12 17:15:54 2011 +++ src/tests/lib/libm/t_ceil.c Sat Sep 17 12:12:19 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ceil.c,v 1.6 2011/09/12 17:15:54 jruoho Exp $ */ +/* $NetBSD: t_ceil.c,v 1.7 2011/09/17 12:12:19 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_ceil.c,v 1.6 2011/09/12 17:15:54 jruoho Exp $"); +__RCSID("$NetBSD: t_ceil.c,v 1.7 2011/09/17 12:12:19 jruoho Exp $"); #include #include @@ -42,6 +42,9 @@ #define SMALL_NUM 1.0e-40 #endif +/* + * ceil(3) + */ ATF_TC(ceil_basic); ATF_TC_HEAD(ceil_basic, tc) { @@ -57,6 +60,92 @@ ATF_CHECK(fabs(ceil(y) - 1) < SMALL_NUM); } +ATF_TC(ceil_nan); +ATF_TC_HEAD(ceil_nan, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test ceil(NaN) == NaN"); +} + +ATF_TC_BODY(ceil_nan, tc) +{ +#ifndef __vax__ + const double x = 0.0L / 0.0L; + + ATF_CHECK(isnan(ceil(x)) != 0); +#endif +} + +ATF_TC(ceil_inf_neg); +ATF_TC_HEAD(ceil_inf_neg, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test ceil(-Inf) == -Inf"); +} + +ATF_TC_BODY(ceil_inf_neg, tc) +{ +#ifndef __vax__ + const double x = -1.0L / 0.0L; + double y = ceil(x); + + if (isinf(y) == 0 || signbit(y) == 0) + atf_tc_fail_nonfatal("ceil(-Inf) != -Inf"); +#endif +} + +ATF_TC(ceil_inf_pos); +ATF_TC_HEAD(ceil_inf_pos, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test ceil(+Inf) == +Inf"); +} + +ATF_TC_BODY(ceil_inf_pos, tc) +{ +#ifndef __vax__ + const double x = 1.0L / 0.0L; + double y = ceil(x); + + if (isinf(y) == 0 || signbit(y) != 0) + atf_tc_fail_nonfatal("ceil(+Inf) != +Inf"); +#endif +} + +ATF_TC(ceil_zero_neg); +ATF_TC_HEAD(ceil_zero_neg, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test ceil(-0.0) == -0.0"); +} + +ATF_TC_BODY(ceil_zero_neg, tc) +{ +#ifndef __vax__ + const double x = -0.0L; + double y = ceil(x); + + if (fabs(y) > 0.0 || signbit(y) == 0) + atf_tc_fail_nonfatal("ceil(-0.0) != -0.0"); +#endif +} + +ATF_TC(ceil_zero_pos); +ATF_TC_HEAD(ceil_zero_pos, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test ceil(+0.0) == +0.0"); +} + +ATF_TC_BODY(ceil_zero_pos, tc) +{ +#ifndef __vax__ + const double x = 0.0L; + double y = ceil(x); + + if (fabs(y) > 0.0 || signbit(y) != 0) + atf_tc_fail_nonfatal("ceil(+0.0) != +0.0"); +#endif +} + +/* + * ceilf(3) + */ ATF_TC(ceilf_basic); ATF_TC_HEAD(ceilf_basic, tc) { @@ -72,6 +161,92 @@ ATF_CHECK(fabsf(ceilf(y) - 1) < SMALL_NUM); } +ATF_TC(ceilf_nan); +ATF_TC_HEAD(ceilf_nan, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test ceilf(NaN) == NaN"); +} + +ATF_TC_BODY(ceilf_nan, tc) +{ +#ifndef __vax__ + const float x = 0.0L / 0.0L; + + ATF_CHECK(isnan(ceilf(x)) != 0); +#endif +} + +ATF_TC(ceilf_inf_neg); +ATF_TC_HEAD(ceilf_inf_neg, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test ceilf(-Inf) == -Inf"); +} + +ATF_TC_BODY(ceilf_inf_neg, tc) +{ +#ifndef __vax__ + const float x = -1.0L / 0.0L; + float y = ceilf(x); + + if (isinf(y) == 0 || signbit(y) == 0) + atf_tc_fail_nonfatal("ceilf(-Inf) != -Inf"); +#endif +} + +ATF_TC(ceilf_inf_pos); +ATF_TC_HEAD(ceilf_inf_pos, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test ceilf(+Inf) == +Inf"); +} + +ATF_TC_BODY(ceilf_inf_pos, tc) +{ +#ifndef __vax__ + const float x = 1.0L / 0.0L; + float y = ceilf(x); + + if (isinf(y) == 0 || signbit(y) != 0) + atf_tc_fail_nonfatal("ceilf(+Inf) != +Inf"); +#endif +} + +ATF_TC(ceilf_zero_neg); +ATF_TC_HEAD(ceilf_zero_neg, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test ceilf(-0.0) == -0.0"); +} + +ATF_TC_BODY(ceilf_zero_neg, tc) +{ +#ifndef __vax__ + const float x = -0.0L; + float y = ceilf(x); + + if (fabsf(y) > 0.0 || signbit(y) == 0) + atf_tc_fail_nonfatal("ceilf(-0.0) != -0.0"); +#endif +} + +ATF_TC(ceilf_zero_pos); +ATF_TC_HEAD(ceilf_zero_pos, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test ceilf(+0.0) == +0.0"); +} + +ATF_TC_BODY(ceilf_zero_pos, tc) +{ +#ifndef __vax__ + const float x = 0.0L; + float y = ceilf(x); + + if (fabsf(y) > 0.0 || signbit(y) != 0) + atf_tc_fail_nonfatal("ceilf(+0.0) != +0.0"); +#endif +} + +/* + * floor(3) + */ ATF_TC(floor_basic); ATF_TC_HEAD(floor_basic, tc) { @@ -87,6 +262,92 @@ ATF_CHECK(floor(y) < SMALL_NUM); } +ATF_TC(floor_nan); +ATF_TC_HEAD(floor_nan, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test floor(NaN) == NaN"); +} + +ATF_TC_BODY(floor_nan, tc) +{ +#ifndef __vax__ + const double x = 0.0L / 0.0L; + + ATF_CHECK(isnan(floor(x)) != 0); +#endif +} + +ATF_TC(floor_inf_neg); +ATF_TC_HEAD(floor_inf_neg, tc) +{ + atf_tc_set_md_var(tc, "descr"