]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
login: do not hardcode tty used in TEST-35-LOGIN
authorDavid Tardon <dtardon@redhat.com>
Mon, 22 May 2023 13:36:21 +0000 (15:36 +0200)
committerDavid Tardon <dtardon@redhat.com>
Mon, 22 May 2023 19:13:15 +0000 (21:13 +0200)
The test can be run manually outside of CI.

src/login/test-session-properties.c
test/units/testsuite-35.sh

index 0bfde422138ce42b24684d66edbeebf9b43dd76e..d2110b5c72c9b78fbbf5a302db98af340c657b36 100644 (file)
@@ -1,9 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 /* Usage:
- * ./test-session-properties <SESSION-OBJECT-PATH>
+ * ./test-session-properties <SESSION-OBJECT-PATH> [<TTY>]
  * e.g.,
- * ./test-session-properties /org/freedesktop/login1/session/_32
+ * ./test-session-properties /org/freedesktop/login1/session/_32 /dev/tty2
  */
 
 #include <fcntl.h>
@@ -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;
 }
 
index 8cb380d2fd331f2d1c2b07374d180c2a3babd345..d86db83fbe0c34138f8f7208cf57da075122e112 100755 (executable)
@@ -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() {