TESTS: flashiap: Add condition to check error on unaligned access

In case the target supports a page size of 1 byte, i.e. is able to
program flash 1 byte at a time, which is the case of STM32 F4 targets,
there is no reason for flash_device.program to return an error when
trying to write on an "unaligned" address.
pull/4980/head
Laurent MEUNIER 2017-08-24 16:20:09 +02:00
parent a9468c09e3
commit be7fa925ad
1 changed files with 9 additions and 5 deletions

View File

@ -106,12 +106,16 @@ void flashiap_program_error_test()
// unaligned address // unaligned address
ret = flash_device.erase(address + 1, sector_size); ret = flash_device.erase(address + 1, sector_size);
TEST_ASSERT_EQUAL_INT32(-1, ret); TEST_ASSERT_EQUAL_INT32(-1, ret);
ret = flash_device.program(data, address + 1, page_size); if (flash_device.get_page_size() > 1) {
TEST_ASSERT_EQUAL_INT32(-1, ret); ret = flash_device.program(data, address + 1, page_size);
TEST_ASSERT_EQUAL_INT32(-1, ret);
}
// unaligned page size if (flash_device.get_page_size() > 1) {
ret = flash_device.program(data, address, page_size + 1); // unaligned page size
TEST_ASSERT_EQUAL_INT32(-1, ret); ret = flash_device.program(data, address, page_size + 1);
TEST_ASSERT_EQUAL_INT32(-1, ret);
}
delete[] data; delete[] data;