]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
6524990f LP |
2 | /*** |
3 | This file is part of systemd. | |
4 | ||
5 | Copyright 2012 Lennart Poettering | |
6524990f LP |
6 | ***/ |
7 | ||
6524990f | 8 | #include <stdio.h> |
6524990f | 9 | |
6524990f | 10 | #include "log.h" |
19adb8a3 ZJS |
11 | #include "sleep-config.h" |
12 | #include "strv.h" | |
cf0fbc49 | 13 | #include "util.h" |
6524990f | 14 | |
e9e506ed | 15 | static void test_sleep(void) { |
19adb8a3 ZJS |
16 | _cleanup_strv_free_ char |
17 | **standby = strv_new("standby", NULL), | |
18 | **mem = strv_new("mem", NULL), | |
19 | **disk = strv_new("disk", NULL), | |
20 | **suspend = strv_new("suspend", NULL), | |
21 | **reboot = strv_new("reboot", NULL), | |
22 | **platform = strv_new("platform", NULL), | |
23 | **shutdown = strv_new("shutdown", NULL), | |
24 | **freez = strv_new("freeze", NULL); | |
25 | ||
69ab8088 ZJS |
26 | log_info("Standby configured: %s", yes_no(can_sleep_state(standby) > 0)); |
27 | log_info("Suspend configured: %s", yes_no(can_sleep_state(mem) > 0)); | |
28 | log_info("Hibernate configured: %s", yes_no(can_sleep_state(disk) > 0)); | |
29 | log_info("Hibernate+Suspend (Hybrid-Sleep) configured: %s", yes_no(can_sleep_disk(suspend) > 0)); | |
30 | log_info("Hibernate+Reboot configured: %s", yes_no(can_sleep_disk(reboot) > 0)); | |
31 | log_info("Hibernate+Platform configured: %s", yes_no(can_sleep_disk(platform) > 0)); | |
32 | log_info("Hibernate+Shutdown configured: %s", yes_no(can_sleep_disk(shutdown) > 0)); | |
33 | log_info("Freeze configured: %s", yes_no(can_sleep_state(freez) > 0)); | |
19adb8a3 ZJS |
34 | |
35 | log_info("Suspend configured and possible: %s", yes_no(can_sleep("suspend") > 0)); | |
36 | log_info("Hibernation configured and possible: %s", yes_no(can_sleep("hibernate") > 0)); | |
37 | log_info("Hybrid-sleep configured and possible: %s", yes_no(can_sleep("hybrid-sleep") > 0)); | |
e68c79db | 38 | log_info("Suspend-then-Hibernate configured and possible: %s", yes_no(can_sleep("suspend-then-hibernate") > 0)); |
e9e506ed ZJS |
39 | } |
40 | ||
41 | int main(int argc, char* argv[]) { | |
42 | log_parse_environment(); | |
43 | log_open(); | |
44 | ||
45 | if (getuid() != 0) | |
ff9b60f3 | 46 | log_warning("This program is unlikely to work for unprivileged users"); |
e9e506ed ZJS |
47 | |
48 | test_sleep(); | |
6524990f LP |
49 | |
50 | return 0; | |
51 | } |