6 if [ "$1" = "-q" ]; then
8 elif [ "$1" = "-v" ]; then
10 elif [ "$1" = '--color=no' ]; then
12 elif [ "$1" = '--color=yes' ]; then
14 elif [ "$1" = '--color' ]; then
15 export MSGCOLOR
="$(echo "$2" | tr 'a-z' 'A-Z')"
17 elif [ "$1" = '--level' ]; then
20 elif [ "$1" = '-j' ]; then
23 elif [ -x "$1" ]; then
26 echo >&2 "WARNING: Unknown parameter »$1« will be ignored"
30 export MSGLEVEL
="${MSGLEVEL:-3}"
32 if [ "${MSGCOLOR:-YES}" = 'YES' ]; then
33 if [ ! -t 1 ]; then # but check that we output to a terminal
37 if [ "$MSGCOLOR" != 'NO' ]; then
47 if [ -n "$TESTTORUN" ]; then
48 # collecting the output of one test to have it together
50 CURRENTTRAP
="rm -f \"$OUTPUT\"; $CURRENTTRAP"
51 trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
53 if [ "$MSGLEVEL" -le 2 ]; then
54 printf "${CTEST}Testcase ${CHIGH}${TESTTORUN##*/}${CRESET}: "
56 printf "${CTEST}Run Testcase ${CHIGH}${TESTTORUN##*/}${CRESET}\n"
58 if ! "$TESTTORUN"; then
60 if [ "$MSGLEVEL" -le 2 ]; then
61 printf >&2 "\n${CHIGH}Running ${TESTTORUN##*/} -> FAILED${CRESET}"
63 echo >&2 "${CHIGH}Running ${TESTTORUN##*/} -> FAILED${CRESET}"
66 if [ "$MSGLEVEL" -le 2 ]; then
70 # without we end up getting stepped output 'randomly'
74 if [ "$FAIL" = 'yes' ]; then
85 DIR
="$(readlink -f "$(dirname "$0")")"
87 TESTLIST="$(find . -mindepth 1 -maxdepth 1 -regex '^\./test-[^/]*$' | sort)"
88 if [ -n "$APT_TEST_JOBS" ]; then
89 if [ "$MSGCOLOR" != 'NO' ]; then
90 export MSGCOLOR='ALWAYS'
93 if command -v moreutils-parallel >/dev/null 2>&1; then
94 parallel=moreutils-parallel
96 exec $parallel -j "$APT_TEST_JOBS" ".
/$(basename "$0")" -- $(echo "$TESTLIST")
98 TOTAL="$(echo "$TESTLIST" | wc -l)"
99 for testcase in $TESTLIST; do
100 if [ "$MSGLEVEL" -le 2 ]; then
101 printf "($(($ALL+1))/${TOTAL}) ${CTEST}Testcase
${CHIGH}${testcase##*/}${CRESET}: "
103 printf "${CTEST}Run Testcase
($(($ALL+1))/${TOTAL}) ${CHIGH}${testcase##*/}${CRESET}\n"
105 if ! ${testcase}; then
107 FAILED_TESTS="$FAILED_TESTS ${testcase##*/}"
108 if [ "$MSGLEVEL" -le 2 ]; then
109 printf >&2 "\n${CHIGH}Running
${testcase##*/} -> FAILED
${CRESET}"
111 echo >&2 "${CHIGH}Running
${testcase##*/} -> FAILED
${CRESET}"
117 if [ "$MSGLEVEL" -le 2 ]; then
122 echo >&2 "Statistics
: $ALL tests were run
: $PASS successfully and
$FAIL failed
"
123 if [ -n "$FAILED_TESTS" ]; then
124 echo >&2 "Failed tests
: $FAILED_TESTS"
126 echo >&2 'All tests seem to have been run successfully. What could possibly go wrong?'
128 # ensure we don't overflow
129 exit $((FAIL <= 255 ? FAIL : 255))