From: Yu Watanabe Date: Wed, 23 Jul 2025 18:16:11 +0000 (+0900) Subject: TEST-07-PID: journalctl -u may not work for short living processes X-Git-Tag: v258-rc2~95^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=052e2cfbb8823b11bff31db24cfee842311d95aa;p=thirdparty%2Fsystemd.git TEST-07-PID: journalctl -u may not work for short living processes Hopefully fixes #37818. --- diff --git a/test/units/TEST-07-PID1.prefix-shell.sh b/test/units/TEST-07-PID1.prefix-shell.sh index c095ce77318..8771e12f8af 100755 --- a/test/units/TEST-07-PID1.prefix-shell.sh +++ b/test/units/TEST-07-PID1.prefix-shell.sh @@ -14,9 +14,14 @@ systemd-run --wait --uid=nobody \ assert_eq "$(cat /tmp/TEST-07-PID1.prefix-shell.flag)" "a" rm /tmp/TEST-07-PID1.prefix-shell.flag +# If the service exits too early, journald cannot find the source process of the log message. +# Hence, we cannot use 'journalctl -u' below. Instead, let's use --since=. +journalctl --sync +TS="$(date '+%H:%M:%S')" + systemctl start prefix-shell.service assert_eq "$(cat /tmp/TEST-07-PID1.prefix-shell.flag)" "YAY!" journalctl --sync -journalctl -b -u prefix-shell.service --grep "with login shell .*: lvl 101" -journalctl -b -u prefix-shell.service --grep "with normal shell" +journalctl --since "$TS" --grep "with login shell .*: lvl 101" +journalctl --since "$TS" --grep "with normal shell"