1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-11 20:58:27 +03:00

test: move the logic to support /skipped into shared logic

The logic to query test state was rather complex. I don't quite grok the point
of ret=$((ret+1))… But afaics, the precise result was always ignored by the
caller anyway.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-04-23 10:55:49 +02:00
parent 7b87fe4c30
commit 7bf20e48bd
4 changed files with 52 additions and 76 deletions

View File

@ -39,7 +39,7 @@ check_result_nspawn() {
save_journal "$workspace/var/log/journal" save_journal "$workspace/var/log/journal"
_umount_dir "${initdir:?}" _umount_dir "${initdir:?}"
[[ -n "${TIMED_OUT:=}" ]] && ret=$((ret + 1)) [[ -n "${TIMED_OUT:=}" ]] && ret=1
return $ret return $ret
} }
@ -67,7 +67,7 @@ check_result_qemu() {
save_journal "$initdir/var/log/journal" save_journal "$initdir/var/log/journal"
_umount_dir "$initdir" _umount_dir "$initdir"
[[ -n "${TIMED_OUT:=}" ]] && ret=$((ret + 1)) [[ -n "${TIMED_OUT:=}" ]] && ret=1
return $ret return $ret
} }

View File

@ -26,7 +26,7 @@ check_result_qemu() {
[[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed" [[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed"
echo "${JOURNAL_LIST:-No journals were saved}" echo "${JOURNAL_LIST:-No journals were saved}"
test -s "$TESTDIR/failed" && ret=$((ret + 1)) test -s "$TESTDIR/failed" && ret=1
return $ret return $ret
} }

View File

@ -19,52 +19,4 @@ EOF
) )
} }
check_result_nspawn() {
local workspace="${1:?}"
local ret=1
local journald_report=""
local pids=""
[[ -e "$workspace/testok" ]] && ret=0
if [[ -e "$workspace/skipped" ]]; then
echo "TEST-56-OOMD was skipped:"
cat "$workspace/skipped"
ret=0
fi
[[ -f "$workspace/failed" ]] && cp -a "$workspace/failed" "${TESTDIR:?}"
save_journal "$workspace/var/log/journal"
[[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed"
echo "${JOURNAL_LIST:-No journals were saved}"
test -s "$TESTDIR/failed" && ret=$((ret + 1))
[ -n "${TIMED_OUT:=}" ] && ret=$((ret + 1))
check_asan_reports "$workspace" || ret=$((ret + 1))
_umount_dir "${initdir:?}"
return $ret
}
check_result_qemu() {
local ret=1
mount_initdir
[[ -e "${initdir:?}/testok" ]] && ret=0
if [[ -e "$initdir/skipped" ]]; then
echo "TEST-56-OOMD was skipped:"
cat "$initdir/skipped"
ret=0
fi
[[ -f "$initdir/failed" ]] && cp -a "$initdir/failed" "${TESTDIR:?}"
save_journal "$initdir/var/log/journal"
check_asan_reports "$initdir" || ret=$((ret + 1))
_umount_dir "$initdir"
[[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed"
echo "${JOURNAL_LIST:-No journals were saved}"
test -s "$TESTDIR/failed" && ret=$((ret + 1))
[ -n "${TIMED_OUT:=}" ] && ret=$((ret + 1))
return $ret
}
do_test "$@" 55 do_test "$@" 55

View File

@ -1118,42 +1118,66 @@ save_journal() {
JOURNAL_LIST="$(ls -l "$dest"*)" JOURNAL_LIST="$(ls -l "$dest"*)"
} }
check_result_nspawn() { check_result_common() {
local workspace="${1:?}" local workspace="${1:?}"
local ret=1 local ret
local journald_report=""
local pids="" if [ -s "$workspace/failed" ]; then
[[ -e "$workspace/testok" ]] && ret=0 # …/failed only counts if non-empty
[[ -f "$workspace/failed" ]] && cp -a "$workspace/failed" "${TESTDIR:?}" ls -l "$workspace/failed"
cp -a "$workspace/failed" "${TESTDIR:?}/"
ret=1
elif [ -e "$workspace/testok" ]; then
# …/testok always counts (but with lower priority than …/failed)
ret=0
elif [ -e "$workspace/skipped" ]; then
# …/skipped always counts (a message is expected)
echo "${TESTNAME:?} was skipped:"
cat "$workspace/skipped"
ret=0
elif [ -n "$TIMED_OUT" ]; then
echo "${TESTNAME:?} timed out!"
ret=2
else
echo "${TESTNAME:?} did not report a result!"
fi
save_journal "$workspace/var/log/journal" save_journal "$workspace/var/log/journal"
[[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed"
echo "${JOURNAL_LIST:-"No journals were saved"}" check_asan_reports "$workspace" || ret=3
test -s "$TESTDIR/failed" && ret=$((ret+1))
[ -n "$TIMED_OUT" ] && ret=$((ret+1))
check_asan_reports "$workspace" || ret=$((ret+1))
if [ -d "${ARTIFACT_DIRECTORY}" ] && [ -f "$workspace/strace.out" ]; then if [ -d "${ARTIFACT_DIRECTORY}" ] && [ -f "$workspace/strace.out" ]; then
cp "$workspace/strace.out" "${ARTIFACT_DIRECTORY}/" cp "$workspace/strace.out" "${ARTIFACT_DIRECTORY}/"
fi fi
[ -f "$TESTDIR/failed" ] && cat "$TESTDIR/failed"
echo "${JOURNAL_LIST:-"No journals were saved"}"
return $ret
}
check_result_nspawn() {
local workspace="${1:?}"
local ret
check_result_common "${workspace}"
ret=$?
_umount_dir "${initdir:?}" _umount_dir "${initdir:?}"
return $ret return $ret
} }
# can be overridden in specific test # can be overridden in specific test
check_result_qemu() { check_result_qemu() {
local ret=1 local ret
mount_initdir mount_initdir
[[ -e "${initdir:?}/testok" ]] && ret=0
[[ -f "$initdir/failed" ]] && cp -a "$initdir/failed" "${TESTDIR:?}" check_result_common "${initdir:?}"
save_journal "$initdir/var/log/journal" ret=$?
check_asan_reports "$initdir" || ret=$((ret+1))
if [ -d "${ARTIFACT_DIRECTORY}" ] && [ -f "$initdir/strace.out" ]; then _umount_dir "${initdir:?}"
cp "$initdir/strace.out" "${ARTIFACT_DIRECTORY}/"
fi
_umount_dir "$initdir"
[[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed"
echo "${JOURNAL_LIST:-"No journals were saved"}"
test -s "$TESTDIR/failed" && ret=$((ret+1))
[ -n "$TIMED_OUT" ] && ret=$((ret+1))
return $ret return $ret
} }
@ -2208,7 +2232,7 @@ instmods() {
((ret+=$?)) ((ret+=$?))
;; ;;
esac esac
return $ret return "$ret"
} }
local mod mpargs local mod mpargs