changeset 8755:4ae117cb36cd

Make test a bit easier to debug.
author Bruno Haible <bruno@clisp.org>
date Sun, 29 Apr 2007 11:06:56 +0000
parents 1f57552cdb11
children 8a62dff89d5a
files ChangeLog tests/test-fflush.c
diffstat 2 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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.
--- a/tests/test-fflush.c
+++ b/tests/test-fflush.c
@@ -33,7 +33,7 @@
 
   /* 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 @@
       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 @@
       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 @@
   /* 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 @@
   /* 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;