test-sleep: add more logging, show secure boot mode 16590/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 27 Jul 2020 15:36:56 +0000 (17:36 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 29 Jul 2020 09:12:13 +0000 (11:12 +0200)
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.

src/shared/sleep-config.c
src/test/test-sleep.c

index 6b9074c..0dccc8f 100644 (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;
 }
 
index 2e63aac..8b4fa82 100644 (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");