Changeset View
Changeset View
Standalone View
Standalone View
lib/msun/tests/lround_test.c
Show All 25 Lines | |||||||||||
/* | /* | ||||||||||
* Test for lround(), lroundf(), llround(), and llroundf(). | * Test for lround(), lroundf(), llround(), and llroundf(). | ||||||||||
*/ | */ | ||||||||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||||||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||||||||
#include <assert.h> | |||||||||||
#include <fenv.h> | #include <fenv.h> | ||||||||||
#include <limits.h> | #include <limits.h> | ||||||||||
#include <math.h> | #include <math.h> | ||||||||||
#include <stdio.h> | #include <stdio.h> | ||||||||||
#include "test-utils.h" | |||||||||||
/* | /* | ||||||||||
* XXX The volatile here is to avoid gcc's bogus constant folding and work | * XXX The volatile here is to avoid gcc's bogus constant folding and work | ||||||||||
* around the lack of support for the FENV_ACCESS pragma. | * around the lack of support for the FENV_ACCESS pragma. | ||||||||||
*/ | */ | ||||||||||
#define test(func, x, result, excepts) do { \ | #define test(func, x, result, excepts) do { \ | ||||||||||
volatile double _d = x; \ | volatile double _d = x; \ | ||||||||||
assert(feclearexcept(FE_ALL_EXCEPT) == 0); \ | ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT)); \ | ||||||||||
assert((func)(_d) == (result) || fetestexcept(FE_INVALID)); \ | CHECK_FP_EXCEPTIONS_MSG(excepts, FE_ALL_EXCEPT, "for %s(%s)", \ | ||||||||||
assert(fetestexcept(FE_ALL_EXCEPT) == (excepts)); \ | #func, #x); \ | ||||||||||
if (fetestexcept(FE_INVALID) != (excepts & FE_INVALID)) { \ | |||||||||||
atf_tc_fail_nonfatal("FE_INVALID not set correctly for %s(%s)", \ | |||||||||||
#func, #x); \ | |||||||||||
} else { \ | |||||||||||
ATF_CHECK_EQ((result), (func)(_d)); \ | |||||||||||
} \ | |||||||||||
} while (0) | } while (0) | ||||||||||
#define testall(x, result, excepts) do { \ | #define testall(x, result, excepts) do { \ | ||||||||||
test(lround, x, result, excepts); \ | test(lround, x, result, excepts); \ | ||||||||||
test(lroundf, x, result, excepts); \ | test(lroundf, x, result, excepts); \ | ||||||||||
test(llround, x, result, excepts); \ | test(llround, x, result, excepts); \ | ||||||||||
test(llroundf, x, result, excepts); \ | test(llroundf, x, result, excepts); \ | ||||||||||
} while (0) | } while (0) | ||||||||||
#define IGNORE 0 | #define IGNORE 0x12345 | ||||||||||
#pragma STDC FENV_ACCESS ON | #pragma STDC FENV_ACCESS ON | ||||||||||
int | ATF_TC_WITHOUT_HEAD(main); | ||||||||||
main(int argc, char *argv[]) | ATF_TC_BODY(main, tc) | ||||||||||
{ | { | ||||||||||
atf_tc_expect_fail("https://bugs.freebsd.org/205451"); | |||||||||||
ngieUnsubmitted Not Done Inline Actions
ngie: 1. The xfail should be applied to the affected areas; refactoring the tests will allow that to… | |||||||||||
Done Inline ActionsBasically all asserts fail because the exception flags INVALID/INEXACT are not being set. I can try to add the xfails to individual tests but I don't have enough time to do further debugging now. I can also leave the entire test disabled as is the current state. arichardson: Basically all asserts fail because the exception flags INVALID/INEXACT are not being set. I can… | |||||||||||
Done Inline ActionsStandard error: *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:74: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for lround(0.25) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:74: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for lroundf(0.25) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:74: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for llround(0.25) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:74: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for llroundf(0.25) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:75: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for lround(0.5) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:75: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for lroundf(0.5) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:75: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for llround(0.5) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:75: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for llroundf(0.5) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:76: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for lround(-0.5) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:76: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for lroundf(-0.5) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:76: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for llround(-0.5) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:76: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for llroundf(-0.5) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:79: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for lround(0x1234.fp0) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:79: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for lroundf(0x1234.fp0) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:79: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for llround(0x1234.fp0) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:79: (0x20) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x20 for llroundf(0x1234.fp0) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:80: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for lround(__builtin_inff()) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for lround(__builtin_inff()) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:80: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for lroundf(__builtin_inff()) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for lroundf(__builtin_inff()) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:80: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for llround(__builtin_inff()) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for llround(__builtin_inff()) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:80: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for llroundf(__builtin_inff()) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for llroundf(__builtin_inff()) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:81: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for lround(__builtin_nanf("")) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for lround(__builtin_nanf("")) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:81: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for lroundf(__builtin_nanf("")) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for lroundf(__builtin_nanf("")) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:81: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for llround(__builtin_nanf("")) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for llround(__builtin_nanf("")) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:81: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for llroundf(__builtin_nanf("")) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for llroundf(__builtin_nanf("")) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:92: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for lround(0x8000000000000000.0p0) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for lround(0x8000000000000000.0p0) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:93: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for lroundf(0x8000000000000000.0p0f) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for lroundf(0x8000000000000000.0p0f) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:96: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for lround(-0x8000000000000800.0p0) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for lround(-0x8000000000000800.0p0) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:97: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for lroundf(-0x8000010000000000.0p0f) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for lroundf(-0x8000010000000000.0p0f) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:105: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for llround(0x8000000000000000.0p0) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for llround(0x8000000000000000.0p0) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:106: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for llroundf(0x8000000000000000.0p0f) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for llroundf(0x8000000000000000.0p0f) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:109: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for llround(-0x8000000000000800.0p0) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for llround(-0x8000000000000800.0p0) *** Expected check failure: https://bugs.freebsd.org/205451: /Users/alex/cheri/freebsd/lib/msun/tests/lround_test.c:110: (0x01) != fetestexcept((0x04 | 0x02 | 0x20 | 0x01 | 0x08 | 0x10)): unexpected exception flags: got 0 not 0x1 for llroundf(-0x8000010000000000.0p0f) *** Expected check failure: https://bugs.freebsd.org/205451: FE_INVALID not set correctly for llroundf(-0x8000010000000000.0p0f) ===> Expected failures lround_test:main -> expected_failure: https://bugs.freebsd.org/205451: 48 checks failed as expected; see output for more details [0.009s] arichardson: ```
Standard error:
*** Expected check failure: https://bugs.freebsd.org/205451… | |||||||||||
Done Inline ActionsI have some follow-up changes to fix this test. Will post those once I've committed the other reviews. arichardson: I have some follow-up changes to fix this test. Will post those once I've committed the other… | |||||||||||
printf("1..1\n"); | |||||||||||
testall(0.0, 0, 0); | testall(0.0, 0, 0); | ||||||||||
testall(0.25, 0, FE_INEXACT); | testall(0.25, 0, FE_INEXACT); | ||||||||||
testall(0.5, 1, FE_INEXACT); | testall(0.5, 1, FE_INEXACT); | ||||||||||
testall(-0.5, -1, FE_INEXACT); | testall(-0.5, -1, FE_INEXACT); | ||||||||||
testall(1.0, 1, 0); | testall(1.0, 1, 0); | ||||||||||
testall(0x12345000p0, 0x12345000, 0); | testall(0x12345000p0, 0x12345000, 0); | ||||||||||
testall(0x1234.fp0, 0x1235, FE_INEXACT); | testall(0x1234.fp0, 0x1235, FE_INEXACT); | ||||||||||
testall(INFINITY, IGNORE, FE_INVALID); | testall(INFINITY, IGNORE, FE_INVALID); | ||||||||||
Show All 9 Lines | #if (LONG_MAX == 0x7fffffffl) | ||||||||||
test(lroundf, 0x7fffff80.0p0f, 0x7fffff80l, 0); | test(lroundf, 0x7fffff80.0p0f, 0x7fffff80l, 0); | ||||||||||
#elif (LONG_MAX == 0x7fffffffffffffffll) | #elif (LONG_MAX == 0x7fffffffffffffffll) | ||||||||||
test(lround, 0x8000000000000000.0p0, IGNORE, FE_INVALID); | test(lround, 0x8000000000000000.0p0, IGNORE, FE_INVALID); | ||||||||||
test(lroundf, 0x8000000000000000.0p0f, IGNORE, FE_INVALID); | test(lroundf, 0x8000000000000000.0p0f, IGNORE, FE_INVALID); | ||||||||||
test(lround, 0x7ffffffffffffc00.0p0, 0x7ffffffffffffc00l, 0); | test(lround, 0x7ffffffffffffc00.0p0, 0x7ffffffffffffc00l, 0); | ||||||||||
test(lroundf, 0x7fffff8000000000.0p0f, 0x7fffff8000000000l, 0); | test(lroundf, 0x7fffff8000000000.0p0f, 0x7fffff8000000000l, 0); | ||||||||||
test(lround, -0x8000000000000800.0p0, IGNORE, FE_INVALID); | test(lround, -0x8000000000000800.0p0, IGNORE, FE_INVALID); | ||||||||||
test(lroundf, -0x8000010000000000.0p0f, IGNORE, FE_INVALID); | test(lroundf, -0x8000010000000000.0p0f, IGNORE, FE_INVALID); | ||||||||||
test(lround, -0x8000000000000000.0p0, -0x8000000000000000l, 0); | test(lround, -0x8000000000000000.0p0, (long)-0x8000000000000000l, 0); | ||||||||||
test(lroundf, -0x8000000000000000.0p0f, -0x8000000000000000l, 0); | test(lroundf, -0x8000000000000000.0p0f, (long)-0x8000000000000000l, 0); | ||||||||||
#else | #else | ||||||||||
#error "Unsupported long size" | #error "Unsupported long size" | ||||||||||
#endif | #endif | ||||||||||
#if (LLONG_MAX == 0x7fffffffffffffffLL) | #if (LLONG_MAX == 0x7fffffffffffffffLL) | ||||||||||
test(llround, 0x8000000000000000.0p0, IGNORE, FE_INVALID); | test(llround, 0x8000000000000000.0p0, IGNORE, FE_INVALID); | ||||||||||
test(llroundf, 0x8000000000000000.0p0f, IGNORE, FE_INVALID); | test(llroundf, 0x8000000000000000.0p0f, IGNORE, FE_INVALID); | ||||||||||
test(llround, 0x7ffffffffffffc00.0p0, 0x7ffffffffffffc00ll, 0); | test(llround, 0x7ffffffffffffc00.0p0, 0x7ffffffffffffc00ll, 0); | ||||||||||
test(llroundf, 0x7fffff8000000000.0p0f, 0x7fffff8000000000ll, 0); | test(llroundf, 0x7fffff8000000000.0p0f, 0x7fffff8000000000ll, 0); | ||||||||||
test(llround, -0x8000000000000800.0p0, IGNORE, FE_INVALID); | test(llround, -0x8000000000000800.0p0, IGNORE, FE_INVALID); | ||||||||||
test(llroundf, -0x8000010000000000.0p0f, IGNORE, FE_INVALID); | test(llroundf, -0x8000010000000000.0p0f, IGNORE, FE_INVALID); | ||||||||||
test(llround, -0x8000000000000000.0p0, -0x8000000000000000ll, 0); | test(llround, -0x8000000000000000.0p0, (long long)-0x8000000000000000ll, 0); | ||||||||||
test(llroundf, -0x8000000000000000.0p0f, -0x8000000000000000ll, 0); | test(llroundf, -0x8000000000000000.0p0f, (long long)-0x8000000000000000ll, 0); | ||||||||||
#else | #else | ||||||||||
#error "Unsupported long long size" | #error "Unsupported long long size" | ||||||||||
#endif | #endif | ||||||||||
} | |||||||||||
printf("ok 1 - lround\n"); | ATF_TP_ADD_TCS(tp) | ||||||||||
{ | |||||||||||
ATF_TP_ADD_TC(tp, main); | |||||||||||
return (0); | return (atf_no_error()); | ||||||||||
} | } | ||||||||||
Done Inline Actions
newline ngie: newline |