mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Refactor libm-test inline tests disabling.
This patch refactors how libm-test.inc handles disabling errno/exception handling tests, and some other tests, for __FAST_MATH__ inline function tests. The macro TEST_INLINE is changed from being defined/undefined to being defined to 1 or 0, so that it can be tested in "if" conditionals instead of #if. For tests of errno and exception setting, separate macros TEST_ERRNO and TEST_EXCEPTIONS are added, and TEST_ERRNO is also used in the disabling of errno testing for vector function tests. The relevant conditionals are moved up a function, so that they take effect before the code that counts the number of tests, so the inline function tests now accurately report that 0 tests for exceptions and errno were executed (whereas they previously reported a large number desipte not running any such tests). Tested for x86_64 and x86. * math/test-math-errno.h: New file. * math/test-math-inline.h (TEST_INLINE): Define to 1 instead of empty. (TEST_ERRNO): New macro. (TEST_EXCEPTIONS): Likewise. * math/test-math-no-inline.h (TEST_INLINE): Likewise. (TEST_EXCEPTIONS): Likewise. * math/test-math-vector.h (TEST_ERRNO): Likewise. * math/test-double.c: Include "test-math-errno.h". * math/test-float.c: Likewise. * math/test-ldouble.c: Likewise. * math/libm-test.inc (test_single_exception) [!TEST_INLINE]: Make code unconditional. (test_exceptions): Only run code if TEST_EXCEPTIONS. (test_single_errno) [!TEST_INLINE && !TEST_MATHVEC]: Make code unconditional. (test_errno): Only run code if TEST_ERRNO. (enable_test): Use "if" conditional on TEST_INLINE, not #ifdef.
This commit is contained in:
@ -608,7 +608,6 @@ test_single_exception (const char *test_name,
|
||||
int fe_flag,
|
||||
const char *flag_name)
|
||||
{
|
||||
# ifndef TEST_INLINE
|
||||
int ok = 1;
|
||||
if (exception & exc_flag)
|
||||
{
|
||||
@ -643,8 +642,6 @@ test_single_exception (const char *test_name,
|
||||
}
|
||||
if (!ok)
|
||||
++noErrors;
|
||||
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -654,7 +651,7 @@ test_single_exception (const char *test_name,
|
||||
static void
|
||||
test_exceptions (const char *test_name, int exception)
|
||||
{
|
||||
if (EXCEPTION_TESTS (FLOAT))
|
||||
if (TEST_EXCEPTIONS && EXCEPTION_TESTS (FLOAT))
|
||||
{
|
||||
++noExcTests;
|
||||
#ifdef FE_DIVBYZERO
|
||||
@ -694,7 +691,6 @@ static void
|
||||
test_single_errno (const char *test_name, int errno_value,
|
||||
int expected_value, const char *expected_name)
|
||||
{
|
||||
#if !defined TEST_INLINE && !TEST_MATHVEC
|
||||
if (errno_value == expected_value)
|
||||
{
|
||||
if (print_screen (1))
|
||||
@ -708,7 +704,6 @@ test_single_errno (const char *test_name, int errno_value,
|
||||
printf ("Failure: %s: errno set to %d, expected %d (%s)\n",
|
||||
test_name, errno_value, expected_value, expected_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Test whether errno (value ERRNO_VALUE) has been for TEST_NAME set
|
||||
@ -716,13 +711,16 @@ test_single_errno (const char *test_name, int errno_value,
|
||||
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");
|
||||
if (TEST_ERRNO)
|
||||
{
|
||||
++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");
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns the number of ulps that GIVEN is away from EXPECTED. */
|
||||
@ -1041,10 +1039,8 @@ enable_test (int exceptions)
|
||||
{
|
||||
if (exceptions & XFAIL_TEST)
|
||||
return 0;
|
||||
#ifdef TEST_INLINE
|
||||
if (exceptions & NO_TEST_INLINE)
|
||||
if (TEST_INLINE && (exceptions & NO_TEST_INLINE))
|
||||
return 0;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user