autoconf-patches
[Top][All Lists]
Advanced

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

[PATCH] use shell functions to check exit codes


From: Paolo Bonzini
Subject: [PATCH] use shell functions to check exit codes
Date: Fri, 5 Oct 2007 09:55:14 +0200

This patch abstract the case statements used to check exit codes
into two shell functions (one for exit code `ignore', and one for
the others).

2007-10-04  Paolo Bonzini  <address@hidden>

        * general.m4 (AT_INIT): Add at_check_skip and at_check_status
        shell functions.
        (_AT_CHECK): Use them.
---
 ChangeLog               |    6 ++++++
 lib/autotest/general.m4 |   29 +++++++++++++++++------------
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index beed88c..3de93df 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -240,6 +240,22 @@ at_log_failure ()
   exit 1
 }
 
+at_check_skip () {
+  case $[1] in
+    77) echo 77 > "$at_status_file"; exit 77;;
+  esac
+}
+
+at_check_status () {
+dnl This order ensures that we don't `skip' if we are precisely checking $? = 
77.
+  case $[2] in
+    $[1] ) ;;
+    77) echo 77 > "$at_status_file"; exit 77;;
+    *) AS_ECHO(["$[3]: exit code was $[2], expected $[1]"])
+      at_failed=:;;
+  esac
+}
+
 # Load the config file.
 for at_file in atconfig atlocal
 do
@@ -1525,18 +1541,7 @@ m4_case([$3],
        expout, [$at_diff expout "$at_stdout" || at_failed=:],
        [],     [$at_diff "$at_devnull" "$at_stdout" || at_failed=:],
        [echo >>"$at_stdout"; 
AS_ECHO(["m4_ifval([$7],[AS_ESCAPE([$3])],[$3])"]) | $at_diff - "$at_stdout" || 
at_failed=:])
-dnl Check exit val.  Don't `skip' if we are precisely checking $? = 77.
-case $at_status in
-m4_if([$2], [77],
-    [],
-    [   77) echo 77 > "$at_status_file"; exit 77;;
-])dnl
-m4_if([$2], [ignore],
-    [   *);;],
-    [   m4_default([$2], [0])) ;;
-   *) AS_ECHO(["$at_srcdir/AT_LINE: exit code was $at_status, expected 
m4_default([$2], [0])"])
-      at_failed=:;;])
-esac
+m4_if([$2], [ignore], [at_check_skip], [at_check_status m4_default([$2], 
[0])]) $at_status "$at_srcdir/AT_LINE"
 AS_IF($at_failed, [$5], [$6])
 $at_failed && at_log_failure AT_capture_files
 $at_traceon
-- 
1.5.2.4





reply via email to

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