mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +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:
parent
7b87fe4c30
commit
7bf20e48bd
@ -39,7 +39,7 @@ check_result_nspawn() {
|
||||
save_journal "$workspace/var/log/journal"
|
||||
_umount_dir "${initdir:?}"
|
||||
|
||||
[[ -n "${TIMED_OUT:=}" ]] && ret=$((ret + 1))
|
||||
[[ -n "${TIMED_OUT:=}" ]] && ret=1
|
||||
return $ret
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ check_result_qemu() {
|
||||
save_journal "$initdir/var/log/journal"
|
||||
_umount_dir "$initdir"
|
||||
|
||||
[[ -n "${TIMED_OUT:=}" ]] && ret=$((ret + 1))
|
||||
[[ -n "${TIMED_OUT:=}" ]] && ret=1
|
||||
return $ret
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ check_result_qemu() {
|
||||
[[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed"
|
||||
echo "${JOURNAL_LIST:-No journals were saved}"
|
||||
|
||||
test -s "$TESTDIR/failed" && ret=$((ret + 1))
|
||||
test -s "$TESTDIR/failed" && ret=1
|
||||
return $ret
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -1118,42 +1118,66 @@ save_journal() {
|
||||
JOURNAL_LIST="$(ls -l "$dest"*)"
|
||||
}
|
||||
|
||||
check_result_nspawn() {
|
||||
check_result_common() {
|
||||
local workspace="${1:?}"
|
||||
local ret=1
|
||||
local journald_report=""
|
||||
local pids=""
|
||||
[[ -e "$workspace/testok" ]] && ret=0
|
||||
[[ -f "$workspace/failed" ]] && cp -a "$workspace/failed" "${TESTDIR:?}"
|
||||
local ret
|
||||
|
||||
if [ -s "$workspace/failed" ]; then
|
||||
# …/failed only counts if non-empty
|
||||
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"
|
||||
[[ -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))
|
||||
|
||||
check_asan_reports "$workspace" || ret=3
|
||||
|
||||
if [ -d "${ARTIFACT_DIRECTORY}" ] && [ -f "$workspace/strace.out" ]; then
|
||||
cp "$workspace/strace.out" "${ARTIFACT_DIRECTORY}/"
|
||||
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:?}"
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
# can be overridden in specific test
|
||||
check_result_qemu() {
|
||||
local ret=1
|
||||
local ret
|
||||
mount_initdir
|
||||
[[ -e "${initdir:?}/testok" ]] && ret=0
|
||||
[[ -f "$initdir/failed" ]] && cp -a "$initdir/failed" "${TESTDIR:?}"
|
||||
save_journal "$initdir/var/log/journal"
|
||||
check_asan_reports "$initdir" || ret=$((ret+1))
|
||||
if [ -d "${ARTIFACT_DIRECTORY}" ] && [ -f "$initdir/strace.out" ]; then
|
||||
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))
|
||||
|
||||
check_result_common "${initdir:?}"
|
||||
ret=$?
|
||||
|
||||
_umount_dir "${initdir:?}"
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
@ -2208,7 +2232,7 @@ instmods() {
|
||||
((ret+=$?))
|
||||
;;
|
||||
esac
|
||||
return $ret
|
||||
return "$ret"
|
||||
}
|
||||
|
||||
local mod mpargs
|
||||
|
Loading…
Reference in New Issue
Block a user