summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Peress <peress@google.com>2022-11-16 02:52:40 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-18 14:42:40 +0000
commit4f6def440f575126fae7db8f1bb9a50716f6b5bb (patch)
tree0f18e68d03936043d48aad9c2c2fe3bce3b36831
parent6d80b51050df216c0589f31b1ff457f7f5308910 (diff)
downloadchrome-ec-4f6def440f575126fae7db8f1bb9a50716f6b5bb.tar.gz
test: add tests for flash info 2 host command
Verify that the flash info v2 command works as expected producing the correct number of banks for the test binary). BRANCH=none BUG=none TEST=twister Change-Id: I79e7b81d90eb6b6d56ca1fbbdc70cd1c91f42625 Signed-off-by: Yuval Peress <peress@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030063 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--zephyr/test/drivers/default/src/flash.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/zephyr/test/drivers/default/src/flash.c b/zephyr/test/drivers/default/src/flash.c
index 71d6853653..958585c61e 100644
--- a/zephyr/test/drivers/default/src/flash.c
+++ b/zephyr/test/drivers/default/src/flash.c
@@ -252,7 +252,7 @@ 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)
+ZTEST_USER(flash, test_hostcmd_flash_info_1)
{
struct ec_response_flash_info_1 response;
struct host_cmd_handler_args args =
@@ -280,6 +280,50 @@ ZTEST_USER(flash, test_hostcmd_flash_info)
"response.write_ideal_size = %d", response.write_ideal_size);
}
+ZTEST_USER(flash, test_hostcmd_flash_info_2)
+{
+ uint8_t response_buffer[sizeof(struct ec_response_flash_info_2) +
+ sizeof(struct ec_flash_bank)];
+ struct ec_response_flash_info_2 *response =
+ (struct ec_response_flash_info_2 *)response_buffer;
+ struct ec_params_flash_info_2 params = {
+ .num_banks_desc = 1,
+ };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND(EC_CMD_FLASH_INFO, 2, *response, params);
+
+ /* Get the flash info. */
+ zassert_ok(host_command_process(&args), NULL);
+ zassert_equal(response->flash_size,
+ CONFIG_FLASH_SIZE_BYTES - EC_FLASH_REGION_START, "got %d",
+ response->flash_size);
+ zassert_equal(response->flags, 0, "got %d", response->flags);
+ zassert_equal(
+ response->write_ideal_size,
+ (args.response_max - sizeof(struct ec_params_flash_write)) &
+ ~(CONFIG_FLASH_WRITE_SIZE - 1),
+ "got %d", response->write_ideal_size);
+ zassert_equal(response->num_banks_total, 1, "got %d",
+ response->num_banks_total);
+ zassert_equal(response->num_banks_desc, 1, "got %d",
+ response->num_banks_desc);
+ zassert_equal(response->banks[0].count,
+ CONFIG_FLASH_SIZE_BYTES / CONFIG_FLASH_BANK_SIZE,
+ "got %d", response->banks[0].count);
+ zassert_equal(response->banks[0].size_exp,
+ __fls(CONFIG_FLASH_BANK_SIZE), "got %d",
+ response->banks[0].size_exp);
+ zassert_equal(response->banks[0].write_size_exp,
+ __fls(CONFIG_FLASH_WRITE_SIZE), "got %d",
+ response->banks[0].write_size_exp);
+ zassert_equal(response->banks[0].erase_size_exp,
+ __fls(CONFIG_FLASH_ERASE_SIZE), "got %d",
+ response->banks[0].erase_size_exp);
+ zassert_equal(response->banks[0].protect_size_exp,
+ __fls(CONFIG_FLASH_BANK_SIZE), "got %d",
+ response->banks[0].protect_size_exp);
+}
+
ZTEST_USER(flash, test_console_cmd_flash_info)
{
const struct shell *shell_zephyr = get_ec_shell();