TEST-35-LOGIN: Handle multiple lock messages per sleep

If 3 lock messages get sent when going to sleep
then we can falsely assume we have woken up if we only assume we have at least two
so checking we have more than we did before sleeping addresses that issue.
This commit is contained in:
Richard Maw 2024-02-17 21:42:45 +00:00 committed by Daan De Meyer
parent f991c3871b
commit 37029ce769

View file

@ -524,11 +524,15 @@ EOF
# 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"
# 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.
locks="$(journalctl -b -u systemd-logind.service --since="$ts" | grep -c 'Sent message type=signal .* member=Lock')"
# Wakeup
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 2 ]]; do sleep 1; done"
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"
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."