summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c b/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c
index fb63c298ed..f5028af537 100644
--- a/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c
+++ b/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c
@@ -13,6 +13,8 @@
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#define ARBITRARY_SLEEP_TRANSITIONS 1
+
/*
* TODO(b/253224061): Reorganize fakes by public interface
*/
@@ -31,6 +33,18 @@ static struct host_sleep_event_context test_saved_context;
static void _test_power_chipset_handle_host_sleep_event(
enum host_sleep_event state, struct host_sleep_event_context *ctx)
{
+ switch (state) {
+ case HOST_SLEEP_EVENT_S0IX_RESUME:
+ case HOST_SLEEP_EVENT_S3_RESUME:
+ ctx->sleep_transitions = ARBITRARY_SLEEP_TRANSITIONS;
+ break;
+
+ case HOST_SLEEP_EVENT_S3_SUSPEND:
+ case HOST_SLEEP_EVENT_S0IX_SUSPEND:
+ case HOST_SLEEP_EVENT_S3_WAKEABLE_SUSPEND:
+ break;
+ }
+
memcpy(&test_saved_context, ctx,
sizeof(struct host_sleep_event_context));
}
@@ -102,5 +116,30 @@ ZTEST_USER(power_host_sleep, test_non_existent_sleep_event_v1__s3_suspend)
p.suspend_params.sleep_timeout_ms);
}
+ZTEST_USER(power_host_sleep, test_non_existent_sleep_event_v1__s3_resume)
+{
+ struct ec_params_host_sleep_event_v1 p = {
+ .sleep_event = HOST_SLEEP_EVENT_S3_RESUME,
+ };
+ struct ec_response_host_sleep_event_v1 r;
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND(EC_CMD_HOST_SLEEP_EVENT, 1, r, p);
+
+ power_chipset_handle_host_sleep_event_fake.custom_fake =
+ _test_power_chipset_handle_host_sleep_event;
+
+ zassert_ok(host_command_process(&args));
+ zassert_equal(args.response_size, sizeof(r));
+ zassert_equal(power_chipset_handle_host_sleep_event_fake.call_count, 1);
+ zassert_equal(power_chipset_handle_host_sleep_event_fake.arg0_val,
+ p.sleep_event);
+
+ /*
+ * Verify sleep context propagated from chip-specific handler.
+ */
+ zassert_equal(r.resume_response.sleep_transitions,
+ ARBITRARY_SLEEP_TRANSITIONS);
+}
+
ZTEST_SUITE(power_host_sleep, drivers_predicate_post_main, NULL,
power_host_sleep_before_after, power_host_sleep_before_after, NULL);