chiark / gitweb /
systemctl: fix indenting
[elogind.git] / src / test-login.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2011 Lennart Poettering
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   General Public License for more details.
17
18   You should have received a copy of the GNU General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include "sd-login.h"
23 #include "util.h"
24
25 int main(int argc, char* argv[]) {
26     int r, k;
27     uid_t u, u2;
28         char *seat;
29         char *session;
30         char *state;
31         char *session2;
32
33         assert_se(sd_pid_get_session(0, &session) == 0);
34         printf("session = %s\n", session);
35
36         r = sd_session_is_active(session);
37         assert_se(r >= 0);
38         printf("active = %s\n", yes_no(r));
39
40         assert_se(sd_session_get_uid(session, &u) >= 0);
41         printf("uid = %lu\n", (unsigned long) u);
42
43         assert_se(sd_session_get_seat(session, &seat) >= 0);
44         printf("seat = %s\n", seat);
45
46         assert_se(sd_uid_get_state(u, &state) >= 0);
47         printf("state = %s\n", state);
48
49         assert_se(sd_uid_is_on_seat(u, seat) > 0);
50
51         k = sd_uid_is_active_on_seat(u, seat);
52         assert_se(k >= 0);
53         assert_se(!!r == !!r);
54
55         assert_se(sd_seat_get_active(seat, &session2, &u2) >= 0);
56         printf("session2 = %s\n", session2);
57         printf("uid2 = %lu\n", (unsigned long) u2);
58
59         free(session);
60         free(state);
61         free(session2);
62         free(seat);
63
64         return 0;
65 }