diff options
Diffstat (limited to 'tests/tests.c')
-rw-r--r-- | tests/tests.c | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/tests/tests.c b/tests/tests.c index 495410f18..ef5a5a1ae 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -1,6 +1,6 @@ /* Miscellaneous support for test programs. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -27,6 +27,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <float.h> #if TIME_WITH_SYS_TIME @@ -38,6 +39,10 @@ MA 02111-1307, USA. */ # include <time.h> #endif +#if HAVE_SYS_FPU_H +# include <sys/fpu.h> +#endif + #include "mpfr-test.h" static void tests_rand_start (void); @@ -61,7 +66,7 @@ tests_end_mpfr (void) tests_memory_end (); } -void +static void tests_rand_start (void) { gmp_randstate_ptr rands; @@ -105,7 +110,7 @@ tests_rand_start (void) } } -void +static void tests_rand_end (void) { RANDS_CLEAR (); @@ -116,7 +121,7 @@ void mpfr_test_init () { double c, d, eps; -#ifdef __mips +#if HAVE_FPC_CSR /* to get denormalized numbers on IRIX64 */ union fpc_csr exp; @@ -287,3 +292,42 @@ ld_trace (const char *name, long double ld) } printf ("] %.20Lg\n", ld); } + +/* Open a file in the src directory - can't use fopen directly */ +FILE *src_fopen (const char *filename, const char *mode) +{ + const char *srcdir = getenv ("srcdir"); + char *buffer; + FILE *f; + + if (srcdir == NULL) + return fopen (filename, mode); + buffer = (char*) malloc (strlen (filename) + strlen (srcdir) + 1); + if (buffer == NULL) + { + printf ("src_fopen: failed to alloc memory)\n"); + exit (1); + } + sprintf (buffer, "%s/%s", srcdir, filename); + f = fopen (buffer, mode); + free (buffer); + return f; +} + +void set_emin (mp_exp_t exponent) +{ + if (mpfr_set_emin (exponent)) + { + printf ("set_emin: setting emin to %ld failed\n", (long int) exponent); + exit (1); + } +} + +void set_emax (mp_exp_t exponent) +{ + if (mpfr_set_emax (exponent)) + { + printf ("set_emax: setting emax to %ld failed\n", (long int) exponent); + exit (1); + } +} |