int main (int argc, char *argv[]) { int N; tests_start_mpfr (); /* with no argument: prints to /dev/null, tprintf N: prints N tests to stdout */ if (argc == 1) { N = 1000; stdout_redirect = 1; if (freopen ("/dev/null", "w", stdout) == NULL) { /* We failed to open this device, try with a dummy file */ if (freopen ("mpfrtest.txt", "w", stdout) == NULL) { /* Output the error message to stderr since it is not a message about a wrong result in MPFR. Anyway the stdandard output may have changed. */ fprintf (stderr, "Can't open /dev/null or a temporary file\n"); exit (1); } } } else { stdout_redirect = 0; N = atoi (argv[1]); } check_invalid_format (); check_special (); check_mixed (); /* expensive tests */ if (getenv ("MPFR_CHECK_LARGEMEM") != NULL) check_long_string(); check_random (N); test_locale (); if (stdout_redirect) { if ((fflush (stdout) == EOF) || (fclose (stdout) == -1)) perror ("main"); } tests_end_mpfr (); return 0; }
int main (int argc, char *argv[]) { FILE *fout; int N; tests_start_mpfr (); /* with no argument: prints to /dev/null, tfprintf N: prints N tests to stdout */ if (argc == 1) { N = 1000; fout = fopen ("/dev/null", "w"); /* If we failed to open this device, try with a dummy file */ if (fout == NULL) { fout = fopen ("mpfrtest.txt", "w"); if (fout == NULL) { printf ("Can't open /dev/null or a temporary file\n"); exit (1); } } } else { fout = stdout; N = atoi (argv[1]); } check_special (fout); check_mixed (fout); check_random (fout, N); bug_20090316 (fout); fclose (fout); tests_end_mpfr (); return 0; }