]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Diagnose write errors in config.status instantiations.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Fri, 16 Nov 2007 06:51:10 +0000 (07:51 +0100)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Fri, 16 Nov 2007 06:51:10 +0000 (07:51 +0100)
* lib/autoconf/status.m4 (_AC_OUTPUT_FILE)
(_AC_OUTPUT_HEADER, _AC_OUTPUT_MAIN_LOOP): Bail out
on write errors.
* tests/torture.at (AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS):
Extend test to also check for some write error failures, using...
<AT_CHECK_CONFIG_CREATION_NOWRITE>: ...this new macro.
Report by Bruno Haible.

ChangeLog
lib/autoconf/status.m4
tests/torture.at

index ddfd871731946b2b03f14c72053d214489775651..627adbd066728c52813f7a099eb75b2911c91a97 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2007-11-16  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       Diagnose write errors in config.status instantiations.
+       * lib/autoconf/status.m4 (_AC_OUTPUT_FILE)
+       (_AC_OUTPUT_HEADER, _AC_OUTPUT_MAIN_LOOP): Bail out
+       on write errors.
+       * tests/torture.at (AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS):
+       Extend test to also check for some write error failures, using...
+       <AT_CHECK_CONFIG_CREATION_NOWRITE>: ...this new macro.
+       Report by Bruno Haible.
+
        Indentation fixups.
        * lib/autotest/general.m4 (AT_INIT) <at_func_log_failure>: Fix
        indentation.
index 0d1d93e7992c970b37cfbfb161f641c805c8ab73..4a617a66fd242e12865f80cc38bcdcda90da6e3b 100644 (file)
@@ -636,7 +636,8 @@ m4_foreach([_AC_Var], [srcdir, abs_srcdir, top_srcdir, abs_top_srcdir,
 ])dnl
 m4_ifndef([AC_DATAROOTDIR_CHECKED], [$ac_datarootdir_hack
 ])dnl
-" $ac_file_inputs m4_defn([_AC_SUBST_CMDS]) >$tmp/out
+" $ac_file_inputs m4_defn([_AC_SUBST_CMDS]) >$tmp/out \
+  || AC_MSG_ERROR([could not create $ac_file])
 
 m4_ifndef([AC_DATAROOTDIR_CHECKED],
 [test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
@@ -648,9 +649,10 @@ which seems to be undefined.  Please make sure it is defined.])
 
   rm -f "$tmp/stdin"
   case $ac_file in
-  -) cat "$tmp/out"; rm -f "$tmp/out";;
-  *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;
-  esac
+  -) cat "$tmp/out" && rm -f "$tmp/out";;
+  *) rm -f "$ac_file" && mv "$tmp/out" $ac_file;;
+  esac \
+  || AC_MSG_ERROR([could not create $ac_file])
 dnl This would break Makefile dependencies:
 dnl  if diff $ac_file "$tmp/out" >/dev/null 2>&1; then
 dnl    echo "$ac_file is unchanged"
@@ -838,17 +840,22 @@ m4_define([_AC_OUTPUT_HEADER],
   # CONFIG_HEADER
   #
   if test x"$ac_file" != x-; then
-    AS_ECHO(["/* $configure_input  */"]) >"$tmp/config.h"
-    $AWK -f "$tmp/defines.awk" $ac_file_inputs >>"$tmp/config.h"
+    {
+      AS_ECHO(["/* $configure_input  */"]) \
+      && $AWK -f "$tmp/defines.awk" $ac_file_inputs
+    } >"$tmp/config.h" \
+      || AC_MSG_ERROR([could not create $ac_file])
     if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then
       AC_MSG_NOTICE([$ac_file is unchanged])
     else
       rm -f $ac_file
-      mv "$tmp/config.h" $ac_file
+      mv "$tmp/config.h" $ac_file \
+       || AC_MSG_ERROR([could not create $ac_file])
     fi
   else
-    AS_ECHO(["/* $configure_input  */"])
-    $AWK -f "$tmp/defines.awk" $ac_file_inputs
+    AS_ECHO(["/* $configure_input  */"]) \
+      && $AWK -f "$tmp/defines.awk" $ac_file_inputs \
+      || AC_MSG_ERROR([could not create -])
   fi
 dnl If running for Automake, be ready to perform additional
 dnl commands to set up the timestamp files.
@@ -1617,7 +1624,8 @@ do
     fi
 
     case $ac_tag in
-    *:-:* | *:-) cat >"$tmp/stdin";;
+    *:-:* | *:-) cat >"$tmp/stdin" \
+      || AC_MSG_ERROR([could not create $ac_file]) ;;
     esac
     ;;
   esac
index 63d6ef94fc5c7673f00f4dff7abe4d5a358df841..a87a33bcc724f19768d6259d9ed63cbb4e849b73 100644 (file)
@@ -193,6 +193,29 @@ AT_CHECK([grep OK var-$1], [], [OK
 ])# AT_CHECK_CONFIG_CREATION
 
 
+# AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
+# ------------------------------------------------------------------
+# Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
+# are properly created, with the right content.
+# Use `grep OK' instead of a simple `cat' to avoid banners such as in
+# AC_CONFIG_HEADERS.
+m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
+[AT_CHECK_CONFIGURE([what_to_test=$1])
+AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
+        [ignore], [$1
+])
+AT_CHECK([grep OK $1], [], [OK
+])
+
+AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
+# config.status might be stupidly expecting data on stdin, if it's
+# really broken...
+chmod a-w .
+AT_CHECK([./config.status var-$1 </dev/null], [1], [ignore], [ignore])
+chmod u+w .
+])# AT_CHECK_CONFIG_CREATION_NOWRITE
+
+
 # Create a file
 AT_CHECK_CONFIG_CREATION(file)
 
@@ -205,6 +228,24 @@ AT_CHECK_CONFIG_CREATION(command)
 # Create a link
 AT_CHECK_CONFIG_CREATION(link)
 
+# Now check for write errors
+
+# Create a file
+AT_CHECK_CONFIG_CREATION_NOWRITE(file)
+AT_CHECK([./config.status --file=-:input </dev/null >/dev/full],
+        [1], [ignore], [ignore])
+
+# Create a header
+AT_CHECK_CONFIG_CREATION_NOWRITE(header)
+AT_CHECK([./config.status --header=-:input </dev/null >/dev/full],
+        [1], [ignore], [ignore])
+
+# Execute a command
+AT_CHECK_CONFIG_CREATION_NOWRITE(command)
+
+# Create a link
+AT_CHECK_CONFIG_CREATION_NOWRITE(link)
+
 AT_CLEANUP