[tests] prevent settings/flash retaining between unit tests (#12875)

Issue: state was retained between OT instances in the unit test platform, across tests.
This commit adds settings and flash clearing as part of testInitInstance().
This commit is contained in:
Esko Dijk
2026-04-10 12:16:27 +02:00
committed by Jonathan Hui
parent e336e7a86c
commit 68ab3a55a1
+8
View File
@@ -33,6 +33,8 @@
#include <stdio.h>
#include <sys/time.h>
#include <openthread/platform/flash.h>
#ifdef OPENTHREAD_CONFIG_BLE_TCAT_ENABLE
#include <openthread/tcat.h>
#include <openthread/platform/ble.h>
@@ -50,6 +52,12 @@ ot::Instance *testInitInstance(void)
{
otInstance *instance = nullptr;
settings.clear();
for (uint8_t idx = 0; idx < FLASH_SWAP_NUM; idx++)
{
otPlatFlashErase(nullptr, idx);
}
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
#if OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE
instance = otInstanceInitMultiple(0);