mirror of https://github.com/ARMmbed/mbed-os.git
TDBStore Whitebox tests: fix memory check
Each block of HeapBlockDevice is only allocated from the heap when that block is programmed. And erasing a block frees the associated buffer. To decide if there is enough heap to run the TDBStore Whitebox tests, we need to perform a trial program() instead of erase().pull/14483/head
parent
aedc6009ea
commit
7b763be0e3
|
@ -132,11 +132,14 @@ static void white_box_test()
|
||||||
} else {
|
} else {
|
||||||
test_bd = &heap_bd;
|
test_bd = &heap_bd;
|
||||||
// We need to skip the test if we don't have enough memory for the heap block device.
|
// We need to skip the test if we don't have enough memory for the heap block device.
|
||||||
// However, this device allocates the erase units on the fly, so "erase" it via the flash
|
// However, this device allocates the blocks on the fly when programmed. A failure
|
||||||
// simulator. A failure here means we haven't got enough memory.
|
// here means we haven't got enough memory.
|
||||||
heap_bd.init();
|
result = heap_bd.init();
|
||||||
result = heap_bd.erase(0, heap_bd.size());
|
TEST_SKIP_UNLESS_MESSAGE(result == BD_ERROR_OK, "Not enough heap to run test")
|
||||||
TEST_SKIP_UNLESS_MESSAGE(!result, "Not enough heap to run test");
|
for (bd_addr_t addr = 0; addr < heap_bd.size(); addr += heap_bd.get_program_size()) {
|
||||||
|
result = heap_bd.program(dummy, addr, heap_bd.get_program_size());
|
||||||
|
TEST_SKIP_UNLESS_MESSAGE(result == BD_ERROR_OK, "Not enough heap to run test")
|
||||||
|
}
|
||||||
heap_bd.deinit();
|
heap_bd.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,11 +348,14 @@ static void multi_set_test()
|
||||||
|
|
||||||
#ifdef USE_HEAP_BD
|
#ifdef USE_HEAP_BD
|
||||||
// We need to skip the test if we don't have enough memory for the heap block device.
|
// We need to skip the test if we don't have enough memory for the heap block device.
|
||||||
// However, this device allocates the erase units on the fly, so "erase" it via the flash
|
// However, this device allocates the blocks on the fly when programmed. A failure
|
||||||
// simulator. A failure here means we haven't got enough memory.
|
// here means we haven't got enough memory.
|
||||||
flash_bd.init();
|
result = flash_bd.init();
|
||||||
result = flash_bd.erase(0, flash_bd.size());
|
TEST_SKIP_UNLESS_MESSAGE(result == BD_ERROR_OK, "Not enough heap to run test")
|
||||||
TEST_SKIP_UNLESS_MESSAGE(!result, "Not enough heap to run test");
|
for (bd_addr_t addr = 0; addr < flash_bd.size(); addr += flash_bd.get_program_size()) {
|
||||||
|
result = flash_bd.program(dummy, addr, flash_bd.get_program_size());
|
||||||
|
TEST_SKIP_UNLESS_MESSAGE(result == BD_ERROR_OK, "Not enough heap to run test")
|
||||||
|
}
|
||||||
flash_bd.deinit();
|
flash_bd.deinit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue