Skip to content
Snippets Groups Projects
Commit 20e93304 authored by Simon McVittie's avatar Simon McVittie Committed by Sjoerd Simons
Browse files

run-test-in-systemd: watch output in real-time

This is good for usability, and might also prevent it from detecting
inactivity and killing our tests, which upstream developer Neil Williams
warned me might happen (although I haven't seen it on our installation).

Differential Revision: https://phabricator.apertis.org/D372
Reviewed-by: pwith
parent 8384cf9a
No related branches found
No related tags found
No related merge requests found
......@@ -224,8 +224,10 @@ ${as_target_user} rm -f "${filename}.tmp"
${as_target_user} rm -f "${filename}"
user_log_dir="$(${as_target_user} mktemp -d)"
${as_target_user} touch "${user_log_dir}/stdout.log"
exec_start="${tee_exec} ${user_log_dir}/stdout.log"
# We write the output to a fifo (named pipe) so that we can watch it in
# real-time, below. We start watching it before we start the test.
${as_target_user} mkfifo "${user_log_dir}/stdout.fifo"
exec_start="${tee_exec} ${user_log_dir}/stdout.fifo"
while [ "$#" -gt 0 ]; do
exec_start="${exec_start} $(systemd_escape_argument "$1")"
......@@ -264,6 +266,12 @@ if [ -n "${lava_runes}" ]; then
fi
debug "starting test"
# Watch the output in real time, both for developers' benefit and so that
# LAVA does not think "it has become inactive" and kill us.
${as_target_user} cat "${user_log_dir}/stdout.fifo" &
cat_fifo_pid="$!"
if ${time_adverb} ${systemctl} start ${service}; then
debug "test passed"
result=pass
......@@ -279,14 +287,13 @@ else
fi
fi
debug "getting command output..."
${as_target_user} cat "${user_log_dir}/stdout.log" || result=fail
rm -fr "${user_log_dir}" || result=fail
debug "killing any leftover test processes"
${systemctl} stop ${service} || :
debug "waiting for end-of-file on command output..."
wait "$cat_fifo_pid" || result=fail
rm -fr "${user_log_dir}" || result=fail
if [ -n "${lava_runes}" ]; then
echo "<LAVA_SIGNAL_ENDTC ${name}>"
"lava-test-case" "${name}" --result "${result}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment