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