summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/default/src/flash.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/test/drivers/default/src/flash.c')
-rw-r--r--zephyr/test/drivers/default/src/flash.c88
1 files changed, 15 insertions, 73 deletions
diff --git a/zephyr/test/drivers/default/src/flash.c b/zephyr/test/drivers/default/src/flash.c
index e0c6743cde..6794ca2878 100644
--- a/zephyr/test/drivers/default/src/flash.c
+++ b/zephyr/test/drivers/default/src/flash.c
@@ -3,13 +3,6 @@
* found in the LICENSE file.
*/
-#include "ec_commands.h"
-#include "emul/emul_flash.h"
-#include "flash.h"
-#include "host_command.h"
-#include "system.h"
-#include "test/drivers/test_state.h"
-
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/gpio/gpio_emul.h>
@@ -17,6 +10,13 @@
#include <zephyr/shell/shell_dummy.h>
#include <zephyr/ztest.h>
+#include "ec_commands.h"
+#include "emul/emul_flash.h"
+#include "flash.h"
+#include "host_command.h"
+#include "system.h"
+#include "test/drivers/test_state.h"
+
#define WP_L_GPIO_PATH DT_PATH(named_gpios, wp_l)
static int gpio_wp_l_set(int value)
@@ -135,17 +135,6 @@ ZTEST_USER(flash, test_hostcmd_flash_protect_wp_deasserted)
response.flags);
}
-ZTEST_USER(flash, test_hostcmd_flash_read__overflow)
-{
- struct ec_params_flash_read params = {
- .size = 32,
- };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_FLASH_READ, 0, params);
-
- zassert_equal(EC_RES_OVERFLOW, host_command_process(&args));
-}
-
#define TEST_BUF_SIZE 0x100
ZTEST_USER(flash, test_hostcmd_flash_write_and_erase)
@@ -263,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_1)
+ZTEST_USER(flash, test_hostcmd_flash_info)
{
struct ec_response_flash_info_1 response;
struct host_cmd_handler_args args =
@@ -291,50 +280,6 @@ ZTEST_USER(flash, test_hostcmd_flash_info_1)
"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();
@@ -364,15 +309,12 @@ ZTEST_USER(flash, test_console_cmd_flash_info)
sprintf(format_buffer, "Protect: %4d B", CONFIG_FLASH_BANK_SIZE);
zassert_not_null(strstr(outbuffer, format_buffer));
- zassert_not_null(strstr(outbuffer, "wp_gpio_asserted: ON"));
- zassert_not_null(strstr(outbuffer, "ro_at_boot: OFF"));
- zassert_not_null(strstr(outbuffer, "all_at_boot: OFF"));
- zassert_not_null(strstr(outbuffer, "ro_now: OFF"));
- zassert_not_null(strstr(outbuffer, "all_now: OFF"));
- zassert_not_null(strstr(outbuffer, "STUCK: OFF"));
- zassert_not_null(strstr(outbuffer, "INCONSISTENT: OFF"));
- zassert_not_null(strstr(outbuffer, "UNKNOWN_ERROR: OFF"));
+ zassert_not_null(strstr(outbuffer, "wp_gpio_asserted"));
zassert_not_null(strstr(outbuffer, "Protected now"));
+ /*
+ * TODO(b/254926324): Fake crec_flash_get_protect() to get more
+ * flag messages.
+ */
}
ZTEST_USER(flash, test_console_cmd_flashwp__invalid)
@@ -472,7 +414,7 @@ static void setup_flash_region_helper(uint32_t offset, uint32_t size,
int rv;
rv = host_command_process(&erase_args);
- zassert_ok(rv, "Got %d", rv);
+ zassume_ok(rv, "Got %d", rv);
if (make_write) {
/* Sized for flash_write header plus one byte of data */
@@ -492,7 +434,7 @@ static void setup_flash_region_helper(uint32_t offset, uint32_t size,
/* Write one byte at start of region */
out_buf[sizeof(*write_params)] = 0xec;
- zassert_ok(host_command_process(&write_args), NULL);
+ zassume_ok(host_command_process(&write_args), NULL);
}
}