From: Yu Watanabe Date: Fri, 8 Jul 2022 11:22:40 +0000 (+0900) Subject: test: start test user session before idle action setting is changed X-Git-Tag: v252-rc1~695 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9d9fd4ad0a66eea9635081e8ef765e29865d22bf;p=thirdparty%2Fsystemd.git 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. --- diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh index 147604e2936..612f92ac195 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 <&2 "Session of the \'logind-test-user\' is already present." + exit 1 + fi + trap teardown_lock_idle_action RETURN + create_session + + ts="$(date '+%H:%M:%S')" + mkdir -p /run/systemd/logind.conf.d cat >/run/systemd/logind.conf.d/idle-action-lock.conf <&2 "Session of the \'logind-test-user\' is already present." - exit 1 - fi - - # 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 <