From fe9d58b25a8b8b1029dcdfbae89fac59fb429707 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 31 Jul 2022 00:11:59 +0900 Subject: [PATCH 1/3] test: terminate session and user on cleanup --- test/units/testsuite-35.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh index 6e556519b4..71b16b0a45 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" From 54d5c126d30dc0bc4c88d776af2b59e240844d58 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 31 Jul 2022 00:12:48 +0900 Subject: [PATCH 2/3] test: do not restart getty@tty2 automatically --- test/units/testsuite-35.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh index 71b16b0a45..13eb7c0424 100755 --- a/test/units/testsuite-35.sh +++ b/test/units/testsuite-35.sh @@ -323,6 +323,7 @@ create_session() { Type=simple ExecStart= ExecStart=-/sbin/agetty --autologin logind-test-user --noclear %I $TERM +Restart=no EOF systemctl daemon-reload From 3cf9c51e97fc343dcbee2df0da1d7f89191d434d Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 30 Jul 2022 23:51:25 +0900 Subject: [PATCH 3/3] test: restart logind before cleaning up sessions Hopefully, fixes #24040. --- test/units/testsuite-35.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh index 13eb7c0424..eae2cb801d 100755 --- a/test/units/testsuite-35.sh +++ b/test/units/testsuite-35.sh @@ -407,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 )