diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh index 6e556519b47..eae2cb801d4 100755 --- a/test/units/testsuite-35.sh +++ b/test/units/testsuite-35.sh @@ -221,7 +221,7 @@ test_shutdown() { cleanup_session() ( set +ex - local uid + local uid s uid=$(id -u logind-test-user) @@ -229,6 +229,17 @@ cleanup_session() ( systemctl stop getty@tty2.service + for s in $(loginctl --no-legend list-sessions | awk '$3 == "logind-test-user" { print $1 }'); do + echo "INFO: stopping session $s" + loginctl terminate-session "$s" + done + + loginctl terminate-user logind-test-user + + if ! timeout 30 bash -c "while loginctl --no-legend | grep -q logind-test-user; do sleep 1; done"; then + echo "WARNING: session for logind-test-user still active, ignoring." + fi + pkill -u "$uid" sleep 1 pkill -KILL -u "$uid" @@ -312,6 +323,7 @@ create_session() { Type=simple ExecStart= ExecStart=-/sbin/agetty --autologin logind-test-user --noclear %I $TERM +Restart=no EOF systemctl daemon-reload @@ -395,11 +407,11 @@ EOF teardown_lock_idle_action() ( set +eux - cleanup_session - rm -f /run/systemd/logind.conf.d/idle-action-lock.conf systemctl restart systemd-logind.service + cleanup_session + return 0 )