summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-02-02 10:57:17 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-02-02 10:57:17 +0000
commitcb5f1c7b54fccc610fd4329ea6ea4aa6d1eeb61b (patch)
tree65d624c2164c3b55f908a180b0447794f65a763c
parentf4f215404bd38f76b45bcf97a8bf44a9caf79783 (diff)
downloadmpfr-cb5f1c7b54fccc610fd4329ea6ea4aa6d1eeb61b.tar.gz
[tests] Fixed the cases where tests_start_mpfr was called too late,
i.e. after potential output (to stdout). * tremquo.c: moved the call to tests_start_mpfr to the beginning. * tset_float128.c, tset_ld.c: removed the optional, obsolete code setting the FPU control word; MPFR_FPU_PREC can be used instead (see tests.c). [tests/tests.c] Make stderr unbuffered again. Note for the history: both stdout and stderr were made unbuffered in r2361, then all stderr were changed to stdout (and the corresponding setbuf on stderr removed) in r2449 for consistency, but stderr was used later for specific cases (e.g. memory allocation errors or when stdout is already used for something else), and it is also used for assertion failures. Thus the setbuf on stderr is still needed. (merged changesets r12185-12186 from the trunk) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/4.0@12187 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--tests/tests.c11
-rw-r--r--tests/tremquo.c4
-rw-r--r--tests/tset_float128.c14
-rw-r--r--tests/tset_ld.c10
4 files changed, 11 insertions, 28 deletions
diff --git a/tests/tests.c b/tests/tests.c
index bbeaf785e..c1a20c17b 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -256,9 +256,16 @@ void
tests_start_mpfr (void)
{
/* Don't buffer, so output is not lost if a test causes a segv, etc.
- Warning! No operations must have already been done on stdout
- (this is a requirement of ISO C, and this is important on AIX). */
+ For stdout, this is important as it will typically be fully buffered
+ by default with "make check". For stderr, the C standard just says
+ that it is not fully buffered (it may be line buffered by default);
+ disabling buffering completely might be useful in some cases.
+ Warning! No operations must have already been done on stdout/stderr
+ (this is a requirement of ISO C, and this is important on AIX).
+ Thus tests_start_mpfr should be called at the beginning of main(),
+ possibly after some variable settings. */
setbuf (stdout, NULL);
+ setbuf (stderr, NULL);
test_version ();
diff --git a/tests/tremquo.c b/tests/tremquo.c
index dc64aba8c..55eb82564 100644
--- a/tests/tremquo.c
+++ b/tests/tremquo.c
@@ -58,6 +58,8 @@ main (int argc, char *argv[])
long q[1];
int inex;
+ tests_start_mpfr ();
+
if (argc == 3) /* usage: tremquo x y (rnd=MPFR_RNDN implicit) */
{
mpfr_init2 (x, GMP_NUMB_BITS);
@@ -75,8 +77,6 @@ main (int argc, char *argv[])
return 0;
}
- tests_start_mpfr ();
-
bug20090227 ();
mpfr_init (x);
diff --git a/tests/tset_float128.c b/tests/tset_float128.c
index d20de1149..1480d885a 100644
--- a/tests/tset_float128.c
+++ b/tests/tset_float128.c
@@ -327,20 +327,6 @@ check_small (void)
int
main (int argc, char *argv[])
{
-#ifdef WITH_FPU_CONTROL
- fpu_control_t cw;
-
- /* cw=895 (0x037f): round to double extended precision
- cw=639 (0x027f): round to double precision
- cw=127 (0x007f): round to single precision */
- if (argc > 1)
- {
- cw = strtol(argv[1], NULL, 0);
- printf ("FPU control word: 0x%x\n", (unsigned int) cw);
- _FPU_SETCW (cw);
- }
-#endif
-
tests_start_mpfr ();
check_special ();
diff --git a/tests/tset_ld.c b/tests/tset_ld.c
index 76f826ddd..e6701971d 100644
--- a/tests/tset_ld.c
+++ b/tests/tset_ld.c
@@ -505,16 +505,6 @@ main (int argc, char *argv[])
mpfr_t x;
int i;
mpfr_exp_t emax;
-#ifdef WITH_FPU_CONTROL
- fpu_control_t cw;
-
- if (argc > 1)
- {
- cw = strtol(argv[1], NULL, 0);
- printf ("FPU control word: 0x%x\n", (unsigned int) cw);
- _FPU_SETCW (cw);
- }
-#endif
tests_start_mpfr ();
mpfr_test_init ();