Skip to content

Commit be1c887

Browse files
author
offirko
committed
Ensure unique block address for multi threaded test.
The addresses dont have to change each run, just be unique. Because address seeds repeat themselves each run, rand() will produce repeating results that should not collide between different threads.
1 parent 4bbc2cd commit be1c887

File tree

1 file changed

+5
-0
lines changed
  • components/storage/blockdevice/COMPONENT_SPIF/TESTS/block_device/spif

1 file changed

+5
-0
lines changed

components/storage/blockdevice/COMPONENT_SPIF/TESTS/block_device/spif/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ void basic_erase_program_read_test(SPIFBlockDevice &block_device, bd_size_t bloc
4747
{
4848
int err = 0;
4949
_mutex->lock();
50+
51+
// Make sure block address per each test is unique
52+
static unsigned block_seed = 1;
53+
srand(block_seed++);
54+
5055
// Find a random block
5156
bd_addr_t block = (rand() * block_size) % block_device.size();
5257

0 commit comments

Comments
 (0)