systemd/SOURCES/0342-test-start-test-user-session-before-idle-action-sett.patch

105 lines
2.7 KiB
Diff
Raw Normal View History

2022-11-15 06:58:41 +00:00
From 2ac026ce61d73f76e33a31fdb29c73ec40a05dfc Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Fri, 8 Jul 2022 20:22:40 +0900
Subject: [PATCH] test: start test user session before idle action setting is
changed
Otherwise, idle action may be triggered before starting the test user
session.
This also introduce create_session() and cleanup_session() helper
functions.
Fixes #23952.
(cherry picked from commit 9d9fd4ad0a66eea9635081e8ef765e29865d22bf)
Related: #2100464
---
test/units/testsuite-35.sh | 44 ++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 16 deletions(-)
diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh
index 86787e7a02..9c37fc36d0 100755
--- a/test/units/testsuite-35.sh
+++ b/test/units/testsuite-35.sh
@@ -214,7 +214,7 @@ test_shutdown() {
assert_eq "$(systemctl show systemd-logind.service -p ExecMainPID --value)" "$pid"
}
-teardown_session() (
+cleanup_session() (
set +ex
systemctl stop getty@tty2.service
@@ -224,6 +224,12 @@ teardown_session() (
pkill -u "$(id -u logind-test-user)"
sleep 1
pkill -KILL -u "$(id -u logind-test-user)"
+)
+
+teardown_session() (
+ set +ex
+
+ cleanup_session
rm -f /run/udev/rules.d/70-logindtest-scsi_debug-user.rules
udevadm control --reload
@@ -271,21 +277,7 @@ check_session() (
fi
)
-test_session() {
- local dev
-
- if systemd-detect-virt --quiet --container; then
- echo "Skipping ACL tests in container"
- return
- fi
-
- if [[ ! -c /dev/tty2 ]]; then
- echo "/dev/tty2 does not exist, skipping test ${FUNCNAME[0]}."
- return
- fi
-
- trap teardown_session RETURN
-
+create_session() {
# login with the test user to start a session
mkdir -p /run/systemd/system/getty@tty2.service.d
cat >/run/systemd/system/getty@tty2.service.d/override.conf <<EOF
@@ -295,6 +287,7 @@ ExecStart=
ExecStart=-/sbin/agetty --autologin logind-test-user --noclear %I $TERM
EOF
systemctl daemon-reload
+
systemctl restart getty@tty2.service
# check session
@@ -303,6 +296,25 @@ EOF
check_session && break
done
check_session
+ assert_eq "$(loginctl --no-legend | awk '$3=="logind-test-user" { print $5 }')" "tty2"
+}
+
+test_session() {
+ local dev
+
+ if systemd-detect-virt --quiet --container; then
+ echo "Skipping ACL tests in container"
+ return
+ fi
+
+ if [[ ! -c /dev/tty2 ]]; then
+ echo "/dev/tty2 does not exist, skipping test ${FUNCNAME[0]}."
+ return
+ fi
+
+ trap teardown_session RETURN
+
+ create_session
# scsi_debug should not be loaded yet
if [[ -d /sys/bus/pseudo/drivers/scsi_debug ]]; then