changeset 13760:7e5397f6cecf

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>.
author Bruno Haible <bruno@clisp.org>
date Mon, 04 Oct 2010 21:35:44 +0200
parents 38b745d4e6a4
children a19ace3ba849
files ChangeLog tests/test-read-file.c
diffstat 2 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/tests/test-read-file.c
+++ b/tests/test-read-file.c
@@ -52,11 +52,23 @@
               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);
         }