mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
test: optionally, only save test journal for failing tests
Saving the journal for passing tests creates a huge amount of unneeded data stored for each full test run. Add a env var to allow saving the journal only for failed tests.
This commit is contained in:
parent
5f9fa7a5f3
commit
d3b8e38409
@ -1117,6 +1117,15 @@ check_asan_reports() {
|
||||
}
|
||||
|
||||
save_journal() {
|
||||
# Default to always saving journal
|
||||
local save="yes"
|
||||
|
||||
if [ "${TEST_SAVE_JOURNAL}" = "no" ]; then
|
||||
save="no"
|
||||
elif [ "${TEST_SAVE_JOURNAL}" = "fail" ] && [ "$2" = "0" ]; then
|
||||
save="no"
|
||||
fi
|
||||
|
||||
if [ -n "${ARTIFACT_DIRECTORY}" ]; then
|
||||
dest="${ARTIFACT_DIRECTORY}/${testname:?}.journal"
|
||||
else
|
||||
@ -1124,9 +1133,9 @@ save_journal() {
|
||||
fi
|
||||
|
||||
for j in "${1:?}"/*; do
|
||||
"$SYSTEMD_JOURNAL_REMOTE" \
|
||||
-o "$dest" \
|
||||
--getter="$JOURNALCTL -o export -D $j"
|
||||
if [ "$save" = "yes" ]; then
|
||||
"$SYSTEMD_JOURNAL_REMOTE" -o "$dest" --getter="$JOURNALCTL -o export -D $j"
|
||||
fi
|
||||
|
||||
if [ -n "${TEST_SHOW_JOURNAL}" ]; then
|
||||
echo "---- $j ----"
|
||||
@ -1136,6 +1145,10 @@ save_journal() {
|
||||
rm -r "$j"
|
||||
done
|
||||
|
||||
if [ "$save" != "yes" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ -n "${SUDO_USER}" ]; then
|
||||
setfacl -m "user:${SUDO_USER:?}:r-X" "$dest"*
|
||||
fi
|
||||
@ -1171,10 +1184,10 @@ check_result_common() {
|
||||
ret=3
|
||||
fi
|
||||
|
||||
save_journal "$workspace/var/log/journal"
|
||||
|
||||
check_asan_reports "$workspace" || ret=4
|
||||
|
||||
save_journal "$workspace/var/log/journal" $ret
|
||||
|
||||
if [ -d "${ARTIFACT_DIRECTORY}" ] && [ -f "$workspace/strace.out" ]; then
|
||||
cp "$workspace/strace.out" "${ARTIFACT_DIRECTORY}/"
|
||||
fi
|
||||
@ -1252,10 +1265,12 @@ check_result_nspawn_unittests() {
|
||||
fi
|
||||
fi
|
||||
|
||||
save_journal "$workspace/var/log/journal"
|
||||
[[ -n "${TIMED_OUT:=}" ]] && ret=1
|
||||
|
||||
save_journal "$workspace/var/log/journal" $ret
|
||||
|
||||
_umount_dir "${initdir:?}"
|
||||
|
||||
[[ -n "${TIMED_OUT:=}" ]] && ret=1
|
||||
return $ret
|
||||
}
|
||||
|
||||
@ -1282,10 +1297,12 @@ check_result_qemu_unittests() {
|
||||
fi
|
||||
fi
|
||||
|
||||
save_journal "$initdir/var/log/journal"
|
||||
[[ -n "${TIMED_OUT:=}" ]] && ret=1
|
||||
|
||||
save_journal "$initdir/var/log/journal" $ret
|
||||
|
||||
_umount_dir "$initdir"
|
||||
|
||||
[[ -n "${TIMED_OUT:=}" ]] && ret=1
|
||||
return $ret
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user