summaryrefslogtreecommitdiff
path: root/common/host_command.c
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-06-19 16:00:03 -0700
committerChromeBot <chrome-bot@google.com>2013-06-20 16:47:06 -0700
commite493e7a01333fb0894cbcbc41cd1ec70906a2081 (patch)
tree30692c39979929f5785f44dbbd58e36df2612105 /common/host_command.c
parentb839e6524193b61bad0f5ce935b45f48e26d23c0 (diff)
downloadchrome-ec-e493e7a01333fb0894cbcbc41cd1ec70906a2081.tar.gz
Add EC_CMD_TEST_PROTOCOL to fake certain responses.
This lets us force the EC to return various error codes, so that we can be sure we're seeing them. BUG=chromium:242706 BRANCH=none TEST=none Trigger various errors like so: ectool test 0 14 ectool test 1 14 ectool test 5 14 ectool test 8 14 ectool test 0 33 Change-Id: Ia951cd7afacdcce6c8ec7d35d3bfb5b113dea694 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/59327 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/host_command.c')
-rw-r--r--common/host_command.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/common/host_command.c b/common/host_command.c
index bf310991b6..fe270d013a 100644
--- a/common/host_command.c
+++ b/common/host_command.c
@@ -525,6 +525,23 @@ DECLARE_HOST_COMMAND(EC_CMD_RESEND_RESPONSE,
EC_VER_MASK(0));
#endif /* CONFIG_HOST_COMMAND_STATUS */
+/* Returns what we tell it to. */
+static int host_command_test_protocol(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_test_protocol *p = args->params;
+ struct ec_response_test_protocol *r = args->response;
+ int copy_len = MIN(p->ret_len, sizeof(r->buf)); /* p,r bufs same size */
+
+ memset(r->buf, 0, sizeof(r->buf));
+ memcpy(r->buf, p->buf, copy_len);
+ args->response_size = p->ret_len;
+
+ return p->ec_result;
+}
+DECLARE_HOST_COMMAND(EC_CMD_TEST_PROTOCOL,
+ host_command_test_protocol,
+ EC_VER_MASK(0));
+
/*****************************************************************************/
/* Console commands */