]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/test/test-sleep.c
Generate systemd-fsck-root.service in the initramfs
[thirdparty/systemd.git] / src / test / test-sleep.c
CommitLineData
6524990f
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3/***
4 This file is part of systemd.
5
6 Copyright 2012 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
6524990f 22#include <stdio.h>
6524990f
LP
23
24#include "util.h"
25#include "log.h"
19adb8a3
ZJS
26#include "sleep-config.h"
27#include "strv.h"
6524990f 28
e9e506ed 29static void test_sleep(void) {
19adb8a3
ZJS
30 _cleanup_strv_free_ char
31 **standby = strv_new("standby", NULL),
32 **mem = strv_new("mem", NULL),
33 **disk = strv_new("disk", NULL),
34 **suspend = strv_new("suspend", NULL),
35 **reboot = strv_new("reboot", NULL),
36 **platform = strv_new("platform", NULL),
37 **shutdown = strv_new("shutdown", NULL),
38 **freez = strv_new("freeze", NULL);
39
69ab8088
ZJS
40 log_info("Standby configured: %s", yes_no(can_sleep_state(standby) > 0));
41 log_info("Suspend configured: %s", yes_no(can_sleep_state(mem) > 0));
42 log_info("Hibernate configured: %s", yes_no(can_sleep_state(disk) > 0));
43 log_info("Hibernate+Suspend (Hybrid-Sleep) configured: %s", yes_no(can_sleep_disk(suspend) > 0));
44 log_info("Hibernate+Reboot configured: %s", yes_no(can_sleep_disk(reboot) > 0));
45 log_info("Hibernate+Platform configured: %s", yes_no(can_sleep_disk(platform) > 0));
46 log_info("Hibernate+Shutdown configured: %s", yes_no(can_sleep_disk(shutdown) > 0));
47 log_info("Freeze configured: %s", yes_no(can_sleep_state(freez) > 0));
19adb8a3
ZJS
48
49 log_info("Suspend configured and possible: %s", yes_no(can_sleep("suspend") > 0));
50 log_info("Hibernation configured and possible: %s", yes_no(can_sleep("hibernate") > 0));
51 log_info("Hybrid-sleep configured and possible: %s", yes_no(can_sleep("hybrid-sleep") > 0));
e9e506ed
ZJS
52}
53
54int main(int argc, char* argv[]) {
55 log_parse_environment();
56 log_open();
57
58 if (getuid() != 0)
59 log_warning("This program is unlikely to work for unpriviledged users");
60
61 test_sleep();
6524990f
LP
62
63 return 0;
64}