diff options
author | Jeremy Bettis <jbettis@google.com> | 2022-01-24 16:26:18 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-25 14:59:07 +0000 |
commit | 75ab33ec488f977e5b6c31ae7bef3219cc82cf40 (patch) | |
tree | 45b92c010bab0ed0aeb6afcc318322a83f04fbda /zephyr/test/drivers/src/usb_pd_host_cmd.c | |
parent | 43c6a470089992920639dce56cbadabc86c361bc (diff) | |
download | chrome-ec-75ab33ec488f977e5b6c31ae7bef3219cc82cf40.tar.gz |
zephyr: Add some coverage to usb_pd_host_cmd
Include common/usb_pd_host_cmd.c into test/drivers, add test for the
smallest host command.
BRANCH=None
BUG=b:214256453
TEST=Added
Signed-off-by: Jeremy Bettis <jbettis@google.com>
Change-Id: I723d2420415fe828033bd546867e1696eca9b0f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3413821
Tested-by: Jeremy Bettis <jbettis@chromium.org>
Auto-Submit: Jeremy Bettis <jbettis@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/test/drivers/src/usb_pd_host_cmd.c')
-rw-r--r-- | zephyr/test/drivers/src/usb_pd_host_cmd.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/zephyr/test/drivers/src/usb_pd_host_cmd.c b/zephyr/test/drivers/src/usb_pd_host_cmd.c new file mode 100644 index 0000000000..61f2915ec5 --- /dev/null +++ b/zephyr/test/drivers/src/usb_pd_host_cmd.c @@ -0,0 +1,32 @@ +/* Copyright 2022 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <zephyr.h> +#include <ztest.h> + +#include "ec_commands.h" +#include "host_command.h" + +static void test_host_command_hc_pd_ports(void) +{ + struct ec_response_usb_pd_ports response; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_RESPONSE(EC_CMD_USB_PD_PORTS, 0, + response); + + zassert_ok(host_command_process(&args), NULL); + zassert_ok(args.result, NULL); + zassert_equal(args.response_size, sizeof(response), NULL); + zassert_equal(response.num_ports, + CONFIG_PLATFORM_EC_USB_PD_PORT_MAX_COUNT, NULL); +} + +void test_suite_usb_pd_host_cmd(void) +{ + ztest_test_suite(usb_pd_host_cmd, + ztest_user_unit_test( + test_host_command_hc_pd_ports)); + ztest_run_test_suite(usb_pd_host_cmd); +} |