summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2022-08-25 16:23:13 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-30 23:14:04 +0000
commit6ef60109477a09eb966813776a9fa847be6224f3 (patch)
tree50ca4225092c7df698ed65ac9759308702efcf9d
parent896f118b99bf38a24dd695b4c75df529b7f9f71c (diff)
downloadchrome-ec-6ef60109477a09eb966813776a9fa847be6224f3.tar.gz
zephyr: test: Add the flash info host command test
Add the test for the flash info host command. BRANCH=None BUG=b:236075281 TEST=./twister -s zephyr/test/drivers/drivers.default Change-Id: I6534ae8fffda0b895e541f97ef1be0c5b11b865a Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3866424 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Yuval Peress <peress@google.com> Reviewed-by: Yuval Peress <peress@google.com>
-rw-r--r--zephyr/test/drivers/default/src/flash.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/zephyr/test/drivers/default/src/flash.c b/zephyr/test/drivers/default/src/flash.c
index 6bb9d89d99..2660963d3c 100644
--- a/zephyr/test/drivers/default/src/flash.c
+++ b/zephyr/test/drivers/default/src/flash.c
@@ -251,6 +251,34 @@ ZTEST_USER(flash, test_hostcmd_flash_region_info_active_invalid)
zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM, NULL);
}
+ZTEST_USER(flash, test_hostcmd_flash_info)
+{
+ struct ec_response_flash_info_1 response;
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND_RESPONSE(EC_CMD_FLASH_INFO, 1, response);
+
+ /* Get the flash info. */
+ zassert_ok(host_command_process(&args), NULL);
+ zassert_equal(response.flash_size,
+ CONFIG_FLASH_SIZE_BYTES - EC_FLASH_REGION_START,
+ "response.flash_size = %d", response.flash_size);
+ zassert_equal(response.flags, 0, "response.flags = %d", response.flags);
+ zassert_equal(response.write_block_size, CONFIG_FLASH_WRITE_SIZE,
+ "response.write_block_size = %d",
+ response.write_block_size);
+ zassert_equal(response.erase_block_size, CONFIG_FLASH_ERASE_SIZE,
+ "response.erase_block_size = %d",
+ response.erase_block_size);
+ zassert_equal(response.protect_block_size, CONFIG_FLASH_BANK_SIZE,
+ "response.protect_block_size = %d",
+ response.protect_block_size);
+ zassert_equal(
+ response.write_ideal_size,
+ (args.response_max - sizeof(struct ec_params_flash_write)) &
+ ~(CONFIG_FLASH_WRITE_SIZE - 1),
+ "response.write_ideal_size = %d", response.write_ideal_size);
+}
+
static void flash_reset(void)
{
/* Set the GPIO WP_L to default */