Skip to content

Commit 8c68f5c

Browse files
committed
test: drivers: flash: common: Copied size can't exceed page.size
flash_copy() is performed on a page.size span but following flash_read() verification step is performed on EXPECTED_SIZE length (512). This doesn't work on devices where page.size is lower than EXPECTED_SIZE, such as STM32L1 where page size is 256. To fix this, perform verification on the smalest value between page.size and EXPECTED_SIZE. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent c5caa12 commit 8c68f5c

File tree

1 file changed

+4
-2
lines changed
  • tests/drivers/flash/common/src

1 file changed

+4
-2
lines changed

tests/drivers/flash/common/src/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,10 @@ static void test_flash_copy_inner(const struct device *src_dev, off_t src_offset
397397

398398
if ((expected_result == 0) && (size != 0) && (src_offset != dst_offset)) {
399399
/* verify a successful copy */
400-
zassert_ok(flash_read(flash_dev, TEST_AREA_OFFSET, expected, EXPECTED_SIZE));
401-
for (int i = 0; i < EXPECTED_SIZE; i++) {
400+
off_t copy_size = MIN(size, EXPECTED_SIZE);
401+
402+
zassert_ok(flash_read(flash_dev, TEST_AREA_OFFSET, expected, copy_size));
403+
for (int i = 0; i < copy_size; i++) {
402404
zassert_equal(buf[i], 0xaa, "incorrect data (%02x) at %d", buf[i], i);
403405
}
404406
}

0 commit comments

Comments
 (0)