test: correctly clean up test artifacts

Remove the artifact files indicating test result (testok, failed, and
skipped) just before running the test so we always get the latest and
most relevant result instead of incorrectly consuming previous results.

Discovered in https://github.com/systemd/systemd/pull/15378#issuecomment-616801873
This commit is contained in:
Frantisek Sumsal 2020-04-21 13:18:36 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent f6f4f5fe53
commit 80b44b38b5

View file

@ -234,6 +234,7 @@ run_qemu() {
CONSOLE=ttyS0 CONSOLE=ttyS0
rm -f "$initdir"/{testok,failed,skipped}
# make sure the initdir is not mounted to avoid concurrent access # make sure the initdir is not mounted to avoid concurrent access
cleanup_initdir cleanup_initdir
umount_loopback umount_loopback
@ -362,6 +363,7 @@ $QEMU_OPTIONS \
# success), or 1 if nspawn is not available. # success), or 1 if nspawn is not available.
run_nspawn() { run_nspawn() {
[[ -d /run/systemd/system ]] || return 1 [[ -d /run/systemd/system ]] || return 1
rm -f "$initdir"/{testok,failed,skipped}
local _nspawn_cmd=( local _nspawn_cmd=(
--register=no --register=no
@ -2014,7 +2016,6 @@ test_setup() {
test_run() { test_run() {
mount_initdir mount_initdir
rm -f "$initdir"/{testok,failed,skipped}
if [ -z "$TEST_NO_QEMU" ]; then if [ -z "$TEST_NO_QEMU" ]; then
if run_qemu "$1"; then if run_qemu "$1"; then