]> git.saurik.com Git - apt.git/commitdiff
report failures via exit and ensure we don't overflow
authorMichael Vogt <michael.vogt@ubuntu.com>
Mon, 18 Mar 2013 10:38:19 +0000 (11:38 +0100)
committerMichael Vogt <michael.vogt@ubuntu.com>
Mon, 18 Mar 2013 10:38:19 +0000 (11:38 +0100)
test/integration/framework
test/integration/run-tests

index 883b65bba0f1044b7a970e030ab4786c9f0bc2fe..cdaa20627edaf12e89413738ac0b64857f97f395 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh -- # no runable script, just for vi
 
-TESTFAILURES="no"
+TESTFAILURES=0
 
 # we all like colorful messages
 if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null && \
@@ -38,7 +38,7 @@ msgtest() {
 }
 msgpass() { echo "${CPASS}PASS${CNORMAL}" >&2; }
 msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; }
-msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; TESTFAILURES="yes"; }
+msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; TESTFAILURES=$((TESTFAILURES+1)); }
 
 # enable / disable Debugging
 MSGLEVEL=${MSGLEVEL:-3}
@@ -116,7 +116,12 @@ gdb() {
 }
 
 exitwithstatus() {
-       [ "$TESTFAILURES" = "yes" ] && exit 1 || exit 0;
+        # error if we about to overflow, but ...
+        #   "255 failures ought to be enough for everybody"
+        if [ $TESTFAILURES -gt 255 ]; then
+            msgdie "Total failure count $TESTFAILURES too big"
+        fi
+        exit $((TESTFAILURES <= 255 ? TESTFAILURES : 255));
 }
 
 addtrap() {
index 75f2ad66224b65b440d67b4fb19ac38be05efd88..18474b20f6a3dd67c0163c6bdcaf3b0b991a036a 100755 (executable)
@@ -37,4 +37,5 @@ for testcase in $(run-parts --list $DIR | grep '/test-'); do
 done
 
 echo "failures: $FAIL"
-exit $FAIL
+# ensure we don't overflow
+exit $((FAIL <= 255 ? FAIL : 255))