]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/test/test-sleep.c
tree-wide: use -EBADF for fd initialization
[thirdparty/systemd.git] / src / test / test-sleep.c
index f56e7e0167f32a4820607c0454027021b222b26e..abaae43e7240735267bdbfaa4e21f3588f98a9f2 100644 (file)
@@ -15,7 +15,6 @@
 #include "sleep-config.h"
 #include "strv.h"
 #include "tests.h"
-#include "util.h"
 
 TEST(parse_sleep_config) {
         _cleanup_(free_sleep_configp) SleepConfig *sleep_config = NULL;
@@ -30,10 +29,10 @@ TEST(parse_sleep_config) {
         his = strv_join(sleep_config->states[SLEEP_HIBERNATE], ", ");
         hym = strv_join(sleep_config->modes[SLEEP_HYBRID_SLEEP], ", ");
         hys = strv_join(sleep_config->states[SLEEP_HYBRID_SLEEP], ", ");
-        log_debug("  allow_suspend: %u", sleep_config->allow[SLEEP_SUSPEND]);
-        log_debug("  allow_hibernate: %u", sleep_config->allow[SLEEP_HIBERNATE]);
-        log_debug("  allow_s2h: %u", sleep_config->allow[SLEEP_SUSPEND_THEN_HIBERNATE]);
-        log_debug("  allow_hybrid_sleep: %u", sleep_config->allow[SLEEP_HYBRID_SLEEP]);
+        log_debug("  allow_suspend: %s", yes_no(sleep_config->allow[SLEEP_SUSPEND]));
+        log_debug("  allow_hibernate: %s", yes_no(sleep_config->allow[SLEEP_HIBERNATE]));
+        log_debug("  allow_s2h: %s", yes_no(sleep_config->allow[SLEEP_SUSPEND_THEN_HIBERNATE]));
+        log_debug("  allow_hybrid_sleep: %s", yes_no(sleep_config->allow[SLEEP_HYBRID_SLEEP]));
         log_debug("  suspend modes: %s", sum);
         log_debug("         states: %s", sus);
         log_debug("  hibernate modes: %s", him);
@@ -44,7 +43,7 @@ TEST(parse_sleep_config) {
 
 static int test_fiemap_one(const char *path) {
         _cleanup_free_ struct fiemap *fiemap = NULL;
-        _cleanup_close_ int fd = -1;
+        _cleanup_close_ int fd = -EBADF;
         int r;
 
         log_info("/* %s */", __func__);
@@ -109,13 +108,13 @@ TEST(sleep) {
 
         log_info("/= high-level sleep verbs =/");
         r = can_sleep(SLEEP_SUSPEND);
-        log_info("Suspend configured and possible: %s", r >= 0 ? yes_no(r) : strerror_safe(r));
+        log_info("Suspend configured and possible: %s", r >= 0 ? yes_no(r) : STRERROR(r));
         r = can_sleep(SLEEP_HIBERNATE);
-        log_info("Hibernation configured and possible: %s", r >= 0 ? yes_no(r) : strerror_safe(r));
+        log_info("Hibernation configured and possible: %s", r >= 0 ? yes_no(r) : STRERROR(r));
         r = can_sleep(SLEEP_HYBRID_SLEEP);
-        log_info("Hybrid-sleep configured and possible: %s", r >= 0 ? yes_no(r) : strerror_safe(r));
+        log_info("Hybrid-sleep configured and possible: %s", r >= 0 ? yes_no(r) : STRERROR(r));
         r = can_sleep(SLEEP_SUSPEND_THEN_HIBERNATE);
-        log_info("Suspend-then-Hibernate configured and possible: %s", r >= 0 ? yes_no(r) : strerror_safe(r));
+        log_info("Suspend-then-Hibernate configured and possible: %s", r >= 0 ? yes_no(r) : STRERROR(r));
 }
 
 static int intro(void) {
@@ -125,4 +124,4 @@ static int intro(void) {
         return EXIT_SUCCESS;
 }
 
-DEFINE_CUSTOM_TEST_MAIN(LOG_DEBUG, intro, test_nop);
+DEFINE_TEST_MAIN_WITH_INTRO(LOG_DEBUG, intro);