Skip to content

Commit

Permalink
shtests: make tests more interruptable with Ctrl+C
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
McDutchie committed Jun 11, 2020
1 parent 102868f commit 9cef2d5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cmd/ksh93/tests/shtests
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 ))
Expand All @@ -367,14 +370,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 && ++total_e ))
if (( e > 128 && ++total_e ))
then E="(killed by SIG$(kill -l "$e"))"
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 ]"
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 ))
Expand Down

0 comments on commit 9cef2d5

Please sign in to comment.