]>
Commit | Line | Data |
---|---|---|
6524990f LP |
1 | /*** |
2 | This file is part of systemd. | |
3 | ||
4 | Copyright 2012 Lennart Poettering | |
5 | ||
6 | systemd is free software; you can redistribute it and/or modify it | |
7 | under the terms of the GNU Lesser General Public License as published by | |
8 | the Free Software Foundation; either version 2.1 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | systemd is distributed in the hope that it will be useful, but | |
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public License | |
17 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
18 | ***/ | |
19 | ||
6524990f | 20 | #include <stdio.h> |
6524990f | 21 | |
6524990f | 22 | #include "log.h" |
19adb8a3 ZJS |
23 | #include "sleep-config.h" |
24 | #include "strv.h" | |
cf0fbc49 | 25 | #include "util.h" |
6524990f | 26 | |
e9e506ed | 27 | static void test_sleep(void) { |
19adb8a3 ZJS |
28 | _cleanup_strv_free_ char |
29 | **standby = strv_new("standby", NULL), | |
30 | **mem = strv_new("mem", NULL), | |
31 | **disk = strv_new("disk", NULL), | |
32 | **suspend = strv_new("suspend", NULL), | |
33 | **reboot = strv_new("reboot", NULL), | |
34 | **platform = strv_new("platform", NULL), | |
35 | **shutdown = strv_new("shutdown", NULL), | |
36 | **freez = strv_new("freeze", NULL); | |
37 | ||
69ab8088 ZJS |
38 | log_info("Standby configured: %s", yes_no(can_sleep_state(standby) > 0)); |
39 | log_info("Suspend configured: %s", yes_no(can_sleep_state(mem) > 0)); | |
40 | log_info("Hibernate configured: %s", yes_no(can_sleep_state(disk) > 0)); | |
41 | log_info("Hibernate+Suspend (Hybrid-Sleep) configured: %s", yes_no(can_sleep_disk(suspend) > 0)); | |
42 | log_info("Hibernate+Reboot configured: %s", yes_no(can_sleep_disk(reboot) > 0)); | |
43 | log_info("Hibernate+Platform configured: %s", yes_no(can_sleep_disk(platform) > 0)); | |
44 | log_info("Hibernate+Shutdown configured: %s", yes_no(can_sleep_disk(shutdown) > 0)); | |
45 | log_info("Freeze configured: %s", yes_no(can_sleep_state(freez) > 0)); | |
19adb8a3 ZJS |
46 | |
47 | log_info("Suspend configured and possible: %s", yes_no(can_sleep("suspend") > 0)); | |
48 | log_info("Hibernation configured and possible: %s", yes_no(can_sleep("hibernate") > 0)); | |
49 | log_info("Hybrid-sleep configured and possible: %s", yes_no(can_sleep("hybrid-sleep") > 0)); | |
e9e506ed ZJS |
50 | } |
51 | ||
52 | int main(int argc, char* argv[]) { | |
53 | log_parse_environment(); | |
54 | log_open(); | |
55 | ||
56 | if (getuid() != 0) | |
ff9b60f3 | 57 | log_warning("This program is unlikely to work for unprivileged users"); |
e9e506ed ZJS |
58 | |
59 | test_sleep(); | |
6524990f LP |
60 | |
61 | return 0; | |
62 | } |