Skip to content

Commit 76cf78d

Browse files
committed
general_block_device: optimize test_contiguous_erase_write_read() buffer size for large-sector flashes
1 parent 4a47709 commit 76cf78d

File tree

1 file changed

+9
-2
lines changed
  • storage/blockdevice/tests/TESTS/blockdevice/general_block_device

1 file changed

+9
-2
lines changed

storage/blockdevice/tests/TESTS/blockdevice/general_block_device/main.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,15 @@ void test_contiguous_erase_write_read()
549549
utest_printf("contiguous_erase_size=0x%" PRIx64 "\n", contiguous_erase_size);
550550

551551
bd_size_t write_read_buf_size = program_size;
552-
if (contiguous_erase_size / program_size > 8 && contiguous_erase_size % (program_size * 8) == 0) {
553-
write_read_buf_size = program_size * 8;
552+
553+
// Reading/writing in larger chunks reduces the number of operations,
554+
// helping to avoid test timeouts. Try 256-byte chunks if contiguous_erase_size
555+
// (which should be a power of 2) is greater than that. If it's less than
556+
// that, the test finishes quickly anyway...
557+
if ((program_size < 256) && (256 % program_size == 0)
558+
&& (contiguous_erase_size >= 256) && (contiguous_erase_size % 256 == 0)) {
559+
utest_printf("using 256-byte write/read buffer\n");
560+
write_read_buf_size = 256;
554561
}
555562

556563
// Allocate write/read buffer

0 commit comments

Comments
 (0)