diff tests/test-utils.sh @ 54:f258a0258755

Just testing for failure exit codes doesn't distinguish between a clean error exit and a segfault. Define a shell function for clean error exit, and use it everywhere.
author mas01cr
date Thu, 20 Sep 2007 09:52:16 +0000
parents a7aad4c50cb9
children e64a2e7f543c
line wrap: on
line diff
--- a/tests/test-utils.sh	Thu Sep 20 08:50:35 2007 +0000
+++ b/tests/test-utils.sh	Thu Sep 20 09:52:16 2007 +0000
@@ -11,6 +11,18 @@
 # encode.  This might involve writing some C code, as Bash doesn't do
 # Floating Point.  (scanf() is probably enough).
 
+expect_clean_error_exit() {
+  trap - ERR
+  "$@"
+  exit_code=$?
+  trap "exit 1" ERR
+  if [ $exit_code -eq 0 ]; then
+    exit 1
+  elif [ $exit_code -ge 126 ]; then
+    exit 1
+  fi
+}
+
 floatstring() {
   for arg in "$@"; do
     case ${arg} in