diff options
author | Peter Marheine <pmarheine@chromium.org> | 2022-12-01 15:50:07 +1100 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-05 00:15:29 +0000 |
commit | 90ad3480b1d3d23d9d2ed3cb78c7de00d5147910 (patch) | |
tree | 047772033f916bfbe27b3c7a476dde8d8485ad08 | |
parent | f29bf6061eb84579864323c64d4cdd954dc5a4a8 (diff) | |
download | chrome-ec-90ad3480b1d3d23d9d2ed3cb78c7de00d5147910.tar.gz |
ap_pwrseq: add test for insufficient power case
This adds test coverage for the power-on-blocked case added in
commit 43a7c919bbe845c5cb45e5eb3535ae43d1f49dc5.
BUG=b:234049176,b:242627237,b:260909787
TEST=./twister -T zephyr/test
BRANCH=nissa
Change-Id: I62825bd7a43fcc914fa8c2236ed2bd73851e1aaa
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4074989
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Andrew McRae <amcrae@google.com>
-rw-r--r-- | zephyr/test/ap_power/include/test_mocks.h | 1 | ||||
-rw-r--r-- | zephyr/test/ap_power/src/ap_pwrseq.c | 17 | ||||
-rw-r--r-- | zephyr/test/ap_power/src/test_mocks.c | 3 |
3 files changed, 21 insertions, 0 deletions
diff --git a/zephyr/test/ap_power/include/test_mocks.h b/zephyr/test/ap_power/include/test_mocks.h index 05e1d823e0..5efa0c7570 100644 --- a/zephyr/test/ap_power/include/test_mocks.h +++ b/zephyr/test/ap_power/include/test_mocks.h @@ -19,5 +19,6 @@ DECLARE_FAKE_VALUE_FUNC(int, extpower_is_present); /* Mocks for common/system.c */ DECLARE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t); +DECLARE_FAKE_VALUE_FUNC(int, system_can_boot_ap); #endif /* __TEST_AP_POWER_TEST_MOCKS_H */ diff --git a/zephyr/test/ap_power/src/ap_pwrseq.c b/zephyr/test/ap_power/src/ap_pwrseq.c index 6c2fd4fd7f..09277812df 100644 --- a/zephyr/test/ap_power/src/ap_pwrseq.c +++ b/zephyr/test/ap_power/src/ap_pwrseq.c @@ -7,6 +7,7 @@ #include "ap_power/ap_power_interface.h" #include "chipset.h" #include "emul/emul_power_signals.h" +#include "test_mocks.h" #include "test_state.h" #include <zephyr/drivers/espi.h> @@ -114,6 +115,22 @@ ZTEST(ap_pwrseq, test_ap_pwrseq_2) "AP_POWER_HARD_OFF event generated"); } +ZTEST(ap_pwrseq, test_insufficient_power_blocks_s5) +{ + zassert_equal(0, + power_signal_emul_load( + EMUL_POWER_SIGNAL_TEST_PLATFORM(tp_sys_g3_to_s0)), + "Unable to load test platfform `tp_sys_g3_to_s0`"); + system_can_boot_ap_fake.return_val = 0; + + ap_power_exit_hardoff(); + k_msleep(5000); + + zassert_equal(40, system_can_boot_ap_fake.call_count); + zassert_true( + chipset_in_or_transitioning_to_state(CHIPSET_STATE_HARD_OFF)); +} + void ap_pwrseq_after_test(void *data) { power_signal_emul_unload(); diff --git a/zephyr/test/ap_power/src/test_mocks.c b/zephyr/test/ap_power/src/test_mocks.c index 9eb8834ff5..b22b9ddd0b 100644 --- a/zephyr/test/ap_power/src/test_mocks.c +++ b/zephyr/test/ap_power/src/test_mocks.c @@ -13,6 +13,7 @@ DEFINE_FAKE_VALUE_FUNC(int, extpower_is_present); /* Mocks for common/system.c */ DEFINE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t); +DEFINE_FAKE_VALUE_FUNC(int, system_can_boot_ap); /** * @brief Reset all the fakes before each test. @@ -25,6 +26,8 @@ static void fff_reset_rule_before(const struct ztest_unit_test *test, RESET_FAKE(extpower_is_present); RESET_FAKE(system_hibernate); + RESET_FAKE(system_can_boot_ap); + system_can_boot_ap_fake.return_val = 1; } ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL); |