summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2022-11-22 08:14:19 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-12-13 22:43:16 +0000
commit0085c1c5450c7992c2a5111414741d711a14ec65 (patch)
tree98194f5afcb0d9e43cd2080572e7b171412c426d
parent3a705db54bc6f87df6e3b63db08fa379e9b02708 (diff)
downloadchrome-ec-0085c1c5450c7992c2a5111414741d711a14ec65.tar.gz
Zephyr test: Add utility for VDM_RESPONSE HC
Add a utility which tests may use to fetch VDM responses, as the AP would. BRANCH=None BUG=b:208884535 TEST=./twister -T ./zephyr/test/drivers Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I7b713f7da1d18e78c854ae4f65714eae8e4cfd79 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4048913 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--zephyr/test/drivers/common/include/test/drivers/utils.h11
-rw-r--r--zephyr/test/drivers/common/src/utils.c12
2 files changed, 23 insertions, 0 deletions
diff --git a/zephyr/test/drivers/common/include/test/drivers/utils.h b/zephyr/test/drivers/common/include/test/drivers/utils.h
index 7be7dd5400..a39a36dc33 100644
--- a/zephyr/test/drivers/common/include/test/drivers/utils.h
+++ b/zephyr/test/drivers/common/include/test/drivers/utils.h
@@ -178,6 +178,17 @@ static inline struct ec_response_typec_status host_cmd_typec_status(int port)
return response;
}
+/**
+ * Run the host command to get the most recent VDM response for the AP
+ *
+ * This function asserts a successful host command processing and will make a
+ * call to the zassert_* API. A failure here will fail the calling test.
+ *
+ * @param port The USB port to get info from.
+ * @return The result of the query.
+ */
+struct ec_response_typec_vdm_response host_cmd_typec_vdm_response(int port);
+
static inline struct ec_response_usb_pd_control
host_cmd_usb_pd_control(int port, enum usb_pd_control_swap swap)
{
diff --git a/zephyr/test/drivers/common/src/utils.c b/zephyr/test/drivers/common/src/utils.c
index afea5edbac..669ea69592 100644
--- a/zephyr/test/drivers/common/src/utils.c
+++ b/zephyr/test/drivers/common/src/utils.c
@@ -606,6 +606,18 @@ void host_cmd_typec_control_vdm_req(int port, struct typec_vdm_req vdm_req)
"Failed to send Type-C control for port %d", port);
}
+struct ec_response_typec_vdm_response host_cmd_typec_vdm_response(int port)
+{
+ struct ec_params_typec_status params = { .port = port };
+ struct ec_response_typec_vdm_response response;
+ struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
+ EC_CMD_TYPEC_VDM_RESPONSE, 0, response, params);
+
+ zassert_ok(host_command_process(&args),
+ "Failed to get Type-C state for port %d", port);
+ return response;
+}
+
void host_cmd_usb_pd_get_amode(
uint8_t port, uint16_t svid_idx,
struct ec_params_usb_pd_get_mode_response *response, int *response_size)