From f7a6d254f6702b64efada585f48b3be91ba1b836 Mon Sep 17 00:00:00 2001 From: Deepika Date: Fri, 22 Feb 2019 16:19:23 -0600 Subject: [PATCH] rand() by default does increment of 1, randomizing more Random number generation in case of IAR 8, requires TLS support. Thread local storage is not part of Mbed OS, test is updated to have random numbers sparse, but in future random number creation should be moved to main thread, or use some other logic for randomization instead of rand() call. --- .../COMPONENT_SPIF/TESTS/block_device/spif/main.cpp | 5 +++-- .../storage/TESTS/blockdevice/general_block_device/main.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/storage/blockdevice/COMPONENT_SPIF/TESTS/block_device/spif/main.cpp b/components/storage/blockdevice/COMPONENT_SPIF/TESTS/block_device/spif/main.cpp index ad2b2636ed..7abc49a074 100644 --- a/components/storage/blockdevice/COMPONENT_SPIF/TESTS/block_device/spif/main.cpp +++ b/components/storage/blockdevice/COMPONENT_SPIF/TESTS/block_device/spif/main.cpp @@ -49,8 +49,9 @@ void basic_erase_program_read_test(SPIFBlockDevice &block_device, bd_size_t bloc _mutex->lock(); // Make sure block address per each test is unique - static unsigned block_seed = 1; - srand(block_seed++); + static unsigned block_seed = SPIF_TEST_NUM_OF_THREADS; + srand(block_seed); + block_seed += 2; // Find a random block bd_addr_t block = (rand() * block_size) % block_device.size(); diff --git a/features/storage/TESTS/blockdevice/general_block_device/main.cpp b/features/storage/TESTS/blockdevice/general_block_device/main.cpp index fecfe1a0db..22f2a554b8 100644 --- a/features/storage/TESTS/blockdevice/general_block_device/main.cpp +++ b/features/storage/TESTS/blockdevice/general_block_device/main.cpp @@ -189,8 +189,9 @@ void basic_erase_program_read_test(BlockDevice *block_device, bd_size_t block_si _mutex->lock(); // Make sure block address per each test is unique - static unsigned block_seed = 1; - srand(block_seed++); + static unsigned block_seed = TEST_NUM_OF_THREADS; + srand(block_seed); + block_seed += 2; // Find a random block bd_addr_t block = (rand() * block_size) % (block_device->size());