From: David Tardon Date: Mon, 22 May 2023 13:36:21 +0000 (+0200) Subject: login: do not hardcode tty used in TEST-35-LOGIN X-Git-Tag: v254-rc1~416^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b4ad59596dbe309d471f99f3bba3e2c74274fcd6;p=thirdparty%2Fsystemd.git login: do not hardcode tty used in TEST-35-LOGIN The test can be run manually outside of CI. --- diff --git a/src/login/test-session-properties.c b/src/login/test-session-properties.c index 0bfde422138..d2110b5c72c 100644 --- a/src/login/test-session-properties.c +++ b/src/login/test-session-properties.c @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* Usage: - * ./test-session-properties + * ./test-session-properties [] * e.g., - * ./test-session-properties /org/freedesktop/login1/session/_32 + * ./test-session-properties /org/freedesktop/login1/session/_32 /dev/tty2 */ #include @@ -18,6 +18,8 @@ #include "terminal-util.h" #include "tests.h" +static const char *arg_tty = NULL; + static BusLocator session; /* Tests org.freedesktop.logind.Session SetType */ @@ -105,10 +107,12 @@ TEST(set_tty) { _cleanup_(sd_bus_flush_close_unrefp) sd_bus* bus = NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_free_ char *tty = NULL; - const char *path = "/dev/tty2"; /* testsuite uses tty2 */ int fd; - fd = open(path, O_RDWR|O_CLOEXEC|O_NOCTTY); + if (!arg_tty) + return; + + fd = open(arg_tty, O_RDWR|O_CLOEXEC|O_NOCTTY); assert_se(fd >= 0); assert_se(sd_bus_open_system(&bus) >= 0); @@ -136,6 +140,9 @@ static int intro(void) { .interface = "org.freedesktop.login1.Session", }; + if (saved_argc > 2) + arg_tty = saved_argv[2]; + return EXIT_SUCCESS; } diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh index 8cb380d2fd3..d86db83fbe0 100755 --- a/test/units/testsuite-35.sh +++ b/test/units/testsuite-35.sh @@ -517,7 +517,7 @@ test_session_properties() { create_session s=$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $1 }') - /usr/lib/systemd/tests/unit-tests/manual/test-session-properties "/org/freedesktop/login1/session/_3${s?}" + /usr/lib/systemd/tests/unit-tests/manual/test-session-properties "/org/freedesktop/login1/session/_3${s?}" /dev/tty2 } test_list_users_sessions() {