]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-87-AUX-UTILS-VM: make coredumps stored in archived journal file
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 28 Jul 2025 07:40:27 +0000 (16:40 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 4 Aug 2025 15:41:22 +0000 (16:41 +0100)
Fixes the following race:
```
TEST-87-AUX-UTILS-VM.sh[839]: + coredumpctl -1
TEST-87-AUX-UTILS-VM.sh[1169]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
TEST-87-AUX-UTILS-VM.sh[1169]: Sun 2025-07-27 23:22:02 UTC 885   0   0 SIGABRT present  /tmp/test-dump 19.9K
TEST-87-AUX-UTILS-VM.sh[839]: + coredumpctl -n 1
TEST-87-AUX-UTILS-VM.sh[1172]: Journal file /var/log/journal/a8285330872602d1377cbaaf68869946/system.journal is truncated, ignoring file.
TEST-87-AUX-UTILS-VM.sh[1172]: No coredumps found.
```

(cherry picked from commit ab56a96194d102cb4ec279fc4eb181d16c1251ea)

test/units/TEST-87-AUX-UTILS-VM.coredump.sh

index 5b3a148ca57e9bd218da5e1a33dd6c4efca48904..23be2c44a345f3ed28239a231b0d3c3106e1aa21 100755 (executable)
@@ -23,7 +23,8 @@ at_exit() {
 
 trap at_exit EXIT
 
-# To make all coredump entries stored in system.journal.
+# Sync and rotate journal to make all coredump entries stored in system.journal.
+journalctl --sync
 journalctl --rotate
 
 # Check that we're the ones to receive coredumps
@@ -109,6 +110,16 @@ EOF
     unset CONTAINER
 fi
 
+# Sync and rotate journals (again) to make coredumps stored in archived journal. Otherwise, the main active
+# journal file may be already mostly filled with the coredumps, and may trigger rotation during the sanity
+# checks below. If coredumpctl accesses the main journal currently rotationg, then it warns the following and
+# skips reading the main journal, and cannot find the recent coredumps:
+# TEST-87-AUX-UTILS-VM.sh[839]: + coredumpctl -n 1
+# TEST-87-AUX-UTILS-VM.sh[1172]: Journal file /var/log/journal/a8285330872602d1377cbaaf68869946/system.journal is truncated, ignoring file.
+# TEST-87-AUX-UTILS-VM.sh[1172]: No coredumps found.
+journalctl --sync
+journalctl --rotate
+
 coredumpctl
 SYSTEMD_LOG_LEVEL=debug coredumpctl
 coredumpctl --help