]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-07-PID: journalctl -u may not work for short living processes
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 23 Jul 2025 18:16:11 +0000 (03:16 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 24 Jul 2025 11:55:10 +0000 (20:55 +0900)
Hopefully fixes #37818.

test/units/TEST-07-PID1.prefix-shell.sh

index c095ce773181f1f92dd9eac490f6f3f6fc40822f..8771e12f8afb19f0658ee5eddbec3d77fd7bbd30 100755 (executable)
@@ -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"