autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix some write failure cases in Autotest.


From: Ralf Wildenhues
Subject: Fix some write failure cases in Autotest.
Date: Sat, 8 Dec 2007 14:07:51 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

This patch fixes the most problematic write failure issues in Autotest,
namely --help/--version (GCS requirement), --list (was easy to do),
and the cases where scripts are created.  Normal progress output on
stdout or testsuite logs are not checked, neither are creation of test
files (AT_DATA), or various little helper files (like at-stdout,
at-status).  I'm not quite sure to which end these should be checked.

FWIW, I used at_write_fail rather than an AND (&&) list for backward
compatibility in case the Autotest user extended the help (and other)
diversions with her own commands.

If somebody can suggest good ways for test exposure of these then I'd
be glad to write some.  Otherwise, OK to apply?

Cheers,
Ralf

    Fix some write failure cases in Autotest.
    
    * lib/autotest/general.m4 (AT_INIT): Do not exit successfully
    upon write failures for --help, --version, --list.
    Guard against write failures for intermediate created scripts.
    <at_func_create_debugging_script>: Do not make the debugging
    script executable if it is not complete.

diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index cf33cda..11ff925 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -327,14 +327,14 @@ at_func_test ()
 at_func_create_debugging_script ()
 {
   {
-    echo "#! /bin/sh"
+    echo "#! /bin/sh" &&
     echo 'test "${ZSH_VERSION+set}" = set dnl
-&& alias -g '\''${1+"address@hidden"}'\''='\''"address@hidden"'\'''
-    AS_ECHO(["cd '$at_dir'"])
+&& alias -g '\''${1+"address@hidden"}'\''='\''"address@hidden"'\''' &&
+    AS_ECHO(["cd '$at_dir'"]) &&
     AS_ECHO(["exec \${CONFIG_SHELL-$SHELL} \"$at_myself\" -v -d ]dnl
-[$at_debug_args $at_group \${1+\"address@hidden"}"])
+[$at_debug_args $at_group \${1+\"address@hidden"}"]) &&
     echo 'exit 1'
-  } >"$at_group_dir/run"
+  } >"$at_group_dir/run" &&
   chmod +x "$at_group_dir/run"
 }
 
@@ -410,6 +410,8 @@ at_version_p=false
 at_list_p=false
 # Test groups to run
 at_groups=
+# Whether a write failure occurred
+at_write_fail=0
 
 # The directory we are in.
 at_dir=`pwd`
@@ -626,7 +628,7 @@ m4_divert_push([HELP])dnl
 
 # Help message.
 if $at_help_p; then
-  cat <<_ATEOF
+  cat <<_ATEOF || at_write_fail=1
 Usage: $[0] [[OPTION]... [VARIABLE=VALUE]... [TESTS]]
 
 Run all the tests, or the selected TESTS, given by numeric ranges, and
@@ -645,7 +647,7 @@ possibly amounts into
 _ATEOF
 m4_divert_pop([HELP])dnl
 m4_divert_push([HELP_MODES])dnl
-cat <<_ATEOF
+cat <<_ATEOF || at_write_fail=1
 
 Operation modes:
   -h, --help     print the help message, then exit
@@ -655,7 +657,7 @@ Operation modes:
 _ATEOF
 m4_divert_pop([HELP_MODES])dnl
 m4_divert_push([HELP_TUNING])dnl
-cat <<_ATEOF
+cat <<_ATEOF || at_write_fail=1
 
 dnl extra quoting prevents emacs whitespace mode from putting tabs in output
 Execution tuning:
@@ -671,16 +673,16 @@ Execution tuning:
 _ATEOF
 m4_divert_pop([HELP_TUNING])dnl
 m4_divert_push([HELP_END])dnl
-cat <<_ATEOF
+cat <<_ATEOF || at_write_fail=1
 
 Report bugs to <AT_PACKAGE_BUGREPORT>.
 _ATEOF
-  exit 0
+  exit $at_write_fail
 fi
 
 # List of tests.
 if $at_list_p; then
-  cat <<_ATEOF
+  cat <<_ATEOF || at_write_fail=1
 AT_TESTSUITE_NAME test groups:
 
  NUM: FILE-NAME:LINE     TEST-GROUP-NAME
@@ -706,18 +708,18 @@ _ATEOF
             printf " %3d: %-18s %s\n", $ 1, $ 2, $ 3
             if ($ 4) printf "      %s\n", $ 4
           }
-        }'
-  exit 0
+        }' || at_write_fail=1
+  exit $at_write_fail
 fi
 m4_divert_pop([HELP_END])dnl
 m4_divert_push([VERSION])dnl
 if $at_version_p; then
-  AS_ECHO(["$as_me (AT_PACKAGE_STRING)"])
-  cat <<\_ACEOF
+  AS_ECHO(["$as_me (AT_PACKAGE_STRING)"]) &&
+  cat <<\_ACEOF || at_write_fail=1
 m4_divert_pop([VERSION])dnl
 m4_divert_push([VERSION_END])dnl
 _ACEOF
-  exit 0
+  exit $at_write_fail
 fi
 m4_divert_pop([VERSION_END])dnl
 m4_divert_push([PREPARE_TESTS])dnl
@@ -886,8 +888,9 @@ BEGIN { FS="" }
   test = substr ($ 0, 10)
   print "at_sed" test "=\"1," start "d;" (NR-1) "q\""
   if (test == "'"$at_group"'") exit
-}' "$at_myself" > "$at_test_source"
-. "$at_test_source"
+}' "$at_myself" > "$at_test_source" &&
+. "$at_test_source" ||
+  AS_ERROR([cannot create test line number cache])
 
 
 m4_text_box([Driver loop.])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]