1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 11:42:21 +00:00

shtests: report total errors on terminal and in exit status

Setting the exit status allows build scripts and the like
to actually detect regression test failures.

src/cmd/ksh93/tests/shtests:
- Add counter for total number of errors.
- Report total to stdout at the end.
- Set the exit status to the total number of errors, up to 125
  (higher statuses have special meanings).

(cherry picked from commit c0dd80b14d4d316b4e9eff4b1b67d4e47f23a6ba)
This commit is contained in:
Martijn Dekker 2020-06-09 03:09:45 +02:00
parent fb652a7e50
commit c2eabc57e0

View file

@ -307,6 +307,7 @@ then if [[ -x $SHELL-g ]]
valgrind+=" --xml-file=$valxml"
fi
typeset -A tests
typeset -i total_e=0
for i in ${*-*.sh}
do [[ $i == *.sh ]] || i+='.sh'
if [[ ! -r $i ]]
@ -345,11 +346,12 @@ do [[ $i == *.sh ]] || i+='.sh'
then valxml $valxml
(( e += $? ))
fi
if (( e > 256 ))
if (( e > 256 && ++total_e ))
then E="(killed by SIG$(kill -l "$e"))"
elif (( e == 1 ))
elif (( e == 1 && ++total_e ))
then E="1 error"
else E="$e errors"
(( total_e += e ))
fi
if (( e == 0 ))
then echo test $o passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T $E ]"
@ -365,15 +367,17 @@ do [[ $i == *.sh ]] || i+='.sh'
then if $valgrind $SHELL $trace $c
then echo test $o passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T 0 errors ]"
else e=$?
if (( e > 256 ))
if (( e > 256 && ++total_e ))
then E="(killed by SIG$(kill -l "$e"))"
elif (( e == 1 ))
elif (( e == 1 && ++total_e ))
then E="1 error"
else E="$e errors"
(( total_e += e ))
fi
echo test $o failed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ $t $T $E ]"
fi
else e=$?
(( ++total_e ))
echo test $o failed to compile ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ 1 test 1 error ]"
fi
if [[ $i == $timesensitive ]]
@ -381,3 +385,5 @@ do [[ $i == *.sh ]] || i+='.sh'
fi
fi
done
print "Total errors: $total_e"
exit $((total_e > 125 ? 125 : total_e))