/* 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>
#include "terminal-util.h"
#include "tests.h"
+static const char *arg_tty = NULL;
+
static BusLocator session;
/* Tests org.freedesktop.logind.Session SetType */
_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);
.interface = "org.freedesktop.login1.Session",
};
+ if (saved_argc > 2)
+ arg_tty = saved_argv[2];
+
return EXIT_SUCCESS;
}
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() {