1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 19:52:20 +00:00

shtests: make tests more interruptable with Ctrl+C

Sometimes you have to put ^C on rapid repeat to get out of running
the tests. This is because each test scripts is launch as a child
shell (not a subshell) in the foreground, which thus handle the ^C.
It then exits with a status indicating SIGINT, but the shtest script
wasn't handling this and just kept going.

src/cmd/ksh93/tests/shtests:
- For reasons I don't understand yet, interrupting tests with ^C
  tends to make them exit with status 130 (128+2) instead of what
  I would expect for ksh93, 258 (256+2). Not a big deal: POSIX
  specifies that any exit > 128 signifies a signal in any case,
  and 'kill -l' works even on those values. But the checks need
  changing to '> 128'.
- Check each result for SIGINT, and issue SIGINT to self if found.

(cherry picked from commit d0dfb37c6c71ac7b157060249125e0959130927d)
This commit is contained in:
Martijn Dekker 2020-06-11 00:19:03 +02:00
parent 102868f850
commit 9cef2d534a

View file

@ -346,7 +346,7 @@ do [[ $i == *.sh ]] || i+='.sh'
then valxml $valxml
(( e += $? ))
fi
if (( e > 256 && ++total_e ))
if (( e > 128 && ++total_e ))
then E="(killed by SIG$(kill -l "$e"))"
elif (( e == 1 && ++total_e ))
then E="1 error"
@ -357,6 +357,9 @@ do [[ $i == *.sh ]] || i+='.sh'
then echo test $o passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T $E ]"
else echo test $o failed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ $t $T $E ]"
fi
case $E in
*INT\)) kill -s INT $$ ;; # if test was ^C'd, don't keep going but pass down SIGINT
esac
done
fi
if (( compile ))
@ -367,7 +370,7 @@ 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 && ++total_e ))
if (( e > 128 && ++total_e ))
then E="(killed by SIG$(kill -l "$e"))"
elif (( e == 1 && ++total_e ))
then E="1 error"
@ -375,6 +378,9 @@ do [[ $i == *.sh ]] || i+='.sh'
(( total_e += e ))
fi
echo test $o failed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ $t $T $E ]"
case $E in
*INT\)) kill -s INT $$ ;; # if test was ^C'd, don't keep going but pass down SIGINT
esac
fi
else e=$?
(( ++total_e ))