diff options
author | G. Branden Robinson <g.branden.robinson@gmail.com> | 2022-12-19 19:06:05 -0600 |
---|---|---|
committer | G. Branden Robinson <g.branden.robinson@gmail.com> | 2022-12-19 20:38:48 -0600 |
commit | 59efbfc364daee11af9207a3fc79675b6f5bfc25 (patch) | |
tree | 052fa4ce1cc93627fc2e0a803ee9407ab2a4f746 /src/roff | |
parent | 6ea8d851fac5bb0c879863a46785784a192d82ee (diff) | |
download | groff-git-59efbfc364daee11af9207a3fc79675b6f5bfc25.tar.gz |
[tests]: Fix potential problem(s) in trap handler.
* src/roff/groff/tests/smoke-test_html_device.sh: Move call of `cleanup`
function from end of script to after the tests that generate temporary
files have been run, and before script possibly exits with status 77
to skip some checks. Within trap handler, mask trapped signals while
running handler.
(cleanup): Reset trap dispositions to default after removing files;
once the temporary files are gone, we no longer need a trap handler.
One might already be running however, and this ensures that its
"suicide" ("kill -s INT $$") will succeed.
This delicate dance is why I try not to create temporary files in test
scripts. But grohtml does it for us, so we have to cope. (Not so
temporary, in fact--you have to keep them around if you want to view the
HTML document produced.)
(To test this stuff, add a "sleep" built-in before the "cleanup" in the
main logic of the script, and kill it.)
Diffstat (limited to 'src/roff')
-rwxr-xr-x | src/roff/groff/tests/smoke-test_html_device.sh | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/roff/groff/tests/smoke-test_html_device.sh b/src/roff/groff/tests/smoke-test_html_device.sh index 63fb27a8b..efdaa0449 100755 --- a/src/roff/groff/tests/smoke-test_html_device.sh +++ b/src/roff/groff/tests/smoke-test_html_device.sh @@ -29,9 +29,10 @@ wail () { cleanup () { rm -f grohtml-[0-9]*-[12].png + trap - HUP INT QUIT TERM } -trap 'trap - HUP INT QUIT TERM; cleanup; kill -s INT $$' \ +trap 'trap "" HUP INT QUIT TERM; cleanup; kill -s INT $$' \ HUP INT QUIT TERM input='.TS @@ -53,6 +54,8 @@ echo "checking production of inline image for eqn(1) equation" >&2 output=$(echo "$input" | "$groff" -e -Thtml) echo "$output" | grep -q '<img src="grohtml-[0-9]\+-2.png"' || wail +cleanup + # We can't run remaining tests if the environment doesn't support UTF-8. test "$(locale charmap)" = UTF-8 || exit 77 # skip @@ -71,7 +74,6 @@ echo "checking -C -k -Thtml" >&2 printf "\('a" | "$groff" -C -k -Thtml | grep -qx '<p>á</p>' \ || wail -cleanup test -z "$fail" # vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72: |