read-file tests: Avoid a test failure on NonStop Kernel.
authorBruno Haible <bruno@clisp.org>
Mon, 4 Oct 2010 19:35:44 +0000 (21:35 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 4 Oct 2010 19:35:44 +0000 (21:35 +0200)
* tests/test-read-file.c (main): Don't assume that /etc/resolv.conf is
a regular file.
Reported by Joachim Schmitz <schmitz@hp.com>.

ChangeLog
tests/test-read-file.c

index 9f6223c..4a556ce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-10-04  Bruno Haible  <bruno@clisp.org>
+
+       read-file tests: Avoid a test failure on NonStop Kernel.
+       * tests/test-read-file.c (main): Don't assume that /etc/resolv.conf is
+       a regular file.
+       Reported by Joachim Schmitz <schmitz@hp.com>.
+
 2010-10-03  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool: Fixes for --create-testdir with --libtool.
index 0a0bf68..daa6166 100644 (file)
@@ -52,11 +52,23 @@ main (void)
               err = 1;
             }
 
-          /* Assume FILE1 is a regular file or a symlink to a regular file.  */
-          if (len != statbuf.st_size)
+          if (S_ISREG (statbuf.st_mode))
             {
-              fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len, FILE1);
-              err = 1;
+              /* FILE1 is a regular file or a symlink to a regular file.  */
+              if (len != statbuf.st_size)
+                {
+                  fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len, FILE1);
+                  err = 1;
+                }
+            }
+          else
+            {
+              /* Assume FILE1 is not empty.  */
+              if (len == 0)
+                {
+                  fprintf (stderr, "Read nothing from %s\n", FILE1);
+                  err = 1;
+                }
             }
           free (out);
         }