diff options
author | Abe Levkoy <alevkoy@chromium.org> | 2022-10-17 17:09:56 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-18 23:04:45 +0000 |
commit | 980ba3ad06699be1dd4ec44b89790d5fac22a287 (patch) | |
tree | 4d3fed0b11bddccd00aa5d88613b3f484cada070 | |
parent | 6c7e03d4ae723c26fa397e14acbef44c67ce5e94 (diff) | |
download | chrome-ec-980ba3ad06699be1dd4ec44b89790d5fac22a287.tar.gz |
zephyr test: EC_CMD_TYPEC_STATUS invalid params
Verify that invalid parameters to the Type-C status command result in
errors.
BUG=b:236075106
TEST=twister -s zephyr/test/drivers/drivers.host_cmd
BRANCH=none
Signed-off-by: Abe Levkoy <alevkoy@chromium.org>
Change-Id: Ifdf0aa41b105a6c36f6df776197055fddd12b5bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3961321
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Aaron Massey <aaronmassey@google.com>
-rw-r--r-- | zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c b/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c index f790567970..3afc90760a 100644 --- a/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c +++ b/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c @@ -159,5 +159,22 @@ ZTEST_USER(usb_pd_host_cmd, test_typec_control_invalid_args) zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); } +ZTEST_USER(usb_pd_host_cmd, test_typec_status_invalid_args) +{ + struct ec_params_typec_status params = { + .port = 100, + }; + struct ec_response_typec_status response; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_TYPEC_STATUS, 0, response, params); + + /* An invalid port should result in an error. */ + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); + + params.port = 0; + args.response_max = sizeof(struct ec_response_typec_status) - 1; + zassert_equal(host_command_process(&args), EC_RES_RESPONSE_TOO_BIG); +} + ZTEST_SUITE(usb_pd_host_cmd, drivers_predicate_post_main, NULL, NULL, NULL, NULL); |