Skip to content

Commit

Permalink
[Tests] Improving initalizaiton in TestInetCommonPosix (#26663)
Browse files Browse the repository at this point in the history
Add CHIP stack initialization/shutdown for LwIP event service.
It uses an event loop mechanism that requires a CHIP stack
ready for use.

Signed-off-by: ATmobica <[email protected]>
  • Loading branch information
ATmobica authored and pull[bot] committed Oct 23, 2023
1 parent 4338c69 commit 2939537
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
19 changes: 15 additions & 4 deletions src/inet/tests/TestInetCommonPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,31 @@ void ShutdownTestInetCommon()

void InitSystemLayer()
{
#if CHIP_SYSTEM_CONFIG_USE_LWIP && !(CHIP_SYSTEM_CONFIG_LWIP_SKIP_INIT)
#if CHIP_SYSTEM_CONFIG_USE_LWIP
// LwIP implementation uses the event loop for servicing events.
// The CHIP stack initialization is required then.
chip::DeviceLayer::PlatformMgr().InitChipStack();
#ifndef CHIP_SYSTEM_CONFIG_LWIP_SKIP_INIT
AcquireLwIP();
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP && !(CHIP_SYSTEM_CONFIG_LWIP_SKIP_INIT)
#endif // !CHIP_SYSTEM_CONFIG_LWIP_SKIP_INIT
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP

gSystemLayer.Init();
}

void ShutdownSystemLayer()
{

gSystemLayer.Shutdown();

#if CHIP_SYSTEM_CONFIG_USE_LWIP && !(CHIP_SYSTEM_CONFIG_LWIP_SKIP_INIT)
#if CHIP_SYSTEM_CONFIG_USE_LWIP
// LwIP implementation uses the event loop for servicing events.
// The CHIP stack shutdown is required then.
chip::DeviceLayer::PlatformMgr().Shutdown();
#ifndef CHIP_SYSTEM_CONFIG_LWIP_SKIP_INIT
ReleaseLwIP();
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP && !(CHIP_SYSTEM_CONFIG_LWIP_SKIP_INIT)
#endif // !CHIP_SYSTEM_CONFIG_LWIP_SKIP_INIT
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
}

#if CHIP_SYSTEM_CONFIG_USE_LWIP && !(CHIP_SYSTEM_CONFIG_LWIP_SKIP_INIT)
Expand Down
3 changes: 1 addition & 2 deletions src/transport/raw/tests/NetworkTestHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ CHIP_ERROR IOContext::Init()
CHIP_ERROR err = Platform::MemoryInit();
chip::DeviceLayer::SetConfigurationMgr(&chip::DeviceLayer::ConfigurationMgrImpl());

gSystemLayer.Init();

InitSystemLayer();
InitNetwork();

mSystemLayer = &gSystemLayer;
Expand Down

0 comments on commit 2939537

Please sign in to comment.