From 4ea3e478f43ccd3eb9efe3b565989ce969738ceb Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Mar 2022 16:49:37 -0600 Subject: zephyr: Add trivial test of vboot_hash This only tests the host command EC_VBOOT_HASH_START, which doesn't really do anything, but it is a stub for the next person to add more test cases. BRANCH=None BUG=b:214256453 TEST=zmake test -a Signed-off-by: Jeremy Bettis Change-Id: Icdde811128b66c610eaa37b16d4626728273d287 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3543484 Tested-by: Jeremy Bettis Auto-Submit: Jeremy Bettis Reviewed-by: Aaron Massey Commit-Queue: Jeremy Bettis --- zephyr/test/drivers/CMakeLists.txt | 1 + zephyr/test/drivers/prj.conf | 1 + zephyr/test/drivers/src/vboot_hash.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 zephyr/test/drivers/src/vboot_hash.c diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index b2718ca08c..efcdf1f300 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -55,5 +55,6 @@ target_sources(app PRIVATE src/usb_mux.c src/usb_pd_host_cmd.c src/utils.c + src/vboot_hash.c src/watchdog.c ) diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index aa156388ab..8aea6c09c4 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -156,3 +156,4 @@ CONFIG_EMUL_KB_RAW=y CONFIG_EMUL_CROS_FLASH=y CONFIG_FLASH_SIMULATOR=y CONFIG_FLASH=y +CONFIG_PLATFORM_EC_VBOOT_HASH=y diff --git a/zephyr/test/drivers/src/vboot_hash.c b/zephyr/test/drivers/src/vboot_hash.c new file mode 100644 index 0000000000..841893c61b --- /dev/null +++ b/zephyr/test/drivers/src/vboot_hash.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 +#include +#include + +#include "ec_commands.h" +#include "host_command.h" +#include "test_state.h" + +ZTEST_USER(vboot_hash, test_hostcmd) +{ + struct ec_params_vboot_hash params = { + .cmd = EC_VBOOT_HASH_START, + .offset = 0, + .size = 0, + }; + struct ec_response_vboot_hash response; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_VBOOT_HASH, 0, response, params); + + zassert_ok(host_command_process(&args), NULL); + zassert_ok(args.result, NULL); + zassert_equal(args.response_size, sizeof(response), NULL); + zassert_equal(response.status, EC_VBOOT_HASH_STATUS_BUSY, + "response.status = %d", response.status); +} + +ZTEST_SUITE(vboot_hash, drivers_predicate_post_main, NULL, NULL, NULL, NULL); -- cgit v1.2.1