Add additional testcases missed in r311966
This commit is contained in:
parent
20d24fbb93
commit
b6bd3eb5f3
81
lib/libm/t_casinh.c
Normal file
81
lib/libm/t_casinh.c
Normal file
@ -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();
|
||||
}
|
124
lib/libm/t_fe_round.c
Normal file
124
lib/libm/t_fe_round.c
Normal file
@ -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
|
127
lib/libm/t_ilogb.c
Normal file
127
lib/libm/t_ilogb.c
Normal file
@ -0,0 +1,127 @@
|
||||
/* $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.
|
||||
*/
|
||||
|
||||
#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();
|
||||
}
|
30
lib/libpthread/t_timedmutex.c
Normal file
30
lib/libpthread/t_timedmutex.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* $NetBSD: t_timedmutex.c,v 1.2 2016/10/31 16:21:23 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 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.
|
||||
*/
|
||||
|
||||
#define TIMEDMUTEX
|
||||
#include "t_mutex.c"
|
Loading…
x
Reference in New Issue
Block a user