Commit 8727c886 authored by Andrew Jones's avatar Andrew Jones Committed by Radim Krčmář
Browse files

runtime: better handling of QEMU aborts



Add two changes to run_qemu. The first saves/restores terminal settings.
This solves an annoying loss of terminal echo when QEMU aborts during
a test run. The second ensures we see a message about the abort, because
the "Aborted (core dumped)" message we should see gets eaten. We also
add a message to run()'s failure cases in its exit code processing to
handle signals in general.

Note, the first change is necessary because QEMU modifies the terminal
settings when using '-serial stdio', but calling abort() invokes exit
without first calling qemu_chr_free(serial_hds[0]) to restore them.

(Additionally we fixup the premature failure check to only capture the
 last line, like it says it's doing.)
Reported-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrew Jones's avatarAndrew Jones <drjones@redhat.com>
[Redirected the abort message to stderr and moved it below `stty`.]
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent f0ca153c
......@@ -26,13 +26,17 @@
##############################################################################
run_qemu ()
{
local stdout errors ret sig
local stdout errors ret sig tty
# stdout to {stdout}, stderr to $errors and stderr
tty=$(stty -g)
exec {stdout}>&1
errors=$("${@}" 2> >(tee /dev/stderr) > /dev/fd/$stdout)
ret=$?
exec {stdout}>&-
stty "$tty"
[ $ret -eq 134 ] && echo "QEMU Aborted" >&2
if [ "$errors" ]; then
sig=$(grep 'terminating on signal' <<<"$errors")
......
......@@ -92,7 +92,7 @@ function run()
fi
done
last_line=$(premature_failure) && {
last_line=$(premature_failure > >(tail -1)) && {
echo "`SKIP` $1 ($last_line)"
return 77
}
......@@ -115,6 +115,8 @@ function run()
echo "`SKIP` $1 $summary"
elif [ $ret -eq 124 ]; then
echo "`FAIL` $1 (timeout; duration=$timeout)"
elif [ $ret -gt 127 ]; then
echo "`FAIL` $1 (terminated on SIG$(kill -l $(($ret - 128))))"
else
echo "`FAIL` $1 $summary"
fi
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment