@@ -507,6 +507,7 @@ testcase_lock_idle_action() {
507
507
508
508
create_session
509
509
510
+ journalctl --sync
510
511
ts=" $( date ' +%H:%M:%S' ) "
511
512
512
513
mkdir -p /run/systemd/logind.conf.d
522
523
# session active again and next we slept for another 35s so sessions have
523
524
# become idle again. 'Lock' signal is sent out for each session, we have at
524
525
# least one session, so minimum of 2 "Lock" signals must have been sent.
525
- 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"
526
+ journalctl --sync
527
+ 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"
526
528
527
529
# We need to know that a new message was sent after waking up,
528
530
# so we must track how many happened before sleeping to check we have extra.
532
534
touch /dev/tty2
533
535
534
536
# Wait again
535
- 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"
537
+ journalctl --sync
538
+ 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"
536
539
537
540
if [[ " $( journalctl -b -u systemd-logind.service --since=" $ts " | grep -c ' System idle. Will be locked now.' ) " -lt 2 ]]; then
538
541
echo >&2 " System haven't entered idle state at least 2 times."
@@ -620,6 +623,8 @@ testcase_stop_idle_session() {
620
623
trap teardown_stop_idle_session RETURN
621
624
622
625
id=" $( loginctl --no-legend | grep tty | awk ' $3 == "logind-test-user" { print $1; }' ) "
626
+
627
+ journalctl --sync
623
628
ts=" $( date ' +%H:%M:%S' ) "
624
629
625
630
mkdir -p /run/systemd/logind.conf.d
630
635
systemctl restart systemd-logind.service
631
636
sleep 5
632
637
638
+ journalctl --sync
633
639
assert_eq " $( journalctl -b -u systemd-logind.service --since=" $ts " --grep " Session \" $id \" of user \" logind-test-user\" is idle, stopping." | wc -l) " 1
634
640
assert_eq " $( loginctl --no-legend | grep -v manager | grep -c " logind-test-user" ) " 0
635
641
}
0 commit comments