Skip to content

Commit be7fa92

Browse files
committed
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.
1 parent a9468c0 commit be7fa92

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

TESTS/mbed_drivers/flashiap/main.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,16 @@ void flashiap_program_error_test()
106106
// unaligned address
107107
ret = flash_device.erase(address + 1, sector_size);
108108
TEST_ASSERT_EQUAL_INT32(-1, ret);
109-
ret = flash_device.program(data, address + 1, page_size);
110-
TEST_ASSERT_EQUAL_INT32(-1, ret);
109+
if (flash_device.get_page_size() > 1) {
110+
ret = flash_device.program(data, address + 1, page_size);
111+
TEST_ASSERT_EQUAL_INT32(-1, ret);
112+
}
111113

112-
// unaligned page size
113-
ret = flash_device.program(data, address, page_size + 1);
114-
TEST_ASSERT_EQUAL_INT32(-1, ret);
114+
if (flash_device.get_page_size() > 1) {
115+
// unaligned page size
116+
ret = flash_device.program(data, address, page_size + 1);
117+
TEST_ASSERT_EQUAL_INT32(-1, ret);
118+
}
115119

116120
delete[] data;
117121

0 commit comments

Comments
 (0)