sleep-config: introduce sleep_supported_full that returns a reason

Preparation for later commits.

Also some other cleanups:
* Add assertions
* Use FOREACH_ARRAY
This commit is contained in:
Mike Yuan
2023-10-20 23:22:28 +08:00
parent 23577f4462
commit a0f6d74ec8
5 changed files with 123 additions and 42 deletions
+4 -4
View File
@@ -59,13 +59,13 @@ TEST(sleep_supported) {
log_info("Freeze configured: %s", yes_no(sleep_state_supported(freeze) > 0));
log_info("/= high-level sleep verbs =/");
r = can_sleep(SLEEP_SUSPEND);
r = sleep_supported(SLEEP_SUSPEND);
log_info("Suspend configured and possible: %s", r >= 0 ? yes_no(r) : STRERROR(r));
r = can_sleep(SLEEP_HIBERNATE);
r = sleep_supported(SLEEP_HIBERNATE);
log_info("Hibernation configured and possible: %s", r >= 0 ? yes_no(r) : STRERROR(r));
r = can_sleep(SLEEP_HYBRID_SLEEP);
r = sleep_supported(SLEEP_HYBRID_SLEEP);
log_info("Hybrid-sleep configured and possible: %s", r >= 0 ? yes_no(r) : STRERROR(r));
r = can_sleep(SLEEP_SUSPEND_THEN_HIBERNATE);
r = sleep_supported(SLEEP_SUSPEND_THEN_HIBERNATE);
log_info("Suspend-then-Hibernate configured and possible: %s", r >= 0 ? yes_no(r) : STRERROR(r));
}