diff options
author | Wai-Hong Tam <waihong@google.com> | 2022-08-24 09:30:52 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-08-25 00:34:47 +0000 |
commit | 590f8816b4df5c360706ea4054676f63df424721 (patch) | |
tree | da9de8071cf17414e574afc1c19b9d8313582512 | |
parent | 8b1cc0ef3a5aa1b87530c8743bf7bceb95d4f111 (diff) | |
download | chrome-ec-590f8816b4df5c360706ea4054676f63df424721.tar.gz |
zephyr: test: Add a new vboot_hash test to hash arbitrary size
Add a new test to hash arbitrary size. It hits more coverage.
BRANCH=None
BUG=b:236161107
TEST=./twister -s zephyr/test/drivers/drivers.default
Change-Id: Iad34de0d5969c72f130dff401b0b7bf4dc1c6fce
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3854313
Reviewed-by: Aaron Massey <aaronmassey@google.com>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r-- | zephyr/test/drivers/default/src/vboot_hash.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/zephyr/test/drivers/default/src/vboot_hash.c b/zephyr/test/drivers/default/src/vboot_hash.c index a0b5ddc3fe..46f0731058 100644 --- a/zephyr/test/drivers/default/src/vboot_hash.c +++ b/zephyr/test/drivers/default/src/vboot_hash.c @@ -77,4 +77,27 @@ ZTEST_USER(vboot_hash, test_hostcmd_recalc) "response.digest_size = %d", response.digest_size); } +ZTEST_USER(vboot_hash, test_hostcmd_hash_arbitrary_size) +{ + struct ec_response_vboot_hash response; + struct ec_params_vboot_hash recalc_params = { + .cmd = EC_VBOOT_HASH_RECALC, + .hash_type = EC_VBOOT_HASH_TYPE_SHA256, + .offset = 0, + /* arbitrary size */ + .size = 0x12345, + }; + struct host_cmd_handler_args recalc_args = BUILD_HOST_COMMAND( + EC_CMD_VBOOT_HASH, 0, response, recalc_params); + + /* Recalculate the hash. The command waits to finish. */ + zassert_ok(host_command_process(&recalc_args), NULL); + zassert_ok(recalc_args.result, NULL); + zassert_equal(recalc_args.response_size, sizeof(response), NULL); + zassert_equal(response.status, EC_VBOOT_HASH_STATUS_DONE, + "response.status = %d", response.status); + zassert_equal(response.digest_size, SHA256_DIGEST_SIZE, + "response.digest_size = %d", response.digest_size); +} + ZTEST_SUITE(vboot_hash, drivers_predicate_post_main, NULL, NULL, NULL, NULL); |