]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-04-JOURNAL: Make more robust
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 4 May 2024 14:32:57 +0000 (16:32 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 6 May 2024 09:57:09 +0000 (11:57 +0200)
Avoid hitting https://github.com/systemd/systemd/issues/2913 by adding
some more sleeps. This is required to make the test pass when executed
with mkosi on my machine.

test/testsuite-04.units/verbose-success.service
test/units/testsuite-04.journal.sh

index 67c8bf10079af5f0ee8f6d60cc9757f44962162e..f4a86fd2b227662713069ab244f6f1a6aaee7117 100644 (file)
@@ -3,4 +3,9 @@
 Description=Verbose successful service
 
 [Service]
-ExecStart=/bin/echo success
+Type=oneshot
+# Sleep so that the cgroup is still there when journald processes the log message which is required for
+# journald to add the expected fields to the log message.
+ExecStart=sleep 2
+ExecStart=echo success
+ExecStart=sleep 2
index 9ca1b789e3b8a90a6672e232030615ef460ea50e..bb4f66d2c8940472b618c487c0ac4f962238bdfe 100755 (executable)
@@ -109,13 +109,12 @@ journalctl --sync
 
 # Test syslog identifiers exclusion
 systemctl start verbose-success.service
-timeout 30 bash -xec 'while systemctl -q is-active verbose-success.service; do sleep 1; done'
 journalctl --sync
 [[ -n "$(journalctl -b -q -u verbose-success.service -t systemd)" ]]
 [[ -n "$(journalctl -b -q -u verbose-success.service -t echo)" ]]
 [[ -n "$(journalctl -b -q -u verbose-success.service -T systemd)" ]]
 [[ -n "$(journalctl -b -q -u verbose-success.service -T echo)" ]]
-[[ -z "$(journalctl -b -q -u verbose-success.service -T echo -T '(echo)' -T systemd -T '(systemd)' -T systemd-executor)" ]]
+[[ -z "$(journalctl -b -q -u verbose-success.service -T echo -T '(echo)' -T sleep -T '(sleep)' -T systemd -T '(systemd)' -T systemd-executor)" ]]
 
 # Exercise the matching machinery
 SYSTEMD_LOG_LEVEL=debug journalctl -b -n 1 /dev/null /dev/zero /dev/null /dev/null /dev/null
@@ -263,7 +262,7 @@ UNIT_NAME="test-cursor-$RANDOM.service"
 CURSOR_FILE="$(mktemp)"
 # Generate some messages we can match against
 journalctl --cursor-file="$CURSOR_FILE" -n1
-systemd-run --unit="$UNIT_NAME" --wait --service-type=exec bash -xec "echo hello; echo world"
+systemd-run --unit="$UNIT_NAME" --wait --service-type=exec bash -ec "sleep 2; set -x; echo hello; echo world; set +x; sleep 2"
 journalctl --sync
 # --after-cursor= + --unit=
 # The format of the "Starting ..." message depends on StatusUnitFormat=, so match only the beginning
@@ -277,6 +276,7 @@ diff <(journalctl --cursor-file="$CURSOR_FILE" -p info -o cat _SYSTEMD_UNIT="$UN
 hello
 + echo world
 world
++ set +x
 EOF
 rm -f "$CURSOR_FILE"