nvs_flash: Fix host test regressions

Regression in 09d2c5daa6 - in some
cases the test fixture was out of scope by the time
nvs_flash_deinit_partition() was called in this test.
pull/6718/head
Angus Gratton 2020-12-17 19:30:19 +11:00
rodzic b92c290e56
commit c553430b0c
1 zmienionych plików z 17 dodań i 13 usunięć

Wyświetl plik

@ -1220,9 +1220,9 @@ TEST_CASE("nvs api tests, starting with random data in flash", "[nvs][long]")
nvs_close(handle_2);
}
nvs_close(handle_1);
}
TEST_ESP_OK(nvs_flash_deinit_partition(NVS_DEFAULT_PART_NAME));
TEST_ESP_OK(nvs_flash_deinit_partition(f.part.get_partition_name()));
}
}
extern "C" void nvs_dump(const char *partName);
@ -1519,17 +1519,16 @@ TEST_CASE("test recovery from sudden poweroff", "[long][nvs][recovery][monkey]")
gen.seed(seed);
const size_t iter_count = 2000;
PartitionEmulationFixture f(0, 10);
const uint32_t NVS_FLASH_SECTOR = 2;
const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 8;
f.emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
size_t totalOps = 0;
int lastPercent = -1;
for (uint32_t errDelay = 0; ; ++errDelay) {
INFO(errDelay);
PartitionEmulationFixture f(0, 10);
const uint32_t NVS_FLASH_SECTOR = 2;
const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 8;
f.emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
f.emu.randomize(seed);
f.emu.clearStats();
f.emu.failAfter(errDelay);
@ -1550,14 +1549,18 @@ TEST_CASE("test recovery from sudden poweroff", "[long][nvs][recovery][monkey]")
if (NVSPartitionManager::get_instance()->init_custom(&f.part,
NVS_FLASH_SECTOR,
NVS_FLASH_SECTOR_COUNT_MIN) == ESP_OK) {
auto res = ESP_ERR_FLASH_OP_FAIL;
if (nvs_open("namespace1", NVS_READWRITE, &handle) == ESP_OK) {
if(test.doRandomThings(handle, gen, count) != ESP_ERR_FLASH_OP_FAIL) {
nvs_close(handle);
break;
}
res = test.doRandomThings(handle, gen, count);
nvs_close(handle);
}
TEST_ESP_OK(nvs_flash_deinit_partition(NVS_DEFAULT_PART_NAME));
if (res != ESP_ERR_FLASH_OP_FAIL) {
// This means we got to the end without an error due to f.emu.failAfter(), therefore errDelay
// is high enough that we're not triggering it any more, therefore we're done
break;
}
}
TEST_ESP_OK(NVSPartitionManager::get_instance()->init_custom(&f.part,
@ -1575,6 +1578,7 @@ TEST_CASE("test recovery from sudden poweroff", "[long][nvs][recovery][monkey]")
TEST_ESP_OK(nvs_flash_deinit_partition(NVS_DEFAULT_PART_NAME));
}
}
TEST_CASE("test for memory leaks in open/set", "[leaks]")
{
PartitionEmulationFixture f(0, 10);