summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2022-11-02 14:53:51 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-03 18:12:17 +0000
commita08bcc0f4329c177b7dfbcdfd974f107b14b4ab2 (patch)
tree5a01b42116c570afa735ebb1c82abc51e04b446e
parent6b9ec04933d47411d796e62a887dd424f5d1c724 (diff)
downloadchrome-ec-a08bcc0f4329c177b7dfbcdfd974f107b14b4ab2.tar.gz
zephyr test: Verify port suspend at low battery
Verify that suspending a Type-C port for a firmware update will fail when the battery is very low. BUG=b:256182103 TEST=twister -s zephyr/test/drivers/drivers.host_cmd BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ifa21894aa34626e70dd8c6f6ad97ebf90206d241 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000780 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tristan Honscheid <honscheid@google.com>
-rw-r--r--zephyr/test/drivers/host_cmd/src/pd_control.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/zephyr/test/drivers/host_cmd/src/pd_control.c b/zephyr/test/drivers/host_cmd/src/pd_control.c
index 5fdd424db9..97624fdb34 100644
--- a/zephyr/test/drivers/host_cmd/src/pd_control.c
+++ b/zephyr/test/drivers/host_cmd/src/pd_control.c
@@ -93,6 +93,20 @@ ZTEST_USER(host_cmd_pd_control, test_suspend_resume)
zassert_true(pd_is_port_enabled(TEST_PORT), "Port failed to resume");
}
+ZTEST_USER(host_cmd_pd_control, test_suspend_low_battery)
+{
+ struct ec_params_pd_control params = { .chip = TEST_PORT,
+ .subcmd = PD_SUSPEND };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params);
+
+ /* Suspending the port for firmware update should fail at critical low
+ * battery.
+ */
+ test_set_battery_level(1);
+ zassert_equal(host_command_process(&args), EC_RES_BUSY);
+}
+
ZTEST_USER(host_cmd_pd_control, test_control_disable)
{
struct ec_params_pd_control params = { .chip = TEST_PORT,