summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2022-10-17 12:44:17 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-17 22:34:26 +0000
commit319ef2112e2ea4f6f39e9b62fb354389b9281774 (patch)
tree81224792b70024ef1d1e6da8f9a1c76ac8ad624c
parent138377a2b74cbb6fcee7d63fc28c171232bc2125 (diff)
downloadchrome-ec-319ef2112e2ea4f6f39e9b62fb354389b9281774.tar.gz
zephyr test: EC_CMD_TYPEC_DISCOVERY response size
Verify that getting discovery data does not return discovered SVIDs when the provided response buffer does not contain enough space for them. BUG=b:236075403 TEST=twister -s zephyr/test/drivers/drivers.usbc_alt_mode BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I6ae934dd4781a158c73c952c13aadc0c87c77930 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3960780 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com>
-rw-r--r--zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c
index d255fe734c..43ccc3b3f3 100644
--- a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c
+++ b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c
@@ -201,6 +201,19 @@ ZTEST_F(usbc_alt_mode, verify_discovery)
"DP mode VDOs did not match");
}
+ZTEST_F(usbc_alt_mode, verify_discovery_params_too_small)
+{
+ struct ec_response_typec_discovery discovery;
+
+ /* The expected size of the response buffer is larger than struct
+ * ec_response_typec_discovery. With only that amount of space, the
+ * command should succeed but not return any of the discovered SVIDs.
+ */
+ host_cmd_typec_discovery(TEST_PORT, TYPEC_PARTNER_SOP, &discovery,
+ sizeof(discovery));
+ zassert_equal(discovery.svid_count, 0);
+}
+
ZTEST_F(usbc_alt_mode, verify_displayport_mode_entry)
{
if (IS_ENABLED(CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY)) {