testsuite instrumentation fixes by Christian
authorDenis Vlasenko <vda.linux@googlemail.com>
Thu, 15 May 2008 22:43:48 +0000 (22:43 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Thu, 15 May 2008 22:43:48 +0000 (22:43 -0000)
testsuite/runtest
testsuite/testing.sh

index d9de8799f66e3ed4f6b2920a32d029fb85f0f870..624de8fde242fb269ae988a283ebe2bc1fc11bf3 100755 (executable)
@@ -12,7 +12,7 @@ run_applet_testcase()
        local applet="$1"
        local testcase="$2"
 
-       local status
+       local status=0
        local uc_applet=$(echo "$applet" | tr a-z A-Z)
        local testname="$testcase"
 
@@ -36,8 +36,8 @@ run_applet_testcase()
        cd ".tmpdir.$applet" || return 1
 
 #      echo "Running testcase $testcase"
-       d="$tsdir" sh -x -e "$testcase" >"$testname.stdout.txt" 2>&1
-       status=$?
+       d="$tsdir" \
+               sh -x -e "$testcase" >"$testname.stdout.txt" 2>&1 || status=$?
        if [ $status -ne 0 ]; then
                echo "FAIL: $testname"
                if [ x"$VERBOSE" != x ]; then
@@ -69,8 +69,7 @@ run_oldstyle_applet_tests()
                        *.mine) continue ;;    # svn-produced junk
                        *.r[0-9]*) continue ;; # svn-produced junk
                esac
-               run_applet_testcase "$applet" "$testcase"
-               test $? -eq 0 || status=1
+               run_applet_testcase "$applet" "$testcase" || status=1
        done
        return $status
 }
@@ -125,8 +124,7 @@ status=0
 for applet in $applets; do
        # Any old-style tests for this applet?
        if [ -d "$tsdir/$applet" ]; then
-               run_oldstyle_applet_tests "$applet"
-               test $? -eq 0 || status=1
+               run_oldstyle_applet_tests "$applet" || status=1
        fi
 
        # Is this a new-style test?
@@ -139,8 +137,8 @@ for applet in $applets; do
                        fi
                fi
 #              echo "Running test $tsdir/$applet.tests"
-               PATH="$LINKSDIR:$tsdir:$bindir:$PATH" "$tsdir/$applet.tests"
-               test $? -eq 0 || status=1
+               PATH="$LINKSDIR:$tsdir:$bindir:$PATH" \
+                       "$tsdir/$applet.tests" || status=1
        fi
 done
 
index 028d09a280e8c1e29b83de039907b7bd4be8b829..ea59f317a61505f54030f7f339c2206a972dff73 100755 (executable)
@@ -37,7 +37,7 @@ export FAILCOUNT=0
 export SKIP=
 
 # Helper for helpers. Oh my...
-test x"$ECHO" = x"" && {
+test x"$ECHO" != x"" || {
        ECHO="echo"
        test x"`echo -ne`" = x"" || {
                # Compile and use a replacement 'echo' which understands -e -n
@@ -68,15 +68,15 @@ optional()
 testing()
 {
   NAME="$1"
-  [ -z "$1" ] && NAME="$2"
+  [ -n "$1" ] || NAME="$2"
 
   if [ $# -ne 5 ]
   then
     echo "Test $NAME has wrong number of arguments (must be 5) ($# $*)" >&2
-    exit
+    exit 1
   fi
 
-  [ -n "$DEBUG" ] && set -x
+  [ -z "$DEBUG" ] || set -x
 
   if [ -n "$SKIP" ]
   then
@@ -90,18 +90,17 @@ testing()
   $ECHO -ne "$5" | eval "$2" > actual
   RETVAL=$?
 
-  cmp expected actual >/dev/null 2>/dev/null
-  if [ $? -ne 0 ]
+  if cmp expected actual >/dev/null 2>/dev/null
   then
+    echo "PASS: $NAME"
+  else
     FAILCOUNT=$(($FAILCOUNT + 1))
     echo "FAIL: $NAME"
-    [ -n "$VERBOSE" ] && diff -u expected actual
-  else
-    echo "PASS: $NAME"
+    [ -z "$VERBOSE" ] || diff -u expected actual
   fi
   rm -f input expected actual
 
-  [ -n "$DEBUG" ] && set +x
+  [ -z "$DEBUG" ] || set +x
 
   return $RETVAL
 }