summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Peress <peress@google.com>2022-05-02 16:28:10 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-03 19:38:53 +0000
commit24866f37b9ad93425aeeb93a130e5acc5873cc9b (patch)
tree97fbd97b4faf8f9bea1fd986d0ca54658a94210a
parent1913306bbef3310807d4c87a5fe1a10fc6b9caf6 (diff)
downloadchrome-ec-24866f37b9ad93425aeeb93a130e5acc5873cc9b.tar.gz
test: add tests for motion sense fifo info host command
BRANCH=none BUG=b:224614211 TEST=zmake test test-drivers Signed-off-by: Yuval Peress <peress@google.com> Change-Id: If9d372a33d095d6a5d8708758271042ea18ab0fc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3621799 Reviewed-by: Tristan Honscheid <honscheid@google.com>
-rw-r--r--zephyr/test/drivers/include/test/drivers/utils.h8
-rw-r--r--zephyr/test/drivers/src/host_cmd/motion_sense.c12
-rw-r--r--zephyr/test/drivers/src/utils.c11
3 files changed, 31 insertions, 0 deletions
diff --git a/zephyr/test/drivers/include/test/drivers/utils.h b/zephyr/test/drivers/include/test/drivers/utils.h
index a3be9f3281..d38eed3297 100644
--- a/zephyr/test/drivers/include/test/drivers/utils.h
+++ b/zephyr/test/drivers/include/test/drivers/utils.h
@@ -375,6 +375,14 @@ int host_cmd_motion_sense_fifo_flush(uint8_t sensor_num,
struct ec_response_motion_sense *response);
/**
+ * @brief Get the current fifo info
+ *
+ * @param response Pointer to the response data structure to fill on success
+ * @return The result code from the host command
+ */
+int host_cmd_motion_sense_fifo_info(struct ec_response_motion_sense *response);
+
+/**
* Run the host command to get the PD discovery responses.
*
* @param port The USB-C port number
diff --git a/zephyr/test/drivers/src/host_cmd/motion_sense.c b/zephyr/test/drivers/src/host_cmd/motion_sense.c
index 245769265c..5b4b82b6d1 100644
--- a/zephyr/test/drivers/src/host_cmd/motion_sense.c
+++ b/zephyr/test/drivers/src/host_cmd/motion_sense.c
@@ -668,3 +668,15 @@ ZTEST(host_cmd_motion_sense, test_fifo_flush)
zassert_equal(5, response->fifo_info.lost[0], NULL);
zassert_equal(0, motion_sensors[0].lost, NULL);
}
+
+ZTEST(host_cmd_motion_sense, test_fifo_info)
+{
+ uint8_t response_buffer[RESPONSE_SENSOR_FIFO_SIZE(ALL_MOTION_SENSORS)];
+ struct ec_response_motion_sense *response =
+ (struct ec_response_motion_sense *)response_buffer;
+
+ motion_sensors[0].lost = 4;
+ zassert_ok(host_cmd_motion_sense_fifo_info(response), NULL);
+ zassert_equal(4, response->fifo_info.lost[0], NULL);
+ zassert_equal(0, motion_sensors[0].lost, NULL);
+}
diff --git a/zephyr/test/drivers/src/utils.c b/zephyr/test/drivers/src/utils.c
index ee90b41876..eb639f32b5 100644
--- a/zephyr/test/drivers/src/utils.c
+++ b/zephyr/test/drivers/src/utils.c
@@ -264,6 +264,17 @@ int host_cmd_motion_sense_fifo_flush(uint8_t sensor_num,
return host_command_process(&args);
}
+int host_cmd_motion_sense_fifo_info(struct ec_response_motion_sense *response)
+{
+ struct ec_params_motion_sense params = {
+ .cmd = MOTIONSENSE_CMD_FIFO_INFO,
+ };
+ struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
+ EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
+
+ return host_command_process(&args);
+}
+
void host_cmd_typec_discovery(int port, enum typec_partner_type partner_type,
void *response, size_t response_size)
{