summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2022-10-17 12:40:08 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-17 21:25:21 +0000
commit3bcfee387813480b6e005a77f58101fa578b7ea2 (patch)
tree6e8e4ae227f5cb60d2ba1703c9c01cac33ad6262
parente82fb744a9596e411d568926e27640c4494f547e (diff)
downloadchrome-ec-3bcfee387813480b6e005a77f58101fa578b7ea2.tar.gz
zephyr test: EC_CMD_TYPEC_DISCOVERY invalid args
Verify that getting discovery data fails with and invalid port number or invalid SOP type. BUG=b:236075403 TEST=twister -s zephyr/test/drivers/drivers.host_cmd BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I03e06e5d7505b162e12e69016ad071d1ac08a6a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3960779 Reviewed-by: Aaron Massey <aaronmassey@google.com> Commit-Queue: 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.c22
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);