Debian Codegraph @

src/login/test-login-tables.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "logind-action.h"
4 #include "logind-session.h"
5 #include "logind-user.h"
6 #include "sleep-config.h"
7 #include "test-tables.h"
8 #include "tests.h"
9
10 static void test_sleep_handle_action(void) {
11 for (HandleAction action = _HANDLE_ACTION_SLEEP_FIRST; action < _HANDLE_ACTION_SLEEP_LAST; action++) {
12 const HandleActionData *data;
13 const char *sleep_operation_str, *handle_action_str;
14
15 assert_se(data = handle_action_lookup(action));
16
17 assert_se(handle_action_str = handle_action_to_string(action));
18 assert_se(sleep_operation_str = sleep_operation_to_string(data->sleep_operation));
19
20 assert_se(streq(handle_action_str, sleep_operation_str));
21 }
22 }
23
24 int main(int argc, char **argv) {
25 test_setup_logging(LOG_DEBUG);
26
27 test_table(HandleAction, handle_action, HANDLE_ACTION);
28 test_table(InhibitMode, inhibit_mode, INHIBIT_MODE);
29 test_table(KillWhom, kill_whom, KILL_WHOM);
30 test_table(SessionClass, session_class, SESSION_CLASS);
31 test_table(SessionState, session_state, SESSION_STATE);
32 test_table(SessionType, session_type, SESSION_TYPE);
33 test_table(UserState, user_state, USER_STATE);
34
35 test_sleep_handle_action();
36
37 return EXIT_SUCCESS;
38 }