mirror of
https://github.com/espressif/openthread.git
synced 2026-08-06 02:37:47 +00:00
[test] add testResetInstance() to simulate device reset (#12878)
This commit introduces `testResetInstance()` in the unit test platform layer to finalize an existing `ot::Instance` and re-initialize it using the same underlying memory buffer, simulating a device reset. This commit also updates `test_routing_manager.cpp` to use this new function to streamline the test implementation.
This commit is contained in:
@@ -75,6 +75,23 @@ ot::Instance *testInitInstance(void)
|
||||
return static_cast<ot::Instance *>(instance);
|
||||
}
|
||||
|
||||
ot::Instance *testResetInstance(ot::Instance *aInstance)
|
||||
{
|
||||
otInstanceFinalize(aInstance);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
|
||||
{
|
||||
size_t instanceBufferLength = sizeof(ot::Instance);
|
||||
|
||||
aInstance = static_cast<ot::Instance *>(otInstanceInit(aInstance, &instanceBufferLength));
|
||||
}
|
||||
#else
|
||||
aInstance = static_cast<ot::Instance *>(otInstanceInitSingle());
|
||||
#endif
|
||||
|
||||
return aInstance;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE && OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE
|
||||
ot::Instance *testInitAdditionalInstance(uint8_t id)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user