summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/integration/framework36
-rwxr-xr-xtest/integration/run-tests64
-rwxr-xr-xtest/integration/skip-bug-601016-description-translation (renamed from test/integration/test-bug-601016-description-translation)0
-rwxr-xr-xtest/integration/skip-ubuntu-bug-784473-InRelease-one-message-only (renamed from test/integration/test-ubuntu-bug-784473-InRelease-one-message-only)0
-rwxr-xr-xtest/integration/skip-ubuntu-bug-859188-multiarch-reinstall (renamed from test/integration/test-ubuntu-bug-859188-multiarch-reinstall)0
5 files changed, 78 insertions, 22 deletions
diff --git a/test/integration/framework b/test/integration/framework
index 13f03a201..9b95434c6 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -1,5 +1,7 @@
#!/bin/sh -- # no runable script, just for vi
+EXIT_CODE=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,12 @@ msgtest() {
}
msgpass() { echo "${CPASS}PASS${CNORMAL}" >&2; }
msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; }
-msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; }
+msgfail() {
+ if [ $# -gt 0 ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2;
+ else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi
+ EXIT_CODE=$((EXIT_CODE+1));
+}
+
# enable / disable Debugging
MSGLEVEL=${MSGLEVEL:-3}
@@ -113,9 +120,32 @@ 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 [ $EXIT_CODE -gt 255 ]; then
+ msgdie "Total failure count $EXIT_CODE too big"
+ fi
+ exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255));
+}
+
+shellsetedetector() {
+ local exit_status=$?
+ if [ "$exit_status" != '0' ]; then
+ printf >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}\n"
+ if [ "$EXIT_CODE" = '0' ]; then
+ EXIT_CODE="$exit_status"
+ fi
+ fi
+}
+
addtrap() {
- CURRENTTRAP="$CURRENTTRAP $1"
- trap "$CURRENTTRAP exit;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+ if [ "$1" = 'prefix' ]; then
+ CURRENTTRAP="$2 $CURRENTTRAP"
+ else
+ CURRENTTRAP="$CURRENTTRAP $1"
+ fi
+ trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
}
setupenvironment() {
diff --git a/test/integration/run-tests b/test/integration/run-tests
index 75f2ad662..c39a2ac68 100755
--- a/test/integration/run-tests
+++ b/test/integration/run-tests
@@ -2,39 +2,65 @@
set -e
FAIL=0
+PASS=0
+ALL=0
+
+FAILED_TESTS=""
DIR=$(readlink -f $(dirname $0))
-if [ "$1" = "-q" ]; then
- export MSGLEVEL=2
-elif [ "$1" = "-v" ]; then
- export MSGLEVEL=4
-fi
+while [ -n "$1" ]; do
+ if [ "$1" = "-q" ]; then
+ export MSGLEVEL=2
+ elif [ "$1" = "-v" ]; then
+ export MSGLEVEL=4
+ elif [ "$1" = '--color=no' ]; then
+ export MSGCOLOR='NO'
+ else
+ echo >&2 "WARNING: Unknown parameter »$1« will be ignored"
+ fi
+ shift
+done
+export MSGLEVEL="${MSGLEVEL:-3}"
-if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null; then
+if [ "$MSGCOLOR" != 'NO' ]; then
+ if [ ! -t 1 ]; then # but check that we output to a terminal
+ export MSGCOLOR='NO'
+ fi
+fi
+if [ "$MSGCOLOR" != 'NO' ]; then
CTEST='\033[1;32m'
CHIGH='\033[1;35m'
CRESET='\033[0m'
-elif [ -z "${MSGLEVEL}" ]; then
- export MSGLEVEL=2
-fi
-
-if [ -z "$MSGLEVEL" ]; then
- MSGLEVEL=5
+else
+ CTEST=''
+ CHIGH=''
+ CRESET=''
fi
+TOTAL="$(run-parts --list $DIR | grep '/test-' | wc -l)"
for testcase in $(run-parts --list $DIR | grep '/test-'); do
if [ "$MSGLEVEL" -le 2 ]; then
- echo -n "${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: "
+ printf "($(($ALL+1))/${TOTAL}) ${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: "
else
- echo "${CTEST}Run Testcase ${CHIGH}$(basename ${testcase})${CRESET}"
+ printf "${CTEST}Run Testcase ($(($ALL+1))/${TOTAL}) ${CHIGH}$(basename ${testcase})${CRESET}\n"
fi
if ! ${testcase}; then
- FAIL=$((FAIL+1))
- echo "$(basename $testcase) ... FAIL"
- fi
+ FAIL=$((FAIL+1))
+ FAILED_TESTS="$FAILED_TESTS $(basename $testcase)"
+ echo >&2 "$(basename $testcase) ... FAIL"
+ else
+ PASS=$((PASS+1))
+ fi
+ ALL=$((ALL+1))
if [ "$MSGLEVEL" -le 2 ]; then
echo
fi
done
-echo "failures: $FAIL"
-exit $FAIL
+echo >&2 "Statistics: $ALL tests were run: $PASS successfully and $FAIL failed"
+if [ -n "$FAILED_TESTS" ]; then
+ echo >&2 "Failed tests: $FAILED_TESTS"
+else
+ echo >&2 'All tests seem to have been run successfully. What could possibly go wrong?'
+fi
+# ensure we don't overflow
+exit $((FAIL <= 255 ? FAIL : 255))
diff --git a/test/integration/test-bug-601016-description-translation b/test/integration/skip-bug-601016-description-translation
index 03fddbfda..03fddbfda 100755
--- a/test/integration/test-bug-601016-description-translation
+++ b/test/integration/skip-bug-601016-description-translation
diff --git a/test/integration/test-ubuntu-bug-784473-InRelease-one-message-only b/test/integration/skip-ubuntu-bug-784473-InRelease-one-message-only
index d97011914..d97011914 100755
--- a/test/integration/test-ubuntu-bug-784473-InRelease-one-message-only
+++ b/test/integration/skip-ubuntu-bug-784473-InRelease-one-message-only
diff --git a/test/integration/test-ubuntu-bug-859188-multiarch-reinstall b/test/integration/skip-ubuntu-bug-859188-multiarch-reinstall
index 0fdf97485..0fdf97485 100755
--- a/test/integration/test-ubuntu-bug-859188-multiarch-reinstall
+++ b/test/integration/skip-ubuntu-bug-859188-multiarch-reinstall