60 lines
2.2 KiB
Diff
60 lines
2.2 KiB
Diff
From 89f043cce92c336105e1b36b9eac4ba3bd1333b9 Mon Sep 17 00:00:00 2001
|
|
From: Mike Yuan <me@yhndnzj.com>
|
|
Date: Mon, 15 May 2023 13:45:33 +0800
|
|
Subject: [PATCH] test: add test for state in loginctl list-{users,sessions}
|
|
|
|
(cherry picked from commit 306ff2e29798f571fba573577abaeb812f7e3166)
|
|
|
|
Related: #2209912
|
|
---
|
|
test/units/testsuite-35.sh | 18 ++++++++++++++----
|
|
1 file changed, 14 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh
|
|
index 85925f2471..c9b2417bb7 100755
|
|
--- a/test/units/testsuite-35.sh
|
|
+++ b/test/units/testsuite-35.sh
|
|
@@ -520,7 +520,7 @@ test_session_properties() {
|
|
/usr/lib/systemd/tests/manual/test-session-properties "/org/freedesktop/login1/session/_3${s?}"
|
|
}
|
|
|
|
-test_list_users() {
|
|
+test_list_users_sessions() {
|
|
if [[ ! -c /dev/tty2 ]]; then
|
|
echo "/dev/tty2 does not exist, skipping test ${FUNCNAME[0]}."
|
|
return
|
|
@@ -531,12 +531,22 @@ test_list_users() {
|
|
|
|
assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $1 }')" "$(id -ru logind-test-user)"
|
|
assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $3 }')" no
|
|
+ assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $4 }')" active
|
|
+ assert_eq "$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $6 }')" active
|
|
|
|
loginctl enable-linger logind-test-user
|
|
-
|
|
assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $3 }')" yes
|
|
-}
|
|
|
|
+ for s in $(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $1 }'); do
|
|
+ loginctl terminate-session "$s"
|
|
+ done
|
|
+ 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."
|
|
+ return
|
|
+ fi
|
|
+
|
|
+ assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $4 }')" lingering
|
|
+}
|
|
|
|
teardown_stop_idle_session() (
|
|
set +eux
|
|
@@ -585,7 +595,7 @@ test_sanity_check
|
|
test_session
|
|
test_lock_idle_action
|
|
test_session_properties
|
|
-test_list_users
|
|
+test_list_users_sessions
|
|
test_stop_idle_session
|
|
|
|
touch /testok
|