]> git.saurik.com Git - apt.git/blobdiff - test/integration/framework
report failures via exit and ensure we don't overflow
[apt.git] / test / integration / framework
index 1c4872c8e148076256af7365bb1be6f51c41ae08..cdaa20627edaf12e89413738ac0b64857f97f395 100644 (file)
@@ -1,5 +1,7 @@
 #!/bin/sh -- # no runable script, just for vi
 
+TESTFAILURES=0
+
 # we all like colorful messages
 if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null && \
    expr match "$(readlink -f /proc/$$/fd/2)" '/dev/pts/[0-9]\+' > /dev/null; then
@@ -36,7 +38,7 @@ msgtest() {
 }
 msgpass() { echo "${CPASS}PASS${CNORMAL}" >&2; }
 msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; }
-msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; }
+msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; TESTFAILURES=$((TESTFAILURES+1)); }
 
 # enable / disable Debugging
 MSGLEVEL=${MSGLEVEL:-3}
@@ -113,9 +115,18 @@ gdb() {
        APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which gdb) ${BUILDDIRECTORY}/$1
 }
 
+exitwithstatus() {
+        # 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() {
        CURRENTTRAP="$CURRENTTRAP $1"
-       trap "$CURRENTTRAP exit;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+       trap "$CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
 }
 
 setupenvironment() {