X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Ftest%2Ftest-sleep.c;h=a1020ad14c1faf6fdcdfb4f1dc2193a8f39757c5;hb=bc9992978cd1456b5bb79e72e8cf7a2331d3a7c6;hp=5a98ecda2f42a03962412acca582aac0e1e684ae;hpb=6524990fdc98370ecba5d9f73e67161e8798c010;p=elogind.git diff --git a/src/test/test-sleep.c b/src/test/test-sleep.c index 5a98ecda2..a1020ad14 100644 --- a/src/test/test-sleep.c +++ b/src/test/test-sleep.c @@ -26,14 +26,42 @@ #include "util.h" #include "log.h" +#include "sleep-config.h" +#include "strv.h" + +static void test_sleep(void) { + _cleanup_strv_free_ char + **standby = strv_new("standby", NULL), + **mem = strv_new("mem", NULL), + **disk = strv_new("disk", NULL), + **suspend = strv_new("suspend", NULL), + **reboot = strv_new("reboot", NULL), + **platform = strv_new("platform", NULL), + **shutdown = strv_new("shutdown", NULL), + **freez = strv_new("freeze", NULL); + + log_info("Standby configured: %s", yes_no(can_sleep_state(standby) > 0)); + log_info("Suspend configured: %s", yes_no(can_sleep_state(mem) > 0)); + log_info("Hibernate configured: %s", yes_no(can_sleep_state(disk) > 0)); + log_info("Hibernate+Suspend (Hybrid-Sleep) configured: %s", yes_no(can_sleep_disk(suspend) > 0)); + log_info("Hibernate+Reboot configured: %s", yes_no(can_sleep_disk(reboot) > 0)); + log_info("Hibernate+Platform configured: %s", yes_no(can_sleep_disk(platform) > 0)); + log_info("Hibernate+Shutdown configured: %s", yes_no(can_sleep_disk(shutdown) > 0)); + log_info("Freeze configured: %s", yes_no(can_sleep_state(freez) > 0)); + + log_info("Suspend configured and possible: %s", yes_no(can_sleep("suspend") > 0)); + log_info("Hibernation configured and possible: %s", yes_no(can_sleep("hibernate") > 0)); + log_info("Hybrid-sleep configured and possible: %s", yes_no(can_sleep("hybrid-sleep") > 0)); +} int main(int argc, char* argv[]) { - log_info("Can Suspend: %s", yes_no(can_sleep("mem") > 0)); - log_info("Can Hibernate: %s", yes_no(can_sleep("disk") > 0)); - log_info("Can Hibernate+Suspend (Hybrid-Sleep): %s", yes_no(can_sleep_disk("suspend") > 0)); - log_info("Can Hibernate+Reboot: %s", yes_no(can_sleep_disk("reboot") > 0)); - log_info("Can Hibernate+Platform: %s", yes_no(can_sleep_disk("platform") > 0)); - log_info("Can Hibernate+Shutdown: %s", yes_no(can_sleep_disk("shutdown") > 0)); + log_parse_environment(); + log_open(); + + if (getuid() != 0) + log_warning("This program is unlikely to work for unpriviledged users"); + + test_sleep(); return 0; }