summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2023-05-15 13:45:33 +0800
committerMike Yuan <me@yhndnzj.com>2023-05-16 18:09:15 +0800
commit306ff2e29798f571fba573577abaeb812f7e3166 (patch)
treef0d5ae0aecd240ec84e1621f4853279071cdbda3
parent8b6c039a1ac73da006bfe9d5735515bba12ef3c4 (diff)
downloadsystemd-306ff2e29798f571fba573577abaeb812f7e3166.tar.gz
test: add test for state in loginctl list-{users,sessions}
-rwxr-xr-xtest/units/testsuite-35.sh18
1 files changed, 14 insertions, 4 deletions
diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh
index bfd11658d6..76127102c4 100755
--- a/test/units/testsuite-35.sh
+++ b/test/units/testsuite-35.sh
@@ -520,7 +520,7 @@ test_session_properties() {
/usr/lib/systemd/tests/unit-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
@@ -637,7 +647,7 @@ test_sanity_check
test_session
test_lock_idle_action
test_session_properties
-test_list_users
+test_list_users_sessions
test_stop_idle_session
test_ambient_caps