From 2ca2dd689c1585b8db4746d40292992986977f28 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 29 Apr 2007 11:06:56 +0000 Subject: [PATCH] Make test a bit easier to debug. --- ChangeLog | 5 +++++ tests/test-fflush.c | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1d9ef89cd..dad169cb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-04-29 Bruno Haible + * tests/test-fflush.c (main): Use a file of size 17, not 10. + Print more information in case of failure. Disable a test on BeOS. + +2007-04-29 Bruno Haible + * tests/**/test-*.[hc] (ASSERT): Use fprintf to show the line number. This helps debugging on systems on which no gdb is available. diff --git a/tests/test-fflush.c b/tests/test-fflush.c index 88789f30a..e4468c2ea 100755 --- a/tests/test-fflush.c +++ b/tests/test-fflush.c @@ -33,7 +33,7 @@ main (int argc, char *argv[]) /* Create test file. */ f = fopen ("test-fflush.txt", "w"); - if (!f || fwrite ("1234567890", 1, 10, f) != 10 || fclose (f) != 0) + if (!f || fwrite ("1234567890ABCDEFG", 1, 17, f) != 17 || fclose (f) != 0) { fputs ("Failed to create sample file.\n", stderr); unlink ("test-fflush.txt"); @@ -50,7 +50,9 @@ main (int argc, char *argv[]) unlink ("test-fflush.txt"); return 1; } - /* For deterministic results, ensure f read a bigger buffer. */ + /* For deterministic results, ensure f read a bigger buffer. + This is not the case on BeOS. */ +#if !defined __BEOS__ if (lseek (fd, 0, SEEK_CUR) == 5) { fputs ("Sample file was not buffered after fread.\n", stderr); @@ -58,6 +60,7 @@ main (int argc, char *argv[]) unlink ("test-fflush.txt"); return 1; } +#endif /* POSIX requires fflush-fseek to set file offset of fd. */ if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0) { @@ -69,14 +72,16 @@ main (int argc, char *argv[]) /* Check that offset is correct. */ if (lseek (fd, 0, SEEK_CUR) != 5) { - fputs ("File offset is wrong after fseek.\n", stderr); + fprintf (stderr, "File offset is wrong after fseek: %ld.\n", + (long) lseek (fd, 0, SEEK_CUR)); fclose (f); unlink ("test-fflush.txt"); return 1; } if (ftell (f) != 5) { - fputs ("ftell result is wrong after fseek.\n", stderr); + fprintf (stderr, "ftell result is wrong after fseek: %ld.\n", + (long) ftell (f)); fclose (f); unlink ("test-fflush.txt"); return 1; @@ -108,14 +113,16 @@ main (int argc, char *argv[]) /* Check that offset is correct. */ if (lseek (fd, 0, SEEK_CUR) != 6) { - fputs ("File offset is wrong after fseeko.\n", stderr); + fprintf (stderr, "File offset is wrong after fseeko: %ld.\n", + (long) lseek (fd, 0, SEEK_CUR)); fclose (f); unlink ("test-fflush.txt"); return 1; } if (ftell (f) != 6) { - fputs ("ftell result is wrong after fseek.\n", stderr); + fprintf (stderr, "ftell result is wrong after fseeko: %ld.\n", + (long) ftell (f)); fclose (f); unlink ("test-fflush.txt"); return 1; -- 2.11.0