From a36bb515d8e630bd9a7cb29078789939fdf67265 Mon Sep 17 00:00:00 2001 From: Andrey Tolstoy Date: Thu, 16 Sep 2021 01:27:30 +0700 Subject: [PATCH] [test] wiring/no_fixture: make sure to clean up factory location --- user/tests/wiring/no_fixture/system.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/user/tests/wiring/no_fixture/system.cpp b/user/tests/wiring/no_fixture/system.cpp index 1ee3ad7d80..096044c1d3 100644 --- a/user/tests/wiring/no_fixture/system.cpp +++ b/user/tests/wiring/no_fixture/system.cpp @@ -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; @@ -265,6 +268,9 @@ test(SYSTEM_07_system_describe_is_not_overflowed_when_factory_module_present_but size_t toCopy = std::min(((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)) {