X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Ftest-login.c;h=e4d0c933786ff0c4e48b23cfd0c1e0bf8a190ddf;hb=c784c5ce777f16ee56086a072dc1466639bc9eff;hp=2aaa31f22f1c3ab064018104465496fc3162dfa6;hpb=51f58f083a9454599080dc01d7740cf097f48920;p=elogind.git diff --git a/src/login/test-login.c b/src/login/test-login.c index 2aaa31f22..e4d0c9337 100644 --- a/src/login/test-login.c +++ b/src/login/test-login.c @@ -6,16 +6,16 @@ Copyright 2011 Lennart Poettering systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. systemd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { int r, k; uid_t u, u2; - char *seat, *type, *class; + char *seat, *type, *class, *display; char *session; char *state; char *session2; @@ -71,6 +71,11 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); printf("active = %s\n", yes_no(r)); + r = sd_session_get_state(session, &state); + assert_se(r >= 0); + printf("state = %s\n", state); + free(state); + assert_se(sd_session_get_uid(session, &u) >= 0); printf("uid = %lu\n", (unsigned long) u); assert_se(u == u2); @@ -83,6 +88,10 @@ int main(int argc, char* argv[]) { printf("class = %s\n", class); free(class); + assert_se(sd_session_get_display(session, &display) >= 0); + printf("display = %s\n", display); + free(display); + assert_se(sd_session_get_seat(session, &seat) >= 0); printf("seat = %s\n", seat); @@ -90,6 +99,14 @@ int main(int argc, char* argv[]) { assert_se(r >= 0); printf("can do multi session = %s\n", yes_no(r)); + r = sd_seat_can_tty(seat); + assert_se(r >= 0); + printf("can do tty = %s\n", yes_no(r)); + + r = sd_seat_can_graphical(seat); + assert_se(r >= 0); + printf("can do graphical = %s\n", yes_no(r)); + assert_se(sd_uid_get_state(u, &state) >= 0); printf("state = %s\n", state); @@ -166,12 +183,23 @@ int main(int argc, char* argv[]) { r = sd_login_monitor_new("session", &m); assert_se(r >= 0); - zero(pollfd); - pollfd.fd = sd_login_monitor_get_fd(m); - pollfd.events = POLLIN; for (n = 0; n < 5; n++) { - r = poll(&pollfd, 1, -1); + usec_t timeout, nw; + + zero(pollfd); + assert_se((pollfd.fd = sd_login_monitor_get_fd(m)) >= 0); + assert_se((pollfd.events = sd_login_monitor_get_events(m)) >= 0); + + assert_se(sd_login_monitor_get_timeout(m, &timeout) >= 0); + + nw = now(CLOCK_MONOTONIC); + + r = poll(&pollfd, 1, + timeout == (uint64_t) -1 ? -1 : + timeout > nw ? (int) ((timeout - nw) / 1000) : + 0); + assert_se(r >= 0); sd_login_monitor_flush(m);