Make test a bit easier to debug.
authorBruno Haible <bruno@clisp.org>
Sun, 29 Apr 2007 11:06:56 +0000 (11:06 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 29 Apr 2007 11:06:56 +0000 (11:06 +0000)
ChangeLog
tests/test-fflush.c

index 1d9ef89..dad169c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2007-04-29  Bruno Haible  <bruno@clisp.org>
 
+       * 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  <bruno@clisp.org>
+
        * tests/**/test-*.[hc] (ASSERT): Use fprintf to show the line number.
        This helps debugging on systems on which no gdb is available.
 
index 88789f3..e4468c2 100755 (executable)
@@ -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;