You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.7 KiB
58 lines
1.7 KiB
From 10d03dd6ea51b99488dcfa5e85c85fbddc86a243 Mon Sep 17 00:00:00 2001
|
|
From: David Tardon <dtardon@redhat.com>
|
|
Date: Sun, 17 Jul 2022 15:35:22 +0200
|
|
Subject: [PATCH] test: add a simple test for list-users
|
|
|
|
(cherry picked from commit 6083f7a604267d02a648c76edd3e0cb7b83b4620)
|
|
|
|
Related: #2100464
|
|
---
|
|
test/units/testsuite-35.sh | 20 ++++++++++++++++++++
|
|
1 file changed, 20 insertions(+)
|
|
|
|
diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh
|
|
index 4fb2944e2d..28022b03cf 100755
|
|
--- a/test/units/testsuite-35.sh
|
|
+++ b/test/units/testsuite-35.sh
|
|
@@ -225,6 +225,8 @@ cleanup_session() (
|
|
rm -rf /run/systemd/system/getty@tty2.service.d
|
|
systemctl daemon-reload
|
|
|
|
+ loginctl disable-linger logind-test-user
|
|
+
|
|
pkill -u "$(id -u logind-test-user)"
|
|
sleep 1
|
|
pkill -KILL -u "$(id -u logind-test-user)"
|
|
@@ -388,6 +390,23 @@ test_session_properties() {
|
|
/usr/lib/systemd/tests/manual/test-session-properties "/org/freedesktop/login1/session/_3${s?}"
|
|
}
|
|
|
|
+test_list_users() {
|
|
+ if [[ ! -c /dev/tty2 ]]; then
|
|
+ echo "/dev/tty2 does not exist, skipping test ${FUNCNAME[0]}."
|
|
+ return
|
|
+ fi
|
|
+
|
|
+ trap cleanup_session RETURN
|
|
+ create_session
|
|
+
|
|
+ assert_eq "$(loginctl list-users --no-legend | awk '$2 == "logind-test-user" { print $1 }')" "$(id -ru logind-test-user)"
|
|
+ assert_eq "$(loginctl show-user --property Linger --value logind-test-user)" no
|
|
+
|
|
+ loginctl enable-linger logind-test-user
|
|
+
|
|
+ assert_eq "$(loginctl show-user --property Linger --value logind-test-user)" yes
|
|
+}
|
|
+
|
|
: >/failed
|
|
|
|
setup_test_user
|
|
@@ -398,6 +417,7 @@ test_suspend_on_lid
|
|
test_shutdown
|
|
test_session
|
|
test_session_properties
|
|
+test_list_users
|
|
|
|
touch /testok
|
|
rm /failed
|