]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: sync journal before read 32942/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 20 May 2024 16:54:35 +0000 (01:54 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 20 May 2024 17:00:08 +0000 (02:00 +0900)
Similar to recent commits, e.g. f961f0e47c2caf9af735a22e7f23210e746d0c8b.

Fixes #32926.

test/units/TEST-17-UDEV.02.sh
test/units/TEST-35-LOGIN.sh
test/units/TEST-50-DISSECT.dissect.sh

index b232fca66808bc54da855b12c05fdad2210fd2e1..ee1995ad085fb6647c11a291ed21b92aa1c6becc 100755 (executable)
@@ -145,6 +145,7 @@ EOF
     # make sure that 'udevadm monitor' actually monitor uevents
     sleep 1
 
+    journalctl --sync
     since="$(date '+%H:%M:%S')"
 
     # add another interface which will conflict with an existing interface
@@ -172,7 +173,8 @@ EOF
     done
     test -n "$found"
 
-    timeout 30 bash -c "until journalctl _PID=1 _COMM=systemd --since $since | grep -q 'foobar: systemd-udevd failed to process the device, ignoring: File exists'; do sleep 1; done"
+    journalctl --sync
+    timeout 30 bash -c "until journalctl _PID=1 _COMM=systemd --since $since | grep -q 'foobar: systemd-udevd failed to process the device, ignoring: File exists'; do sleep 1; journalctl --sync; done"
     # check if the invalid SYSTEMD_ALIAS property for the interface foobar is ignored by PID1
     assert_eq "$(systemctl show --property=SysFSPath --value /sys/subsystem/net/devices/hoge)" "/sys/devices/virtual/net/hoge"
 }
index 1ad06526e64ac1b40a63c63d594f1685fe2b16f5..890a0290dd312e73f41d1b09740270c9faf19f32 100755 (executable)
@@ -507,6 +507,7 @@ testcase_lock_idle_action() {
 
     create_session
 
+    journalctl --sync
     ts="$(date '+%H:%M:%S')"
 
     mkdir -p /run/systemd/logind.conf.d
@@ -522,7 +523,8 @@ EOF
     # session active again and next we slept for another 35s so sessions have
     # become idle again. 'Lock' signal is sent out for each session, we have at
     # least one session, so minimum of 2 "Lock" signals must have been sent.
-    timeout 35 bash -c "while [[ \"\$(journalctl -b -u systemd-logind.service --since=$ts | grep -c 'Sent message type=signal .* member=Lock')\" -lt 1 ]]; do sleep 1; done"
+    journalctl --sync
+    timeout 35 bash -c "while [[ \"\$(journalctl -b -u systemd-logind.service --since=$ts | grep -c 'Sent message type=signal .* member=Lock')\" -lt 1 ]]; do sleep 1; journalctl --sync; done"
 
     # We need to know that a new message was sent after waking up,
     # so we must track how many happened before sleeping to check we have extra.
@@ -532,7 +534,8 @@ EOF
     touch /dev/tty2
 
     # Wait again
-    timeout 35 bash -c "while [[ \"\$(journalctl -b -u systemd-logind.service --since=$ts | grep -c 'Sent message type=signal .* member=Lock')\" -lt $((locks + 1)) ]]; do sleep 1; done"
+    journalctl --sync
+    timeout 35 bash -c "while [[ \"\$(journalctl -b -u systemd-logind.service --since=$ts | grep -c 'Sent message type=signal .* member=Lock')\" -lt $((locks + 1)) ]]; do sleep 1; journalctl --sync; done"
 
     if [[ "$(journalctl -b -u systemd-logind.service --since="$ts" | grep -c 'System idle. Will be locked now.')" -lt 2 ]]; then
         echo >&2 "System haven't entered idle state at least 2 times."
@@ -620,6 +623,8 @@ testcase_stop_idle_session() {
     trap teardown_stop_idle_session RETURN
 
     id="$(loginctl --no-legend | grep tty | awk '$3 == "logind-test-user" { print $1; }')"
+
+    journalctl --sync
     ts="$(date '+%H:%M:%S')"
 
     mkdir -p /run/systemd/logind.conf.d
@@ -630,6 +635,7 @@ EOF
     systemctl restart systemd-logind.service
     sleep 5
 
+    journalctl --sync
     assert_eq "$(journalctl -b -u systemd-logind.service --since="$ts" --grep "Session \"$id\" of user \"logind-test-user\" is idle, stopping." | wc -l)" 1
     assert_eq "$(loginctl --no-legend | grep -v manager | grep -c "logind-test-user")" 0
 }
index 991346fd6e30ad2a196455ff0a0f055222e1425b..c3260429aba3ab27ebc35e3920756fdeadc97da4 100755 (executable)
@@ -722,8 +722,9 @@ systemd-sysext merge --no-reload
 (! systemctl --quiet is-active foo.service)
 systemd-sysext unmerge --no-reload
 systemd-sysext merge
+journalctl --sync
 # shellcheck disable=SC2016
-timeout 30s bash -xec 'until [[ $(journalctl -b -u foo.service _TRANSPORT=stdout -o cat) == foo ]]; do sleep .5; done'
+timeout 30s bash -xec 'until [[ $(journalctl -b -u foo.service _TRANSPORT=stdout -o cat) == foo ]]; do sleep 1; journalctl --sync; done'
 systemd-sysext unmerge --no-reload
 # Grep on the Warning to find the warning helper mentioning the daemon reload.
 systemctl status foo.service 2>&1 | grep -q -F "Warning"