diff options
Diffstat (limited to 'zephyr/test/drivers/host_cmd/src/pd_control.c')
-rw-r--r-- | zephyr/test/drivers/host_cmd/src/pd_control.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/zephyr/test/drivers/host_cmd/src/pd_control.c b/zephyr/test/drivers/host_cmd/src/pd_control.c index e8de27f6ce..a881a8e0ea 100644 --- a/zephyr/test/drivers/host_cmd/src/pd_control.c +++ b/zephyr/test/drivers/host_cmd/src/pd_control.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include <zephyr/fff.h> -#include <zephyr/shell/shell.h> -#include <zephyr/ztest.h> - #include "console.h" #include "ec_commands.h" #include "test/drivers/stubs.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include <zephyr/fff.h> +#include <zephyr/shell/shell.h> +#include <zephyr/ztest.h> + #define TEST_PORT USBC_PORT_C0 #define BAD_PORT 82 @@ -23,7 +23,7 @@ ZTEST_USER(host_cmd_pd_control, test_bad_index) struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params); - zassume_true(board_get_usb_pd_port_count() < BAD_PORT, + zassert_true(board_get_usb_pd_port_count() < BAD_PORT, "Intended bad port exists"); zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM, "Failed to fail pd_control for port %d", params.chip); @@ -47,7 +47,7 @@ ZTEST_USER(host_cmd_pd_control, test_pd_reset_resume) * the only HC return which would cover this is a state string, which * could be brittle. */ - zassume_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning"); + zassert_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning"); host_cmd_pd_control(TEST_PORT, PD_RESET); @@ -76,7 +76,7 @@ ZTEST_USER(host_cmd_pd_control, test_suspend_resume) * the only HC return which would cover this is a state string, which * could be brittle. */ - zassume_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning"); + zassert_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning"); host_cmd_pd_control(TEST_PORT, PD_SUSPEND); @@ -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, @@ -117,7 +131,7 @@ static void host_cmd_pd_control_begin(void *data) ARG_UNUSED(data); /* Assume we have at least one USB-C port */ - zassume_true(board_get_usb_pd_port_count() > 0, + zassert_true(board_get_usb_pd_port_count() > 0, "Insufficient TCPCs found"); /* Set the system into S0, since the AP would drive these commands */ |