diff options
Diffstat (limited to 'contrib/netbsd-tests/lib/libm')
-rw-r--r-- | contrib/netbsd-tests/lib/libm/t_casinh.c | 81 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libm/t_exp.c | 41 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libm/t_fe_round.c | 124 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libm/t_fenv.c | 220 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libm/t_fmod.c | 9 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libm/t_hypot.c | 81 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libm/t_ilogb.c | 130 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libm/t_ldexp.c | 12 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libm/t_log.c | 16 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libm/t_pow.c | 7 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libm/t_precision.c | 8 |
11 files changed, 676 insertions, 53 deletions
diff --git a/contrib/netbsd-tests/lib/libm/t_casinh.c b/contrib/netbsd-tests/lib/libm/t_casinh.c new file mode 100644 index 0000000..f9f93c3 --- /dev/null +++ b/contrib/netbsd-tests/lib/libm/t_casinh.c @@ -0,0 +1,81 @@ +/* $NetBSD: t_casinh.c,v 1.2 2016/09/20 17:19:28 christos Exp $ */ + +/* + * Written by Maya Rashish + * Public domain. + * + * Testing special values of casinh + * Values from ISO/IEC 9899:201x G.6.2.2 + */ + +#include <atf-c.h> +#include <complex.h> +#include <math.h> + +#define RE(z) (((double *)(&z))[0]) +#define IM(z) (((double *)(&z))[1]) + +static const struct { + double input_re; + double input_im; + double result_re; + double result_im; +} values[] = { + { +0, +0, +0, +0}, + { +5.032E3, +INFINITY, +INFINITY, +M_PI/2}, + { +INFINITY, +5.023E3, +INFINITY, +0}, + { +INFINITY, +INFINITY, +INFINITY, +M_PI/4}, +#ifdef __HAVE_NANF + { +INFINITY, +NAN, +INFINITY, +NAN}, + { +5.032E3, +NAN, +NAN, +NAN}, /* + FE_INVALID optionally raised */ + { +NAN, +0, +NAN, +0}, + { +NAN, -5.023E3, +NAN, +NAN}, /* + FE_INVALID optionally raised */ + { +NAN, +INFINITY, +INFINITY, +NAN}, /* sign of real part of result unspecified */ + { +NAN, +NAN, +NAN, +NAN}, +#endif +}; + +#ifdef __HAVE_NANF +#define both_nan(a,b) (isnan(a) && isnan(b)) +#else +#define both_nan(a,b) 0 +#endif + +#define crude_equality(a,b) ((a == b) || both_nan(a,b)) + +#define ATF_COMPLEX_EQUAL(a,b) do { \ + 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*/) + + +ATF_TC(casinh); +ATF_TC_HEAD(casinh, tc) +{ + atf_tc_set_md_var(tc, "descr","Check casinh family - special values"); +} + +ATF_TC_BODY(casinh, tc) +{ + complex double input; + complex double result; + unsigned int i; + for (i = 0; i < __arraycount(values); i++) { + RE(input) = values[i].input_re; + IM(input) = values[i].input_im; + RE(result) = values[i].result_re; + IM(result) = values[i].result_im; + ATF_COMPLEX_EQUAL(input, result); + } +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, casinh); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/lib/libm/t_exp.c b/contrib/netbsd-tests/lib/libm/t_exp.c index 7a8e9f8..0eb6412 100644 --- a/contrib/netbsd-tests/lib/libm/t_exp.c +++ b/contrib/netbsd-tests/lib/libm/t_exp.c @@ -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. @@ -145,47 +145,40 @@ ATF_LIBM_TEST(exp2_values, "Test exp2(x) is correct for some 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.fffffffffffffp9, 0x1.ffffffffffd3ap1023, + { 0x1.fffffffffffffp9, 0x1.ffffffffffd3ap1023, 0.00, 0x1p969, 0.0 }, /* The largest float constant */ - { 0x1.fffffep6, 0x1.ffff4ep+127, 6e30, 0.0 }, + { 0x1.fffffep6, 0x1.ffff4ep+127, 0x1.ffff4ep+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; -#ifdef __FreeBSD__ - atf_tc_expect_fail("Some of the cases produce failures on FreeBSD " - "due to the error epsilon being so small"); -#endif - 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); } } diff --git a/contrib/netbsd-tests/lib/libm/t_fe_round.c b/contrib/netbsd-tests/lib/libm/t_fe_round.c new file mode 100644 index 0000000..fe805b4 --- /dev/null +++ b/contrib/netbsd-tests/lib/libm/t_fe_round.c @@ -0,0 +1,124 @@ +/* + * Written by Maya Rashish <maya@NetBSD.org> + * Public domain. + * + * Testing IEEE-754 rounding modes (and lrint) + */ + +#include <atf-c.h> +#include <fenv.h> +#ifdef __HAVE_FENV +#include <math.h> +#include <stdio.h> +#include <stdlib.h> + +/*#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( + (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); + + /* 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 diff --git a/contrib/netbsd-tests/lib/libm/t_fenv.c b/contrib/netbsd-tests/lib/libm/t_fenv.c new file mode 100644 index 0000000..5445036 --- /dev/null +++ b/contrib/netbsd-tests/lib/libm/t_fenv.c @@ -0,0 +1,220 @@ +/* $NetBSD: t_fenv.c,v 1.3 2015/12/22 14:20:59 christos 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 <sys/cdefs.h> +__RCSID("$NetBSD: t_fenv.c,v 1.3 2015/12/22 14:20:59 christos Exp $"); + +#include <atf-c.h> + +#include <fenv.h> +#ifdef __HAVE_FENV + +#include <ieeefp.h> +#include <stdlib.h> + + +#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_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_EXC_PREREQ +#define FPU_EXC_PREREQ() /* nothing */ +#endif +#ifndef FPU_RND_PREREQ +#define FPU_RND_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) +{ + FPU_RND_PREREQ(); + + 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) +{ + FPU_RND_PREREQ(); + + 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_EXC_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(fegetexcept() == FE_OVERFLOW); + + fpsetmask(FP_X_UFL); + ATF_CHECK(fegetexcept() == FE_UNDERFLOW); + + fpsetmask(FP_X_IMP); + ATF_CHECK(fegetexcept() == FE_INEXACT); +} + +ATF_TC(feenableexcept); + +ATF_TC_HEAD(feenableexcept, tc) +{ + atf_tc_set_md_var(tc, "descr", + "verify the feenableexcept() function agrees with the legacy " + "fpgetmask()"); +} + +ATF_TC_BODY(feenableexcept, tc) +{ + FPU_EXC_PREREQ(); + + fedisableexcept(FE_ALL_EXCEPT); + ATF_CHECK(fpgetmask() == 0); + + feenableexcept(FE_UNDERFLOW); + ATF_CHECK(fpgetmask() == FP_X_UFL); + + fedisableexcept(FE_ALL_EXCEPT); + feenableexcept(FE_OVERFLOW); + ATF_CHECK(fpgetmask() == FP_X_OFL); + + fedisableexcept(FE_ALL_EXCEPT); + feenableexcept(FE_DIVBYZERO); + ATF_CHECK(fpgetmask() == FP_X_DZ); + + fedisableexcept(FE_ALL_EXCEPT); + feenableexcept(FE_INEXACT); + ATF_CHECK(fpgetmask() == FP_X_IMP); + + fedisableexcept(FE_ALL_EXCEPT); + feenableexcept(FE_INVALID); + ATF_CHECK(fpgetmask() == FP_X_INV); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, fegetround); + ATF_TP_ADD_TC(tp, fesetround); + ATF_TP_ADD_TC(tp, fegetexcept); + ATF_TP_ADD_TC(tp, feenableexcept); + + return atf_no_error(); +} + +#else /* no fenv.h support */ + +ATF_TC(t_nofenv); + +ATF_TC_HEAD(t_nofenv, tc) +{ + atf_tc_set_md_var(tc, "descr", + "dummy test case - no fenv.h support"); +} + + +ATF_TC_BODY(t_nofenv, tc) +{ + atf_tc_skip("no fenv.h support on this architecture"); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, t_nofenv); + return atf_no_error(); +} + +#endif diff --git a/contrib/netbsd-tests/lib/libm/t_fmod.c b/contrib/netbsd-tests/lib/libm/t_fmod.c index 837e9b2..2a221f5 100644 --- a/contrib/netbsd-tests/lib/libm/t_fmod.c +++ b/contrib/netbsd-tests/lib/libm/t_fmod.c @@ -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 <float.h> #include <math.h> +#include "isqemu.h" + ATF_TC(fmod); ATF_TC_HEAD(fmod, tc) { @@ -41,6 +43,11 @@ ATF_TC_HEAD(fmod, tc) ATF_TC_BODY(fmod, tc) { +#ifdef __NetBSD__ + if (isQEMU()) + atf_tc_expect_fail("PR misc/44767"); +#endif + ATF_CHECK(fmodf(2.0, 1.0) == 0); ATF_CHECK(fmod(2.0, 1.0) == 0); #if !defined(__FreeBSD__) || LDBL_PREC != 53 diff --git a/contrib/netbsd-tests/lib/libm/t_hypot.c b/contrib/netbsd-tests/lib/libm/t_hypot.c new file mode 100644 index 0000000..deb7e86 --- /dev/null +++ b/contrib/netbsd-tests/lib/libm/t_hypot.c @@ -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 <atf-c.h> +#include <math.h> + +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(); +} diff --git a/contrib/netbsd-tests/lib/libm/t_ilogb.c b/contrib/netbsd-tests/lib/libm/t_ilogb.c new file mode 100644 index 0000000..b3c2126 --- /dev/null +++ b/contrib/netbsd-tests/lib/libm/t_ilogb.c @@ -0,0 +1,130 @@ +/* $NetBSD: t_ilogb.c,v 1.6 2016/08/26 08:01:55 christos Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Maya Rashish. + * + * 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. + */ + +#ifdef __FreeBSD__ +#include <limits.h> +#endif +#include <atf-c.h> +#include <fenv.h> +#include <math.h> + +#ifndef __HAVE_FENV + +# define ATF_CHECK_RAISED_INVALID +# define ATF_CHECK_RAISED_NOTHING + +#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); \ + (void)feclearexcept(FE_ALL_EXCEPT); \ +} while (/*CONSTCOND*/0) + +# define ATF_CHECK_RAISED_NOTHING do { \ + 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 + +ATF_TC(ilogb); +ATF_TC_HEAD(ilogb, tc) +{ + atf_tc_set_md_var(tc, "descr","Check ilogb family"); +} + +ATF_TC_BODY(ilogb, tc) +{ + + ATF_CHECK(ilogbf(0) == FP_ILOGB0); + 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; + 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) +{ + + ATF_TP_ADD_TC(tp, ilogb); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/lib/libm/t_ldexp.c b/contrib/netbsd-tests/lib/libm/t_ldexp.c index eaf8a4b..251f2ae 100644 --- a/contrib/netbsd-tests/lib/libm/t_ldexp.c +++ b/contrib/netbsd-tests/lib/libm/t_ldexp.c @@ -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.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 <sys/cdefs.h> -__RCSID("$NetBSD: t_ldexp.c,v 1.14 2014/11/04 00:20:19 justin Exp $"); +__RCSID("$NetBSD: t_ldexp.c,v 1.16 2016/08/25 00:32:31 maya Exp $"); #include <sys/param.h> @@ -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 } }; @@ -170,10 +172,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); diff --git a/contrib/netbsd-tests/lib/libm/t_log.c b/contrib/netbsd-tests/lib/libm/t_log.c index 0164233..756efcf 100644 --- a/contrib/netbsd-tests/lib/libm/t_log.c +++ b/contrib/netbsd-tests/lib/libm/t_log.c @@ -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 <sys/cdefs.h> -__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 <atf-c.h> @@ -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); } diff --git a/contrib/netbsd-tests/lib/libm/t_pow.c b/contrib/netbsd-tests/lib/libm/t_pow.c index a8ae6f0..fbdb984 100644 --- a/contrib/netbsd-tests/lib/libm/t_pow.c +++ b/contrib/netbsd-tests/lib/libm/t_pow.c @@ -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 <sys/cdefs.h> -__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 <atf-c.h> #include <math.h> @@ -284,21 +284,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"); } diff --git a/contrib/netbsd-tests/lib/libm/t_precision.c b/contrib/netbsd-tests/lib/libm/t_precision.c index c01deba..df2d8a3 100644 --- a/contrib/netbsd-tests/lib/libm/t_precision.c +++ b/contrib/netbsd-tests/lib/libm/t_precision.c @@ -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 <sys/cdefs.h> -__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 <atf-c.h> @@ -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,7 +60,7 @@ ATF_TC_BODY(t_precision, tc) x += DBL_EPSILON; ATF_CHECK(x == 2.0); -#if !defined(__FreeBSD__) || !defined(__i386__) +#if __HAVE_LONG_DOUBLE y += LDBL_EPSILON; ATF_CHECK(y != 1.0L); y -= 1; |