tests: drivers: flash: common: Fix page size when no erase is required
When no flash device requires erase, this test does not retrieve flash page size with flash_get_page_info_by_offs(), but instead it takes an arbitrary page size based on the test area length. Since the test_flash_copy routine needs to use two pages, the test area needs to be split into at least two parts. Correct the related code and add a check if test_flash_copy requirements are met. Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This commit is contained in:
parent
15a057c8f6
commit
fb94343ce4
@ -87,7 +87,8 @@ static void flash_driver_before(void *arg)
|
||||
TC_PRINT("No devices with erase requirement present\n");
|
||||
erase_value = 0x55;
|
||||
page_info.start_offset = TEST_AREA_OFFSET;
|
||||
page_info.size = TEST_AREA_MAX - TEST_AREA_OFFSET;
|
||||
/* test_flash_copy uses 2 pages, so split the test area */
|
||||
page_info.size = (TEST_AREA_MAX - TEST_AREA_OFFSET) / 2;
|
||||
}
|
||||
|
||||
|
||||
@ -111,6 +112,10 @@ static void flash_driver_before(void *arg)
|
||||
zassert_true((TEST_AREA_OFFSET + EXPECTED_SIZE) <= TEST_AREA_MAX,
|
||||
"Test area exceeds flash size");
|
||||
|
||||
/* Check if test region is suitable for test_flash_copy */
|
||||
zassert_true((TEST_AREA_OFFSET + 2 * page_info.size) <= TEST_AREA_MAX,
|
||||
"test_flash_copy needs 2 flash pages");
|
||||
|
||||
/* Check if flash is cleared */
|
||||
if (IS_ENABLED(CONFIG_FLASH_HAS_EXPLICIT_ERASE) && ebw_required) {
|
||||
bool is_buf_clear = true;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user