diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-04-11 08:51:06 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-04-11 09:26:14 +0200 |
commit | b71c9758d131e5f2b38fcbc6393579a4aab3cb82 (patch) | |
tree | 367a46d547e5ea6f16b9aa0e1f79469688557cf9 /src/test/test-sleep.c | |
parent | logind: refuse operations if the target unit is masked or unavailable (diff) | |
download | systemd-b71c9758d131e5f2b38fcbc6393579a4aab3cb82.tar.xz systemd-b71c9758d131e5f2b38fcbc6393579a4aab3cb82.zip |
shared/sleep-config: return a custom message when not enough swap for hibernation
$ sudo swapoff -av
swapoff /dev/vda4
$ sudo systemctl hibernate
Failed to hibernate system via logind: Not enough swap space for hibernation
Fixes #6729.
Diffstat (limited to 'src/test/test-sleep.c')
-rw-r--r-- | src/test/test-sleep.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/test/test-sleep.c b/src/test/test-sleep.c index 05fd6c0abf..d9326c9474 100644 --- a/src/test/test-sleep.c +++ b/src/test/test-sleep.c @@ -65,7 +65,9 @@ static void test_sleep(void) { **platform = strv_new("platform", NULL), **shutdown = strv_new("shutdown", NULL), **freez = strv_new("freeze", NULL); + int r; + log_info("/* configuration */"); 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)); @@ -75,10 +77,15 @@ static void test_sleep(void) { 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)); - log_info("Suspend-then-Hibernate configured and possible: %s", yes_no(can_sleep("suspend-then-hibernate") > 0)); + log_info("/* running system */"); + r = can_sleep("suspend"); + log_info("Suspend configured and possible: %s", r >= 0 ? yes_no(r) : strerror(-r)); + r = can_sleep("hibernate"); + log_info("Hibernation configured and possible: %s", r >= 0 ? yes_no(r) : strerror(-r)); + r = can_sleep("hybrid-sleep"); + log_info("Hybrid-sleep configured and possible: %s", r >= 0 ? yes_no(r) : strerror(-r)); + r = can_sleep("suspend-then-hibernate"); + log_info("Suspend-then-Hibernate configured and possible: %s", r >= 0 ? yes_no(r) : strerror(-r)); } int main(int argc, char* argv[]) { |