Skip to content

Commit

Permalink
[test] wiring/no_fixture: make sure to clean up factory location
Browse files Browse the repository at this point in the history
  • Loading branch information
avtolstoy committed Sep 15, 2021
1 parent da0dd98 commit a36bb51
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions user/tests/wiring/no_fixture/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ test(SYSTEM_06_system_describe_is_not_overflowed_when_factory_module_present)
// Copy current user-part into factory location
auto storageId = factory->bounds.location == MODULE_BOUNDS_LOC_EXTERNAL_FLASH ? HAL_STORAGE_ID_EXTERNAL_FLASH : HAL_STORAGE_ID_INTERNAL_FLASH;
int r = hal_storage_erase(storageId, factory->bounds.start_address, factory->bounds.maximum_size);
SCOPE_GUARD({
hal_storage_erase(storageId, factory->bounds.start_address, factory->bounds.maximum_size);
});
assertEqual(factory->bounds.maximum_size, r);
module_info_t patchedModuleInfo = user->info;
module_info_suffix_t patchedModuleSuffix = user->suffix;
Expand Down Expand Up @@ -265,6 +268,9 @@ test(SYSTEM_07_system_describe_is_not_overflowed_when_factory_module_present_but
size_t toCopy = std::min<size_t>(((uintptr_t)user->info.module_end_address - (uintptr_t)user->info.module_start_address) / 2, factory->bounds.maximum_size);
auto storageId = factory->bounds.location == MODULE_BOUNDS_LOC_EXTERNAL_FLASH ? HAL_STORAGE_ID_EXTERNAL_FLASH : HAL_STORAGE_ID_INTERNAL_FLASH;
int r = hal_storage_erase(storageId, factory->bounds.start_address, factory->bounds.maximum_size);
SCOPE_GUARD({
hal_storage_erase(storageId, factory->bounds.start_address, factory->bounds.maximum_size);
});
assertEqual(factory->bounds.maximum_size, r);
char buf[256]; // some platforms cannot write into e.g. an external flash directly from internal
for (size_t pos = 0; pos < toCopy; pos += sizeof(buf)) {
Expand Down

0 comments on commit a36bb51

Please sign in to comment.