diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-03-13 17:48:24 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-03-13 17:48:24 +0000 |
commit | 980afccd553954cb25bc1262daf28c4f0a25728e (patch) | |
tree | 3bc628c68c41bfbfd12e724f34c0ba13c8089d24 | |
parent | b3ef2cd93f039a3209455dc1d4fb4c05aa26024d (diff) | |
download | mpfr-980afccd553954cb25bc1262daf28c4f0a25728e.tar.gz |
[tests/tests.c] Revert a change done in r13783 for function bad_cases():
no longer fail if a generated value does not correspond to a bad case.
But fail if the MPFR_CHECK_BADCASES environment variable is defined
and too few bad cases are generated (less than 90%).
[doc/README.dev] Document MPFR_CHECK_BADCASES.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13788 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | doc/README.dev | 6 | ||||
-rw-r--r-- | tests/tests.c | 29 |
2 files changed, 27 insertions, 8 deletions
diff --git a/doc/README.dev b/doc/README.dev index 1ee7ee641..06518f9e8 100644 --- a/doc/README.dev +++ b/doc/README.dev @@ -340,7 +340,7 @@ To make a release (for the MPFR team): Also test with different environment variables set (GMP_CHECK_RANDOMIZE, MPFR_CHECK_LIBC_PRINTF, MPFR_CHECK_LARGEMEM, - MPFR_SUSPICIOUS_OVERFLOW, MPFR_CHECK_LOCALES). + MPFR_SUSPICIOUS_OVERFLOW, MPFR_CHECK_LOCALES, MPFR_CHECK_BADCASES). Check there is no branch misprediction due to wrong MPFR_LIKELY or MPFR_UNLIKELY statements. For that test, configure with @@ -580,6 +580,10 @@ Environment variables that affect the tests: sure that needed locales are properly installed and tested. ++ MPFR_CHECK_BADCASES: Fail if function bad_cases generates too many + cases for which f(f^{-1}(x)) ≠ x, due to a poor + choice of the parameters. + + MPFR_DEBUG_BADCASES: For debugging (see tests.c, function bad_cases). + MPFR_SUSPICIOUS_OVERFLOW: diff --git a/tests/tests.c b/tests/tests.c index a82a44a54..a27f2109f 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -987,7 +987,7 @@ bad_cases (int (*fct)(FLIST), int (*inv)(FLIST), const char *name, { mpfr_t x, y, z; char *dbgenv; - int i, dbg; + int cnt = 0, i, dbg; mpfr_exp_t old_emin, old_emax; old_emin = mpfr_get_emin (); @@ -1068,12 +1068,16 @@ bad_cases (int (*fct)(FLIST), int (*inv)(FLIST), const char *name, if (mpfr_nanflag_p () || mpfr_overflow_p () || mpfr_underflow_p () || ! mpfr_equal_p (z, y)) { - printf ("bad_cases: inverse doesn't match for %s\ny = ", name); - mpfr_out_str (stdout, 16, 0, y, MPFR_RNDN); - printf ("\nz = "); - mpfr_out_str (stdout, 16, 0, z, MPFR_RNDN); - printf ("\n"); - exit (1); + if (dbg) + { + printf ("bad_cases: inverse doesn't match for %s\ny = ", + name); + mpfr_out_str (stdout, 16, 0, y, MPFR_RNDN); + printf ("\nz = "); + mpfr_out_str (stdout, 16, 0, z, MPFR_RNDN); + printf ("\n"); + } + goto next_i; } } while (inex == 0); @@ -1104,6 +1108,7 @@ bad_cases (int (*fct)(FLIST), int (*inv)(FLIST), const char *name, } /* Note: y is now the expected result rounded toward zero. */ test5rm (fct, x, y, z, MPFR_RNDZ, sb, name); + cnt++; next_i: /* In case the exponent range has been changed by tests_default_random()... */ @@ -1111,6 +1116,16 @@ bad_cases (int (*fct)(FLIST), int (*inv)(FLIST), const char *name, mpfr_set_emax (old_emax); } mpfr_clears (x, y, z, (mpfr_ptr) 0); + + if (dbg) + printf ("bad_cases: %d bad cases over %d generated values\n", cnt, n); + + if (getenv ("MPFR_CHECK_BADCASES") && n - cnt > n/10) + { + printf ("bad_cases: too few bad cases (%d over %d generated values)\n", + cnt, n); + exit (1); + } } void |