mirror of
https://github.com/systemd/systemd.git
synced 2025-03-01 08:58:29 +03:00
test: properly preserve journal from sd-bsod tests
I (incorrectly) assumed that --relinquish-var does everything --flush does, including moving already existing stuff from /var/log/journal/ to /run/log/journal/, but that's not the case. To actually do that we need to shuffle things manually, so let's do just that. This should make issues like #31334 easier to debug, since with this patch we now have a coredump in the test journal as well: ~# make -C test/TEST-04-JOURNAL/ clean setup run TEST_MATCH_SUBTEST=bsod BUILD_DIR=$PWD/build TEST_NO_NSPAWN=1 ... [ 12.176089] testsuite-04.sh[712]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/testsuite-04.bsod.sh failed' [ 12.176089] testsuite-04.sh[712]: Subtest /usr/lib/systemd/tests/testdata/units/testsuite-04.bsod.sh failed [ 12.176089] testsuite-04.sh[712]: + return 1 [ 12.177347] systemd[1]: testsuite-04.service: Failed with result 'exit-code'. [ 12.220580] systemd[1]: Failed to start testsuite-04.service. Spawning getter /home/mrc0mmand/repos/@systemd/systemd/build/journalctl -o export -D /var/tmp/systemd-tests/systemd-test.Qtqmmr/root/var/log/journal... Finishing after writing 7649 entries TEST-04-JOURNAL: (failed; see logs) -rw-r----- 1 root root 16777216 Feb 15 21:13 /var/tmp/systemd-tests/systemd-test.Qtqmmr/system.journal ... ~# coredumpctl --file /var/tmp/systemd-tests/systemd-test.Qtqmmr/system.journal TIME PID UID GID SIG COREFILE EXE SIZE Thu 2024-02-15 21:13:38 CET 812 0 0 SIGABRT journal /usr/lib/systemd/systemd-bsod -
This commit is contained in:
parent
7ad0a7b2b6
commit
7bd41e63f7
@ -17,8 +17,22 @@ at_exit() {
|
||||
fi
|
||||
|
||||
if mountpoint -q /var/log/journal; then
|
||||
# In order to preserve the journal from the just run test we need to do a little dance, as
|
||||
# --relinquish-var is not a "true" opposite of --flush, meaning that it won't move the existing
|
||||
# journal(s) from /var/log/ to /run/log/. To do that, let's rotate the journal first, so all
|
||||
# important bits are in the archived journal(s)...
|
||||
journalctl --rotate
|
||||
# ...then instruct sd-journald to write further entries to the runtime journal...
|
||||
journalctl --relinquish-var
|
||||
# ...make sure there are no outstanding writes to the persistent journal that might block us from
|
||||
# unmounting the tmpfs...
|
||||
journalctl --sync
|
||||
# ...move the archived journals to the runtime storage...
|
||||
mv -v "/var/log/journal/$(</etc/machine-id)"/system@*.journal "/run/log/journal/$(</etc/machine-id)/"
|
||||
# ...get rid of the tmpfs on /var/log/journal/...
|
||||
umount /var/log/journal
|
||||
# ...and finally flush everything to the "real" persistent journal, so we can collect it after the
|
||||
# test finishes.
|
||||
journalctl --flush
|
||||
fi
|
||||
|
||||
@ -88,6 +102,7 @@ systemctl daemon-reload
|
||||
systemctl start systemd-bsod
|
||||
systemd-cat -p emerg echo "Service emergency message"
|
||||
vcs_dump_and_check "Service emergency message"
|
||||
systemctl status systemd-bsod
|
||||
systemctl stop systemd-bsod
|
||||
|
||||
# Wipe the journal
|
||||
|
Loading…
x
Reference in New Issue
Block a user