|
|
594167 |
From d18194ace1b40a39e6503f46cda768b26d403948 Mon Sep 17 00:00:00 2001
|
|
|
594167 |
From: Michal Sekletar <msekleta@redhat.com>
|
|
|
594167 |
Date: Mon, 8 Aug 2022 11:39:52 +0200
|
|
|
594167 |
Subject: [PATCH] tests: add test for StopIdleSessionSec= option
|
|
|
594167 |
|
|
|
594167 |
(cherry picked from commit 5aa633db228ed3de263500d99d40b5d5e2c9695a)
|
|
|
594167 |
|
|
|
594167 |
Related: #2100464
|
|
|
594167 |
---
|
|
|
594167 |
test/units/testsuite-35.sh | 37 +++++++++++++++++++++++++++++++++++++
|
|
|
594167 |
1 file changed, 37 insertions(+)
|
|
|
594167 |
|
|
|
594167 |
diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh
|
|
|
594167 |
index 8bd93ce92c..964adecbf2 100755
|
|
|
594167 |
--- a/test/units/testsuite-35.sh
|
|
|
594167 |
+++ b/test/units/testsuite-35.sh
|
|
|
594167 |
@@ -436,6 +436,42 @@ test_list_users() {
|
|
|
594167 |
assert_eq "$(loginctl show-user --property Linger --value logind-test-user)" yes
|
|
|
594167 |
}
|
|
|
594167 |
|
|
|
594167 |
+
|
|
|
594167 |
+teardown_stop_idle_session() (
|
|
|
594167 |
+ set +eux
|
|
|
594167 |
+
|
|
|
594167 |
+ rm -f /run/systemd/logind.conf.d/stop-idle-session.conf
|
|
|
594167 |
+ systemctl restart systemd-logind.service
|
|
|
594167 |
+
|
|
|
594167 |
+ cleanup_session
|
|
|
594167 |
+)
|
|
|
594167 |
+
|
|
|
594167 |
+test_stop_idle_session() {
|
|
|
594167 |
+ local id ts
|
|
|
594167 |
+
|
|
|
594167 |
+ if [[ ! -c /dev/tty2 ]]; then
|
|
|
594167 |
+ echo "/dev/tty2 does not exist, skipping test ${FUNCNAME[0]}."
|
|
|
594167 |
+ return
|
|
|
594167 |
+ fi
|
|
|
594167 |
+
|
|
|
594167 |
+ create_session
|
|
|
594167 |
+ trap teardown_stop_idle_session RETURN
|
|
|
594167 |
+
|
|
|
594167 |
+ id="$(loginctl --no-legend | awk '$3 == "logind-test-user" { print $1; }')"
|
|
|
594167 |
+ ts="$(date '+%H:%M:%S')"
|
|
|
594167 |
+
|
|
|
594167 |
+ mkdir -p /run/systemd/logind.conf.d
|
|
|
594167 |
+ cat >/run/systemd/logind.conf.d/stop-idle-session.conf <
|
|
|
594167 |
+[Login]
|
|
|
594167 |
+StopIdleSessionSec=2s
|
|
|
594167 |
+EOF
|
|
|
594167 |
+ systemctl restart systemd-logind.service
|
|
|
594167 |
+ sleep 5
|
|
|
594167 |
+
|
|
|
594167 |
+ assert_eq "$(journalctl -b -u systemd-logind.service --since="$ts" --grep "Session \"$id\" of user \"logind-test-user\" is idle, stopping." | wc -l)" 1
|
|
|
594167 |
+ assert_eq "$(loginctl --no-legend | grep -c "logind-test-user")" 0
|
|
|
594167 |
+}
|
|
|
594167 |
+
|
|
|
594167 |
: >/failed
|
|
|
594167 |
|
|
|
594167 |
setup_test_user
|
|
|
594167 |
@@ -447,6 +483,7 @@ test_shutdown
|
|
|
594167 |
test_session
|
|
|
594167 |
test_session_properties
|
|
|
594167 |
test_list_users
|
|
|
594167 |
+test_stop_idle_session
|
|
|
594167 |
|
|
|
594167 |
touch /testok
|
|
|
594167 |
rm /failed
|