summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2024-05-04 16:32:57 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2024-05-06 11:57:09 +0200
commit0214a8fd754ad229aab7d35c2e9b9fee28a386a6 (patch)
tree3f049951d5bbf0b05b653393461106242d55bc42
parentTEST-07-PID1: Schedule exit on successful execution (diff)
downloadsystemd-0214a8fd754ad229aab7d35c2e9b9fee28a386a6.tar.xz
systemd-0214a8fd754ad229aab7d35c2e9b9fee28a386a6.zip
TEST-04-JOURNAL: Make more robust
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.
-rw-r--r--test/testsuite-04.units/verbose-success.service7
-rwxr-xr-xtest/units/testsuite-04.journal.sh6
2 files changed, 9 insertions, 4 deletions
diff --git a/test/testsuite-04.units/verbose-success.service b/test/testsuite-04.units/verbose-success.service
index 67c8bf1007..f4a86fd2b2 100644
--- a/test/testsuite-04.units/verbose-success.service
+++ b/test/testsuite-04.units/verbose-success.service
@@ -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
diff --git a/test/units/testsuite-04.journal.sh b/test/units/testsuite-04.journal.sh
index 9ca1b789e3..bb4f66d2c8 100755
--- a/test/units/testsuite-04.journal.sh
+++ b/test/units/testsuite-04.journal.sh
@@ -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"