Integrate errno testing better in libm-test.inc.

This commit is contained in:
Joseph Myers 2013-04-29 20:36:48 +00:00
parent c3ed8088e4
commit f2da779309
3 changed files with 156 additions and 198 deletions

View File

@ -1,3 +1,33 @@
2013-04-29 Joseph Myers <joseph@codesourcery.com>
* math/libm-test.inc (ERRNO_UNCHANGED): New macro.
(ERRNO_EDOM): Likewise.
(ERRNO_ERANGE): Likewise.
(noErrnoTests): New variable.
(init_max_error): Set errno to 0.
(test_single_errno): New function.
(test_errno): Likewise.
(check_float_internal): Call test_errno. Set errno to 0.
(check_complex): Refer to errno tests in comment.
(check_int): Call test_errno. Set errno to 0.
(check_long): Likewise.
(check_bool): Likewise.
(check_longlong): Likewise.
(cos_test): Use ERRNO_* flags for errno tests instead of
check_int.
(expm1_test): Likewise.
(fmod_test): Likewise.
(ilogb_test): Likewise.
(lgamma_test): Likewise.
(pow_test): Likewise.
(remainder_test): Likewise.
(sin_test): Likewise.
(tan_test): Likewise.
(yn_test): Likewise.
(initialize): Set errno to 0.
(main): Print number of errno tests.
* math/gen-libm-test.pl (parse_args): Allow ERRNO flags on tests.
2013-04-29 Andreas Jaeger <aj@suse.de> 2013-04-29 Andreas Jaeger <aj@suse.de>
[BZ #15084] [BZ #15084]

View File

@ -295,7 +295,7 @@ sub parse_args {
# consistency check # consistency check
if ($current_arg == $#args) { if ($current_arg == $#args) {
die ("wrong number of arguments") die ("wrong number of arguments")
unless ($args[$current_arg] =~ /EXCEPTION|IGNORE_ZERO_INF_SIGN/); unless ($args[$current_arg] =~ /EXCEPTION|ERRNO|IGNORE_ZERO_INF_SIGN/);
} elsif ($current_arg < $#args) { } elsif ($current_arg < $#args) {
die ("wrong number of arguments"); die ("wrong number of arguments");
} elsif ($current_arg > ($#args+1)) { } elsif ($current_arg > ($#args+1)) {

View File

@ -163,6 +163,10 @@
#define EXCEPTIONS_OK INVALID_EXCEPTION_OK+DIVIDE_BY_ZERO_EXCEPTION_OK #define EXCEPTIONS_OK INVALID_EXCEPTION_OK+DIVIDE_BY_ZERO_EXCEPTION_OK
/* Some special test flags, passed together with exceptions. */ /* Some special test flags, passed together with exceptions. */
#define IGNORE_ZERO_INF_SIGN 0x100 #define IGNORE_ZERO_INF_SIGN 0x100
/* Indicate errno settings required or disallowed. */
#define ERRNO_UNCHANGED 0x200
#define ERRNO_EDOM 0x400
#define ERRNO_ERANGE 0x800
/* Values underflowing only for float. */ /* Values underflowing only for float. */
#ifdef TEST_FLOAT #ifdef TEST_FLOAT
@ -218,6 +222,7 @@ static char *output_dir; /* Directory where generated files will be written. */
static int noErrors; /* number of errors */ static int noErrors; /* number of errors */
static int noTests; /* number of tests (without testing exceptions) */ static int noTests; /* number of tests (without testing exceptions) */
static int noExcTests; /* number of tests for exception flags */ static int noExcTests; /* number of tests for exception flags */
static int noErrnoTests;/* number of tests for errno values */
static int noXFails; /* number of expected failures. */ static int noXFails; /* number of expected failures. */
static int noXPasses; /* number of unexpected passes. */ static int noXPasses; /* number of unexpected passes. */
@ -256,6 +261,7 @@ init_max_error (void)
real_max_error = 0; real_max_error = 0;
imag_max_error = 0; imag_max_error = 0;
feclearexcept (FE_ALL_EXCEPT); feclearexcept (FE_ALL_EXCEPT);
errno = 0;
} }
static void static void
@ -536,6 +542,40 @@ test_exceptions (const char *test_name, int exception)
feclearexcept (FE_ALL_EXCEPT); feclearexcept (FE_ALL_EXCEPT);
} }
/* Test whether errno for TEST_NAME, set to ERRNO_VALUE, has value
EXPECTED_VALUE (description EXPECTED_NAME). */
static void
test_single_errno (const char *test_name, int errno_value,
int expected_value, const char *expected_name)
{
if (errno_value == expected_value)
{
if (print_screen (1, 0))
printf ("Pass: %s: errno set to %d (%s)\n", test_name, errno_value,
expected_name);
}
else
{
++noErrors;
if (print_screen (0, 0))
printf ("Failure: %s: errno set to %d, expected %d (%s)\n",
test_name, errno_value, expected_value, expected_name);
}
}
/* Test whether errno (value ERRNO_VALUE) has been for TEST_NAME set
as required by EXCEPTIONS. */
static void
test_errno (const char *test_name, int errno_value, int exceptions)
{
++noErrnoTests;
if (exceptions & ERRNO_UNCHANGED)
test_single_errno (test_name, errno_value, 0, "unchanged");
if (exceptions & ERRNO_EDOM)
test_single_errno (test_name, errno_value, EDOM, "EDOM");
if (exceptions & ERRNO_ERANGE)
test_single_errno (test_name, errno_value, ERANGE, "ERANGE");
}
static void static void
check_float_internal (const char *test_name, FLOAT computed, FLOAT expected, check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
@ -546,8 +586,10 @@ check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
int print_diff = 0; int print_diff = 0;
FLOAT diff = 0; FLOAT diff = 0;
FLOAT ulp = 0; FLOAT ulp = 0;
int errno_value = errno;
test_exceptions (test_name, exceptions); test_exceptions (test_name, exceptions);
test_errno (test_name, errno_value, exceptions);
if (issignaling (computed) && issignaling (expected)) if (issignaling (computed) && issignaling (expected))
ok = 1; ok = 1;
else if (issignaling (computed) || issignaling (expected)) else if (issignaling (computed) || issignaling (expected))
@ -628,6 +670,7 @@ check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
update_stats (ok, xfail); update_stats (ok, xfail);
fpstack_test (test_name); fpstack_test (test_name);
errno = 0;
} }
@ -670,7 +713,7 @@ check_complex (const char *test_name, __complex__ FLOAT computed,
part_max_ulp = __imag__ max_ulp; part_max_ulp = __imag__ max_ulp;
part_xfail = __imag__ xfail; part_xfail = __imag__ xfail;
/* Don't check again for exceptions, just pass through the /* Don't check again for exceptions or errno, just pass through the
zero/inf sign test. */ zero/inf sign test. */
check_float_internal (str, part_comp, part_exp, part_max_ulp, part_xfail, check_float_internal (str, part_comp, part_exp, part_max_ulp, part_xfail,
exception & IGNORE_ZERO_INF_SIGN, exception & IGNORE_ZERO_INF_SIGN,
@ -686,8 +729,10 @@ check_int (const char *test_name, int computed, int expected, int max_ulp,
{ {
int diff = computed - expected; int diff = computed - expected;
int ok = 0; int ok = 0;
int errno_value = errno;
test_exceptions (test_name, exceptions); test_exceptions (test_name, exceptions);
test_errno (test_name, errno_value, exceptions);
noTests++; noTests++;
if (abs (diff) <= max_ulp) if (abs (diff) <= max_ulp)
ok = 1; ok = 1;
@ -707,6 +752,7 @@ check_int (const char *test_name, int computed, int expected, int max_ulp,
update_stats (ok, xfail); update_stats (ok, xfail);
fpstack_test (test_name); fpstack_test (test_name);
errno = 0;
} }
@ -717,8 +763,10 @@ check_long (const char *test_name, long int computed, long int expected,
{ {
long int diff = computed - expected; long int diff = computed - expected;
int ok = 0; int ok = 0;
int errno_value = errno;
test_exceptions (test_name, exceptions); test_exceptions (test_name, exceptions);
test_errno (test_name, errno_value, exceptions);
noTests++; noTests++;
if (labs (diff) <= max_ulp) if (labs (diff) <= max_ulp)
ok = 1; ok = 1;
@ -738,6 +786,7 @@ check_long (const char *test_name, long int computed, long int expected,
update_stats (ok, xfail); update_stats (ok, xfail);
fpstack_test (test_name); fpstack_test (test_name);
errno = 0;
} }
@ -747,8 +796,10 @@ check_bool (const char *test_name, int computed, int expected,
long int max_ulp, int xfail, int exceptions) long int max_ulp, int xfail, int exceptions)
{ {
int ok = 0; int ok = 0;
int errno_value = errno;
test_exceptions (test_name, exceptions); test_exceptions (test_name, exceptions);
test_errno (test_name, errno_value, exceptions);
noTests++; noTests++;
if ((computed == 0) == (expected == 0)) if ((computed == 0) == (expected == 0))
ok = 1; ok = 1;
@ -765,6 +816,7 @@ check_bool (const char *test_name, int computed, int expected,
update_stats (ok, xfail); update_stats (ok, xfail);
fpstack_test (test_name); fpstack_test (test_name);
errno = 0;
} }
@ -777,8 +829,10 @@ check_longlong (const char *test_name, long long int computed,
{ {
long long int diff = computed - expected; long long int diff = computed - expected;
int ok = 0; int ok = 0;
int errno_value = errno;
test_exceptions (test_name, exceptions); test_exceptions (test_name, exceptions);
test_errno (test_name, errno_value, exceptions);
noTests++; noTests++;
if (llabs (diff) <= max_ulp) if (llabs (diff) <= max_ulp)
ok = 1; ok = 1;
@ -798,6 +852,7 @@ check_longlong (const char *test_name, long long int computed,
update_stats (ok, xfail); update_stats (ok, xfail);
fpstack_test (test_name); fpstack_test (test_name);
errno = 0;
} }
@ -5584,15 +5639,9 @@ cos_test (void)
TEST_f_f (cos, 0, 1); TEST_f_f (cos, 0, 1);
TEST_f_f (cos, minus_zero, 1); TEST_f_f (cos, minus_zero, 1);
errno = 0; TEST_f_f (cos, plus_infty, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_f_f (cos, plus_infty, qnan_value, INVALID_EXCEPTION); TEST_f_f (cos, minus_infty, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
check_int ("errno for cos(+inf) == EDOM", errno, EDOM, 0, 0, 0); TEST_f_f (cos, qnan_value, qnan_value, ERRNO_UNCHANGED);
errno = 0;
TEST_f_f (cos, minus_infty, qnan_value, INVALID_EXCEPTION);
check_int ("errno for cos(-inf) == EDOM", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_f_f (cos, qnan_value, qnan_value);
check_int ("errno for cos(qNaN) unchanged", errno, 0, 0, 0, 0);
TEST_f_f (cos, M_PI_6l * 2.0, 0.5); TEST_f_f (cos, M_PI_6l * 2.0, 0.5);
TEST_f_f (cos, M_PI_6l * 4.0, -0.5); TEST_f_f (cos, M_PI_6l * 4.0, -0.5);
@ -7118,9 +7167,7 @@ expm1_test (void)
TEST_f_f (expm1, -10000.0, -1.0); TEST_f_f (expm1, -10000.0, -1.0);
TEST_f_f (expm1, -100000.0, -1.0); TEST_f_f (expm1, -100000.0, -1.0);
errno = 0; TEST_f_f (expm1, 100000.0, plus_infty, OVERFLOW_EXCEPTION|ERRNO_ERANGE);
TEST_f_f (expm1, 100000.0, plus_infty, OVERFLOW_EXCEPTION);
check_int ("errno for expm1(large) == ERANGE", errno, ERANGE, 0, 0, 0);
TEST_f_f (expm1, max_value, plus_infty, OVERFLOW_EXCEPTION); TEST_f_f (expm1, max_value, plus_infty, OVERFLOW_EXCEPTION);
TEST_f_f (expm1, -max_value, -1); TEST_f_f (expm1, -max_value, -1);
@ -8346,17 +8393,11 @@ fmod_test (void)
TEST_ff_f (fmod, minus_zero, 3, minus_zero); TEST_ff_f (fmod, minus_zero, 3, minus_zero);
/* fmod (+inf, y) == qNaN plus invalid exception. */ /* fmod (+inf, y) == qNaN plus invalid exception. */
errno = 0; TEST_ff_f (fmod, plus_infty, 3, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_ff_f (fmod, plus_infty, 3, qnan_value, INVALID_EXCEPTION);
check_int ("errno for fmod(Inf,3) unchanged", errno, EDOM, 0, 0, 0);
/* fmod (-inf, y) == qNaN plus invalid exception. */ /* fmod (-inf, y) == qNaN plus invalid exception. */
errno = 0; TEST_ff_f (fmod, minus_infty, 3, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_ff_f (fmod, minus_infty, 3, qnan_value, INVALID_EXCEPTION);
check_int ("errno for fmod(-Inf,3) unchanged", errno, EDOM, 0, 0, 0);
/* fmod (x, +0) == qNaN plus invalid exception. */ /* fmod (x, +0) == qNaN plus invalid exception. */
errno = 0; TEST_ff_f (fmod, 3, 0, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_ff_f (fmod, 3, 0, qnan_value, INVALID_EXCEPTION);
check_int ("errno for fmod(3,0) unchanged", errno, EDOM, 0, 0, 0);
/* fmod (x, -0) == qNaN plus invalid exception. */ /* fmod (x, -0) == qNaN plus invalid exception. */
TEST_ff_f (fmod, 3, minus_zero, qnan_value, INVALID_EXCEPTION); TEST_ff_f (fmod, 3, minus_zero, qnan_value, INVALID_EXCEPTION);
@ -8522,21 +8563,13 @@ ilogb_test (void)
TEST_f_i (ilogb, -2000, 10); TEST_f_i (ilogb, -2000, 10);
/* ilogb (0.0) == FP_ILOGB0 plus invalid exception */ /* ilogb (0.0) == FP_ILOGB0 plus invalid exception */
errno = 0; TEST_f_i (ilogb, 0.0, FP_ILOGB0, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_f_i (ilogb, 0.0, FP_ILOGB0, INVALID_EXCEPTION);
check_int ("errno for ilogb(0.0) unchanged", errno, EDOM, 0, 0, 0);
/* ilogb (qNaN) == FP_ILOGBNAN plus invalid exception */ /* ilogb (qNaN) == FP_ILOGBNAN plus invalid exception */
errno = 0; TEST_f_i (ilogb, qnan_value, FP_ILOGBNAN, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_f_i (ilogb, qnan_value, FP_ILOGBNAN, INVALID_EXCEPTION);
check_int ("errno for ilogb(qNaN) unchanged", errno, EDOM, 0, 0, 0);
/* ilogb (inf) == INT_MAX plus invalid exception */ /* ilogb (inf) == INT_MAX plus invalid exception */
errno = 0; TEST_f_i (ilogb, plus_infty, INT_MAX, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_f_i (ilogb, plus_infty, INT_MAX, INVALID_EXCEPTION);
check_int ("errno for ilogb(Inf) unchanged", errno, EDOM, 0, 0, 0);
/* ilogb (-inf) == INT_MAX plus invalid exception */ /* ilogb (-inf) == INT_MAX plus invalid exception */
errno = 0; TEST_f_i (ilogb, minus_infty, INT_MAX, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_f_i (ilogb, minus_infty, INT_MAX, INVALID_EXCEPTION);
check_int ("errno for ilogb(-Inf) unchanged", errno, EDOM, 0, 0, 0);
END (ilogb); END (ilogb);
} }
@ -8991,9 +9024,7 @@ lgamma_test (void)
TEST_f_f (lgamma, qnan_value, qnan_value); TEST_f_f (lgamma, qnan_value, qnan_value);
/* lgamma (x) == +inf plus divide by zero exception for integer x <= 0. */ /* lgamma (x) == +inf plus divide by zero exception for integer x <= 0. */
errno = 0; TEST_f_f (lgamma, -3, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_f_f (lgamma, -3, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for lgamma(-integer) == ERANGE", errno, ERANGE, 0, 0, 0);
TEST_f_f (lgamma, minus_infty, plus_infty); TEST_f_f (lgamma, minus_infty, plus_infty);
TEST_f_f (lgamma, -max_value, plus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_f_f (lgamma, -max_value, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
TEST_f_f (lgamma, max_value, plus_infty, OVERFLOW_EXCEPTION); TEST_f_f (lgamma, max_value, plus_infty, OVERFLOW_EXCEPTION);
@ -10648,119 +10679,58 @@ pow_test (void)
TEST_ff_f (pow, -1.0L, min_subnorm_value, qnan_value, INVALID_EXCEPTION); TEST_ff_f (pow, -1.0L, min_subnorm_value, qnan_value, INVALID_EXCEPTION);
TEST_ff_f (pow, -1.0L, -min_subnorm_value, qnan_value, INVALID_EXCEPTION); TEST_ff_f (pow, -1.0L, -min_subnorm_value, qnan_value, INVALID_EXCEPTION);
errno = 0; TEST_ff_f (pow, 0, -1, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, 0, -1, plus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, 0, -11, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
check_int ("errno for pow(0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0); TEST_ff_f (pow, 0, -0xffffff, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
errno = 0;
TEST_ff_f (pow, 0, -11, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, 0, -0xffffff, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
#ifndef TEST_FLOAT #ifndef TEST_FLOAT
errno = 0; TEST_ff_f (pow, 0, -0x1.fffffffffffffp+52L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, 0, -0x1.fffffffffffffp+52L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
#endif #endif
#ifdef TEST_LDOUBLE #ifdef TEST_LDOUBLE
# if LDBL_MANT_DIG >= 64 # if LDBL_MANT_DIG >= 64
errno = 0; TEST_ff_f (pow, 0, -0x1.fffffffffffffffep+63L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, 0, -0x1.fffffffffffffffep+63L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
# endif # endif
# if LDBL_MANT_DIG >= 106 # if LDBL_MANT_DIG >= 106
errno = 0; TEST_ff_f (pow, 0, -0x1.ffffffffffffffffffffffffff8p+105L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, 0, -0x1.ffffffffffffffffffffffffff8p+105L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
# endif # endif
# if LDBL_MANT_DIG >= 113 # if LDBL_MANT_DIG >= 113
errno = 0; TEST_ff_f (pow, 0, -0x1.ffffffffffffffffffffffffffffp+112L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, 0, -0x1.ffffffffffffffffffffffffffffp+112L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
# endif # endif
#endif #endif
TEST_ff_f (pow, minus_zero, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, minus_zero, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
check_int ("errno for pow(-0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0); TEST_ff_f (pow, minus_zero, -11L, minus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
errno = 0; TEST_ff_f (pow, minus_zero, -0xffffff, minus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, minus_zero, -11L, minus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, minus_zero, -0x1fffffe, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
check_int ("errno for pow(-0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, minus_zero, -0xffffff, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(-0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, minus_zero, -0x1fffffe, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(-0,-even) == ERANGE", errno, ERANGE, 0, 0, 0);
#ifndef TEST_FLOAT #ifndef TEST_FLOAT
errno = 0; TEST_ff_f (pow, minus_zero, -0x1.fffffffffffffp+52L, minus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, minus_zero, -0x1.fffffffffffffp+52L, minus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, minus_zero, -0x1.fffffffffffffp+53L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
check_int ("errno for pow(-0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, minus_zero, -0x1.fffffffffffffp+53L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(-0,-even) == ERANGE", errno, ERANGE, 0, 0, 0);
#endif #endif
#ifdef TEST_LDOUBLE #ifdef TEST_LDOUBLE
# if LDBL_MANT_DIG >= 64 # if LDBL_MANT_DIG >= 64
errno = 0; TEST_ff_f (pow, minus_zero, -0x1.fffffffffffffffep+63L, minus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, minus_zero, -0x1.fffffffffffffffep+63L, minus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, minus_zero, -0x1.fffffffffffffffep+64L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
check_int ("errno for pow(-0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, minus_zero, -0x1.fffffffffffffffep+64L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(-0,-even) == ERANGE", errno, ERANGE, 0, 0, 0);
# endif # endif
# if LDBL_MANT_DIG >= 106 # if LDBL_MANT_DIG >= 106
errno = 0; TEST_ff_f (pow, minus_zero, -0x1.ffffffffffffffffffffffffff8p+105L, minus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, minus_zero, -0x1.ffffffffffffffffffffffffff8p+105L, minus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, minus_zero, -0x1.ffffffffffffffffffffffffff8p+106L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
check_int ("errno for pow(-0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, minus_zero, -0x1.ffffffffffffffffffffffffff8p+106L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(-0,-even) == ERANGE", errno, ERANGE, 0, 0, 0);
# endif # endif
# if LDBL_MANT_DIG >= 113 # if LDBL_MANT_DIG >= 113
errno = 0; TEST_ff_f (pow, minus_zero, -0x1.ffffffffffffffffffffffffffffp+112L, minus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, minus_zero, -0x1.ffffffffffffffffffffffffffffp+112L, minus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, minus_zero, -0x1.ffffffffffffffffffffffffffffp+113L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
check_int ("errno for pow(-0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, minus_zero, -0x1.ffffffffffffffffffffffffffffp+113L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(-0,-even) == ERANGE", errno, ERANGE, 0, 0, 0);
# endif # endif
#endif #endif
errno = 0; TEST_ff_f (pow, 0, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, 0, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, 0, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
check_int ("errno for pow(0,-even) == ERANGE", errno, ERANGE, 0, 0, 0); TEST_ff_f (pow, 0, -min_subnorm_value, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
errno = 0; TEST_ff_f (pow, 0, -0x1p24, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, 0, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, 0, -0x1p127, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
check_int ("errno for pow(0,-num) == ERANGE", errno, ERANGE, 0, 0, 0); TEST_ff_f (pow, 0, -max_value, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
errno = 0; TEST_ff_f (pow, minus_zero, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, 0, -min_subnorm_value, plus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, minus_zero, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
check_int ("errno for pow(0,-num) == ERANGE", errno, ERANGE, 0, 0, 0); TEST_ff_f (pow, minus_zero, -min_subnorm_value, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
errno = 0; TEST_ff_f (pow, minus_zero, -0x1p24, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (pow, 0, -0x1p24, plus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, minus_zero, -0x1p127, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
check_int ("errno for pow(0,-num) == ERANGE", errno, ERANGE, 0, 0, 0); TEST_ff_f (pow, minus_zero, -max_value, plus_infty, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE);
errno = 0;
TEST_ff_f (pow, 0, -0x1p127, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(0,-num) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, 0, -max_value, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(0,-num) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, minus_zero, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(-0,-even) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, minus_zero, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(-0,-num) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, minus_zero, -min_subnorm_value, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(-0,-num) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, minus_zero, -0x1p24, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(-0,-num) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, minus_zero, -0x1p127, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(-0,-num) == ERANGE", errno, ERANGE, 0, 0, 0);
errno = 0;
TEST_ff_f (pow, minus_zero, -max_value, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
check_int ("errno for pow(-0,-num) == ERANGE", errno, ERANGE, 0, 0, 0);
TEST_ff_f (pow, 0x1p72L, 0x1p72L, plus_infty, OVERFLOW_EXCEPTION); TEST_ff_f (pow, 0x1p72L, 0x1p72L, plus_infty, OVERFLOW_EXCEPTION);
TEST_ff_f (pow, 10, -0x1p72L, 0, UNDERFLOW_EXCEPTION); TEST_ff_f (pow, 10, -0x1p72L, 0, UNDERFLOW_EXCEPTION);
@ -11394,52 +11364,22 @@ remainder_test (void)
START (remainder); START (remainder);
errno = 0; TEST_ff_f (remainder, 1, 0, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_ff_f (remainder, 1, 0, qnan_value, INVALID_EXCEPTION); TEST_ff_f (remainder, 1, minus_zero, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
check_int ("errno for remainder(1, 0) = EDOM ", errno, EDOM, 0, 0, 0); TEST_ff_f (remainder, plus_infty, minus_zero, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
errno = 0; TEST_ff_f (remainder, plus_infty, 0, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_ff_f (remainder, 1, minus_zero, qnan_value, INVALID_EXCEPTION); TEST_ff_f (remainder, plus_infty, 1, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
check_int ("errno for remainder(1, -0) = EDOM ", errno, EDOM, 0, 0, 0); TEST_ff_f (remainder, plus_infty, 2, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
errno = 0; TEST_ff_f (remainder, minus_infty, minus_zero, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_ff_f (remainder, plus_infty, minus_zero, qnan_value, INVALID_EXCEPTION); TEST_ff_f (remainder, minus_infty, 0, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
check_int ("errno for remainder(INF, -0) = EDOM ", errno, EDOM, 0, 0, 0); TEST_ff_f (remainder, minus_infty, 1, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
errno = 0; TEST_ff_f (remainder, minus_infty, 2, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_ff_f (remainder, plus_infty, 0, qnan_value, INVALID_EXCEPTION); TEST_ff_f (remainder, qnan_value, qnan_value, qnan_value, ERRNO_UNCHANGED);
check_int ("errno for remainder(INF, 0) = EDOM ", errno, EDOM, 0, 0, 0); TEST_ff_f (remainder, 0, qnan_value, qnan_value, ERRNO_UNCHANGED);
errno = 0; TEST_ff_f (remainder, qnan_value, 0, qnan_value, ERRNO_UNCHANGED);
TEST_ff_f (remainder, plus_infty, 1, qnan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(INF, 1) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, plus_infty, 2, qnan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(INF, 2) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, minus_infty, minus_zero, qnan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(-INF, -0) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, minus_infty, 0, qnan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(-INF, 0) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, minus_infty, 1, qnan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(-INF, 1) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, minus_infty, 2, qnan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(-INF, 2) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, qnan_value, qnan_value, qnan_value);
check_int ("errno for remainder(qNAN, qNAN) unchanged", errno, 0, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, 0, qnan_value, qnan_value);
check_int ("errno for remainder(0, qNAN) unchanged", errno, 0, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, qnan_value, 0, qnan_value);
check_int ("errno for remainder(qNaN, 0) unchanged", errno, 0, 0, 0, 0);
errno = 0; TEST_ff_f (remainder, 7.0, plus_infty, 7.0, ERRNO_UNCHANGED);
TEST_ff_f (remainder, 7.0, plus_infty, 7.0); TEST_ff_f (remainder, 7.0, minus_infty, 7.0, ERRNO_UNCHANGED);
check_int ("errno for remainder(7.0, INF) unchanged", errno, 0, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, 7.0, minus_infty, 7.0);
check_int ("errno for remainder(7.0, -INF) unchanged", errno, 0, 0, 0, 0);
TEST_ff_f (remainder, 1.625, 1.0, -0.375); TEST_ff_f (remainder, 1.625, 1.0, -0.375);
TEST_ff_f (remainder, -1.625, 1.0, 0.375); TEST_ff_f (remainder, -1.625, 1.0, 0.375);
@ -12226,15 +12166,9 @@ sin_test (void)
TEST_f_f (sin, 0, 0); TEST_f_f (sin, 0, 0);
TEST_f_f (sin, minus_zero, minus_zero); TEST_f_f (sin, minus_zero, minus_zero);
errno = 0; TEST_f_f (sin, plus_infty, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_f_f (sin, plus_infty, qnan_value, INVALID_EXCEPTION); TEST_f_f (sin, minus_infty, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
check_int ("errno for sin(+inf) == EDOM", errno, EDOM, 0, 0, 0); TEST_f_f (sin, qnan_value, qnan_value, ERRNO_UNCHANGED);
errno = 0;
TEST_f_f (sin, minus_infty, qnan_value, INVALID_EXCEPTION);
check_int ("errno for sin(-inf) == EDOM", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_f_f (sin, qnan_value, qnan_value);
check_int ("errno for sin(qNaN) unchanged", errno, 0, 0, 0, 0);
TEST_f_f (sin, M_PI_6l, 0.5); TEST_f_f (sin, M_PI_6l, 0.5);
TEST_f_f (sin, -M_PI_6l, -0.5); TEST_f_f (sin, -M_PI_6l, -0.5);
@ -12666,15 +12600,9 @@ tan_test (void)
TEST_f_f (tan, 0, 0); TEST_f_f (tan, 0, 0);
TEST_f_f (tan, minus_zero, minus_zero); TEST_f_f (tan, minus_zero, minus_zero);
errno = 0; TEST_f_f (tan, plus_infty, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
TEST_f_f (tan, plus_infty, qnan_value, INVALID_EXCEPTION); TEST_f_f (tan, minus_infty, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM);
check_int ("errno for tan(Inf) == EDOM", errno, EDOM, 0, 0, 0); TEST_f_f (tan, qnan_value, qnan_value, ERRNO_UNCHANGED);
errno = 0;
TEST_f_f (tan, minus_infty, qnan_value, INVALID_EXCEPTION);
check_int ("errno for tan(-Inf) == EDOM", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_f_f (tan, qnan_value, qnan_value);
check_int ("errno for tan(qNaN) == 0", errno, 0, 0, 0, 0);
TEST_f_f (tan, M_PI_4l, 1); TEST_f_f (tan, M_PI_4l, 1);
TEST_f_f (tan, 0.75L, 0.931596459944072461165202756573936428L); TEST_f_f (tan, 0.75L, 0.931596459944072461165202756573936428L);
@ -13232,9 +13160,7 @@ yn_test (void)
and FLT_MIN. See Bug 14173. */ and FLT_MIN. See Bug 14173. */
TEST_ff_f (yn, 10, min_value, minus_infty, OVERFLOW_EXCEPTION); TEST_ff_f (yn, 10, min_value, minus_infty, OVERFLOW_EXCEPTION);
errno = 0; TEST_ff_f (yn, 10, min_value, minus_infty, OVERFLOW_EXCEPTION|ERRNO_ERANGE);
TEST_ff_f (yn, 10, min_value, minus_infty, OVERFLOW_EXCEPTION);
check_int ("errno for yn(10,-min) == ERANGE", errno, ERANGE, 0, 0, 0);
END (yn); END (yn);
} }
@ -13291,6 +13217,7 @@ initialize (void)
/* Clear all exceptions. From now on we must not get random exceptions. */ /* Clear all exceptions. From now on we must not get random exceptions. */
feclearexcept (FE_ALL_EXCEPT); feclearexcept (FE_ALL_EXCEPT);
errno = 0;
/* Test to make sure we start correctly. */ /* Test to make sure we start correctly. */
fpstack_test ("end *init*"); fpstack_test ("end *init*");
@ -13641,8 +13568,9 @@ main (int argc, char **argv)
fclose (ulps_file); fclose (ulps_file);
printf ("\nTest suite completed:\n"); printf ("\nTest suite completed:\n");
printf (" %d test cases plus %d tests for exception flags executed.\n", printf (" %d test cases plus %d tests for exception flags and\n"
noTests, noExcTests); " %d tests for errno executed.\n",
noTests, noExcTests, noErrnoTests);
if (noXFails) if (noXFails)
printf (" %d expected failures occurred.\n", noXFails); printf (" %d expected failures occurred.\n", noXFails);
if (noXPasses) if (noXPasses)