]> git.proxmox.com Git - systemd.git/blame - src/test/test-sleep.c
Imported Upstream version 220
[systemd.git] / src / test / test-sleep.c
CommitLineData
663996b3
MS
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
663996b3 22#include <stdio.h>
663996b3
MS
23
24#include "util.h"
25#include "log.h"
26#include "sleep-config.h"
27#include "strv.h"
28
14228c0d 29static void test_sleep(void) {
663996b3
MS
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
14228c0d
MB
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));
663996b3
MS
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));
14228c0d
MB
52}
53
54int main(int argc, char* argv[]) {
55 log_parse_environment();
56 log_open();
57
58 if (getuid() != 0)
e3bff60a 59 log_warning("This program is unlikely to work for unprivileged users");
14228c0d
MB
60
61 test_sleep();
663996b3
MS
62
63 return 0;
64}