summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-07-15 10:17:20 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-31 18:33:19 +0000
commited87c0c1ade57ab6e8bd46a11a2f0484a503f1b8 (patch)
treefc57a496d2c73b9dc4f5a5727c0e7771aa9dbf2f /include
parent003ec08f8c67845ae8481d3fb4124555213b04c4 (diff)
downloadchrome-ec-ed87c0c1ade57ab6e8bd46a11a2f0484a503f1b8.tar.gz
zephyr: test: drivers: add eSPI test using host command
Verify that we can call host commands from driver tests by adding a test that calls the EC_CMD_GET_PROTOCOL_INFO host command. Add a few convenience functions to host_command.h when building with CONFIG_ZTEST enabled. Also, add eSPI emulator to support the test. Coverage: - lines 17.4% -> 17.8% - functions 21.4% -> 22.0% BRANCH=none BUG=b:189954415 TEST=zmake configure --test zephyr/test/drivers Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ib9e750eeab555ea629a560cbf3beed28e346c460 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3031842 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/host_command.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/host_command.h b/include/host_command.h
index 15cca98d96..ccf86214aa 100644
--- a/include/host_command.h
+++ b/include/host_command.h
@@ -349,4 +349,20 @@ void host_send_sysrq(uint8_t key);
uint32_t get_feature_flags0(void);
uint32_t get_feature_flags1(void);
+#ifdef CONFIG_ZTEST
+static inline void
+stub_send_response_callback(struct host_cmd_handler_args *args)
+{
+ ARG_UNUSED(args);
+}
+
+#define BUILD_HOST_COMMAND(CMD, VERSION, RESPONSE) \
+ { \
+ .command = (CMD), .version = (VERSION), \
+ .send_response = stub_send_response_callback, \
+ .response = &(RESPONSE), .response_max = sizeof(RESPONSE), \
+ .response_size = sizeof(RESPONSE) \
+ }
+#endif /* CONFIG_ZTEST */
+
#endif /* __CROS_EC_HOST_COMMAND_H */