mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 09:21:26 +03:00
sd-login: test - fix failure when run from non-graphical seat
Observed when running from the console of a systemd nspawn container (see failure below). The value of r was tested, when r was last set by sd_session_can_graphical(). This did not correspond to the value expected. Fix the code, so we compare relevant values now. Hopefully :). Test failure ------------ /* Information printed is from the live system */ sd_pid_get_unit(0, …) → "session-13.scope" sd_pid_get_user_unit(0, …) → "n/a" sd_pid_get_slice(0, …) → "user-1000.slice" sd_pid_get_session(0, …) → "13" sd_pid_get_owner_uid(0, …) → 1000 sd_pid_get_cgroup(0, …) → "/user.slice/user-1000.slice/session-13.scope" sd_uid_get_display(1000, …) → "13" sd_uid_get_sessions(1000, …) → [2] "15 13" sd_uid_get_seats(1000, …) → [1] "seat0" sd_session_is_active("13") → yes sd_session_is_remote("13") → no sd_session_get_state("13") → "active" sd_session_get_uid("13") → 1000 sd_session_get_type("13") → "tty" sd_session_get_class("13") → "user" sd_session_get_display("13") → "n/a" sd_session_get_remote_user("13") → "n/a" sd_session_get_remote_host("13") → "n/a" sd_session_get_seat("13") → "seat0" sd_session_can_multi_seat("seat0") → no sd_session_can_tty("seat0") → no sd_session_can_graphical("seat0") → no sd_uid_get_state(1000, …) → active Assertion '!!k == !!r' failed at ../src/libsystemd/sd-login/test-login.c:191, function test_login(). Aborting.
This commit is contained in:
parent
5947643cc2
commit
e6f44233c6
@ -55,7 +55,7 @@ static void test_login(void) {
|
||||
*type = NULL, *class = NULL, *state = NULL, *state2 = NULL,
|
||||
*seat = NULL, *session = NULL,
|
||||
*unit = NULL, *user_unit = NULL, *slice = NULL;
|
||||
int r, k;
|
||||
int r;
|
||||
uid_t u, u2;
|
||||
char *t, **seats, **sessions;
|
||||
|
||||
@ -186,13 +186,14 @@ static void test_login(void) {
|
||||
|
||||
assert_se(sd_uid_is_on_seat(u, 0, seat) > 0);
|
||||
|
||||
k = sd_uid_is_on_seat(u, 1, seat);
|
||||
assert_se(k >= 0);
|
||||
assert_se(!!k == !!r);
|
||||
|
||||
assert_se(sd_seat_get_active(seat, &session2, &u2) >= 0);
|
||||
r = sd_seat_get_active(seat, &session2, &u2);
|
||||
assert_se(r >= 0);
|
||||
log_info("sd_seat_get_active(\"%s\", …) → \"%s\", "UID_FMT, seat, session2, u2);
|
||||
|
||||
r = sd_uid_is_on_seat(u, 1, seat);
|
||||
assert_se(r >= 0);
|
||||
assert_se(!!r == streq(session, session2));
|
||||
|
||||
r = sd_seat_get_sessions(seat, &sessions, &uids, &n);
|
||||
assert_se(r >= 0);
|
||||
assert_se(r == (int) strv_length(sessions));
|
||||
|
Loading…
Reference in New Issue
Block a user