diff options
-rw-r--r-- | zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c | 22 |
1 files changed, 22 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 7a107cee89..5ff41da4bc 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 @@ -116,5 +116,27 @@ ZTEST_USER(usb_pd_host_cmd, test_host_command_hc_pd_ports) zassert_equal(response.num_ports, CONFIG_USB_PD_PORT_MAX_COUNT); } +ZTEST_USER(usb_pd_host_cmd, test_typec_discovery_invalid_args) +{ + struct ec_params_typec_discovery params = { + .port = 100, + .partner_type = TYPEC_PARTNER_SOP, + }; + struct ec_response_typec_discovery response; + /* A successful EC_CMD_TYPEC_DISCOVERY requires response to be larger + * than ec_params_typec_discovery, but this one is expected to fail, so + * the response size is irrelevant. + */ + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_TYPEC_DISCOVERY, 0, response, params); + + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); + + params.port = 0; + /* This is not a valid enum value but should be representable. */ + params.partner_type = 5; + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); +} + ZTEST_SUITE(usb_pd_host_cmd, drivers_predicate_post_main, NULL, NULL, NULL, NULL); |