diff options
author | Abe Levkoy <alevkoy@chromium.org> | 2022-10-17 17:01:45 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-18 20:11:52 +0000 |
commit | 4d493c2f5de36ff41afb72a15391f74bdc5ef38d (patch) | |
tree | 045c4d9ed1ba327e00d224f53b8e15f3e33da828 | |
parent | a13ed8771e1751ea6966e21b5c73078f1df8b02c (diff) | |
download | chrome-ec-4d493c2f5de36ff41afb72a15391f74bdc5ef38d.tar.gz |
zephyr test: EC_CMD_TYPEC_CONTROL invalid params
Verify that invalid parameters passed to Type-C control host command
produce error results.
BUG=b:236075405
TEST=twister -s zephyr/test/drivers/drivers.host_cmd
BRANCH=none
Signed-off-by: Abe Levkoy <alevkoy@chromium.org>
Change-Id: I9e9ac49915d7b8db19d2df5b31161156f7abdfd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3961320
Commit-Queue: Aaron Massey <aaronmassey@google.com>
Reviewed-by: Aaron Massey <aaronmassey@google.com>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r-- | zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c | 21 |
1 files changed, 21 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 5ff41da4bc..f790567970 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 @@ -138,5 +138,26 @@ ZTEST_USER(usb_pd_host_cmd, test_typec_discovery_invalid_args) zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); } +ZTEST_USER(usb_pd_host_cmd, test_typec_control_invalid_args) +{ + struct ec_params_typec_control params = { + .port = 0, + .command = TYPEC_CONTROL_COMMAND_TBT_UFP_REPLY, + }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params); + + /* Setting the TBT UFP responses is not supported by default. */ + zassert_equal(host_command_process(&args), EC_RES_UNAVAILABLE); + + /* Neither is mux setting. */ + params.command = TYPEC_CONTROL_COMMAND_USB_MUX_SET; + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); + + /* This is not a valid enum value but should be representable. */ + params.command = 0xff; + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); +} + ZTEST_SUITE(usb_pd_host_cmd, drivers_predicate_post_main, NULL, NULL, NULL, NULL); |