mirror of
https://github.com/systemd/systemd
synced 2024-07-23 03:04:57 +00:00
test: sync journal before read
Similar to recent commits, e.g. f961f0e47c2caf9af735a22e7f23210e746d0c8b. Fixes #32926.
This commit is contained in:
parent
123acb2560
commit
702fdd3135
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue