test-sleep: add more logging, show secure boot mode

In https://bugzilla.redhat.com/show_bug.cgi?id=1858219 a user
reported that hibernation is not supported. This is probably caused
by secure boot, but our current logging does not make this
obvious.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-07-27 17:36:56 +02:00
parent c21ed6812e
commit c550cb7f8c
2 changed files with 12 additions and 3 deletions

View file

@ -125,10 +125,16 @@ int can_sleep_state(char **types) {
k = strlen(*type);
FOREACH_WORD_SEPARATOR(word, l, p, WHITESPACE, state)
if (l == k && memcmp(word, *type, l) == 0)
if (l == k && memcmp(word, *type, l) == 0) {
log_debug("Sleep mode \"%s\" is supported by the kernel.", *type);
return true;
}
}
if (DEBUG_LOGGING) {
_cleanup_free_ char *t = strv_join(types, "/");
log_debug("Sleep mode %s not supported by the kernel, sorry.", strnull(t));
}
return false;
}

View file

@ -7,6 +7,7 @@
#include <sys/types.h>
#include <unistd.h>
#include "efivars.h"
#include "errno-util.h"
#include "fd-util.h"
#include "log.h"
@ -84,7 +85,9 @@ static void test_sleep(void) {
log_info("/* %s */", __func__);
log_info("/= configuration =/");
printf("Secure boot: %sd\n", enable_disable(is_efi_secure_boot()));
log_info("/= individual sleep modes =/");
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));
@ -94,7 +97,7 @@ 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(freeze) > 0));
log_info("/= running system =/");
log_info("/= high-level sleep verbs =/");
r = can_sleep("suspend");
log_info("Suspend configured and possible: %s", r >= 0 ? yes_no(r) : strerror_safe(r));
r = can_sleep("hibernate");