diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 5998b220ba2fe5..e2f9dcc099eba6 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -1232,7 +1232,7 @@ menu "CHIP Device Layer" menu "Message Reliable Protocol Options" config MRP_LOCAL_ACTIVE_RETRY_INTERVAL_FOR_THREAD int "MRP local active retry interval for Thread network in milliseconds" - depends on OPENTHREAD_ENABLED + depends on ENABLE_MATTER_OVER_THREAD range 0 3600000 default 800 help @@ -1240,7 +1240,7 @@ menu "CHIP Device Layer" config MRP_LOCAL_ACTIVE_RETRY_INTERVAL_FOR_WIFI_ETHERNET int "MRP local active retry interval for WIFI or ETHERNET network in milliseconds" - depends on !OPENTHREAD_ENABLED + depends on !ENABLE_MATTER_OVER_THREAD range 0 3600000 default 300 help @@ -1248,7 +1248,7 @@ menu "CHIP Device Layer" config MRP_LOCAL_IDLE_RETRY_INTERVAL_FOR_THREAD int "MRP local idle retry interval for Thread network in milliseconds" - depends on OPENTHREAD_ENABLED + depends on ENABLE_MATTER_OVER_THREAD range 0 3600000 default 800 help @@ -1256,7 +1256,7 @@ menu "CHIP Device Layer" config MRP_LOCAL_IDLE_RETRY_INTERVAL_FOR_WIFI_ETHERNET int "MRP local idle retry interval for WIFI or ETHERNET network in milliseconds" - depends on !OPENTHREAD_ENABLED + depends on !ENABLE_MATTER_OVER_THREAD range 0 3600000 default 500 help @@ -1264,7 +1264,7 @@ menu "CHIP Device Layer" config MRP_RETRY_INTERVAL_SENDER_BOOST_FOR_THREAD int "MRP retransmission delta timeout for Thread network in milliseconds" - depends on OPENTHREAD_ENABLED + depends on ENABLE_MATTER_OVER_THREAD range 0 3600000 default 500 help @@ -1272,7 +1272,7 @@ menu "CHIP Device Layer" config MRP_RETRY_INTERVAL_SENDER_BOOST_FOR_WIFI_ETHERNET int "MRP retransmission delta timeout for WIFI or ETHERNET network in milliseconds" - depends on !OPENTHREAD_ENABLED + depends on !ENABLE_MATTER_OVER_THREAD range 0 3600000 default 0 help diff --git a/examples/platform/silabs/FreeRTOSConfig.h b/examples/platform/silabs/FreeRTOSConfig.h index ec926f4bbbeb94..5e257c4caf5b16 100644 --- a/examples/platform/silabs/FreeRTOSConfig.h +++ b/examples/platform/silabs/FreeRTOSConfig.h @@ -197,7 +197,7 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ #define configMAX_SYSCALL_INTERRUPT_PRIORITY 48 #endif // SLI_SI91X_MCU_INTERFACE -#define configENABLE_FPU 0 +#define configENABLE_FPU 1 #define configENABLE_MPU 0 /* FreeRTOS Secure Side Only and TrustZone Security Extension */ #define configRUN_FREERTOS_SECURE_ONLY 1 diff --git a/src/BUILD.gn b/src/BUILD.gn index 01aae8abc3fbab..cf15f40ec00629 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -92,9 +92,9 @@ if (chip_build_tests) { ] } + # Skip on efr32 due to flash and/or ram limitations. if (chip_device_platform != "efr32") { tests += [ - # TODO(#10447): App test has HF on EFR32. "${chip_root}/src/app/tests", "${chip_root}/src/credentials/tests", "${chip_root}/src/lib/format/tests", @@ -128,7 +128,7 @@ if (chip_build_tests) { # https://github.com/project-chip/connectedhomeip/issues/9630 if (chip_device_platform != "nrfconnect" && chip_device_platform != "efr32") { - # TODO(#10447): Controller test has HF on EFR32. + # Doesn't compile on ef32. Multiple definitions issues with attribute storage and overflows flash memory. tests += [ "${chip_root}/src/controller/tests/data_model" ] # Skip controller test for Open IoT SDK diff --git a/src/app/icd/server/tests/TestICDManager.cpp b/src/app/icd/server/tests/TestICDManager.cpp index 6cba8c308b4e06..45e781685e6d31 100644 --- a/src/app/icd/server/tests/TestICDManager.cpp +++ b/src/app/icd/server/tests/TestICDManager.cpp @@ -1061,10 +1061,15 @@ TEST_F(TestICDManager, TestICDStateObserverOnTransitionToIdleModeEqualActiveMode // Expire IdleMode timer AdvanceClockAndRunEventLoop(1_s); - EXPECT_FALSE(mICDStateObserver.mOnTransitionToIdleCalled); + // In this scenario, The ICD state machine kicked a OnTransitionToIdle timer with a duration of 0 seconds. + // The freeRTOS systemlayer timer calls a 0s timer's callback instantly while on posix it take and 1 addition event loop. + // Thefore, the expect result diverges here based on the systemlayer implementation. Skip this check. + // https://github.com/project-chip/connectedhomeip/issues/33441 + // EXPECT_FALSE(mICDStateObserver.mOnTransitionToIdleCalled); // Expire OnTransitionToIdleMode AdvanceClockAndRunEventLoop(1_ms32); + // All systems should have called the OnTransitionToIdle callback by now. EXPECT_TRUE(mICDStateObserver.mOnTransitionToIdleCalled); // Reset Old durations diff --git a/src/app/tests/AppTestContext.h b/src/app/tests/AppTestContext.h index b9945fecd3a90a..a2fe3387d2d7aa 100644 --- a/src/app/tests/AppTestContext.h +++ b/src/app/tests/AppTestContext.h @@ -28,13 +28,13 @@ class AppContext : public LoopbackMessagingContext { public: // Performs shared setup for all tests in the test suite - void SetUpTestSuite() override; + static void SetUpTestSuite(); // Performs shared teardown for all tests in the test suite - void TearDownTestSuite() override; + static void TearDownTestSuite(); // Performs setup for each individual test in the test suite - void SetUp() override; + void SetUp(); // Performs teardown for each individual test in the test suite - void TearDown() override; + void TearDown(); }; } // namespace Test diff --git a/src/app/tests/TestAclAttribute.cpp b/src/app/tests/TestAclAttribute.cpp index c1bfd8acf68a73..427b257f9efd7c 100644 --- a/src/app/tests/TestAclAttribute.cpp +++ b/src/app/tests/TestAclAttribute.cpp @@ -259,10 +259,10 @@ const nlTest sTests[] = { nlTestSuite sSuite = { "TestAclAttribute", &sTests[0], - TestAccessContext::nlTestSetUpTestSuite, - TestAccessContext::nlTestTearDownTestSuite, - TestAccessContext::nlTestSetUp, - TestAccessContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestAccessContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestAccessContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestAccessContext, SetUp), + NL_TEST_WRAP_METHOD(TestAccessContext, TearDown), }; } // namespace diff --git a/src/app/tests/TestAclEvent.cpp b/src/app/tests/TestAclEvent.cpp index f7c85e0bccaed8..8f377cc263e9bd 100644 --- a/src/app/tests/TestAclEvent.cpp +++ b/src/app/tests/TestAclEvent.cpp @@ -377,10 +377,10 @@ nlTestSuite sSuite = { "TestAclEvent", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/app/tests/TestBufferedReadCallback.cpp b/src/app/tests/TestBufferedReadCallback.cpp index 93eca2ad5044f4..6079c21b50b49f 100644 --- a/src/app/tests/TestBufferedReadCallback.cpp +++ b/src/app/tests/TestBufferedReadCallback.cpp @@ -610,10 +610,10 @@ nlTestSuite theSuite = { "TestBufferedReadCallback", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; } diff --git a/src/app/tests/TestClusterStateCache.cpp b/src/app/tests/TestClusterStateCache.cpp index a871f3dd1a434e..3247af55bccd03 100644 --- a/src/app/tests/TestClusterStateCache.cpp +++ b/src/app/tests/TestClusterStateCache.cpp @@ -695,10 +695,10 @@ nlTestSuite theSuite = { "TestClusterStateCache", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; } diff --git a/src/app/tests/TestCommandInteraction.cpp b/src/app/tests/TestCommandInteraction.cpp index 87296580fa695f..195580ce8702a5 100644 --- a/src/app/tests/TestCommandInteraction.cpp +++ b/src/app/tests/TestCommandInteraction.cpp @@ -2120,10 +2120,10 @@ nlTestSuite sSuite = { "TestCommandInteraction", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/app/tests/TestEventLogging.cpp b/src/app/tests/TestEventLogging.cpp index 41ae31bd4295ff..854247240ac701 100644 --- a/src/app/tests/TestEventLogging.cpp +++ b/src/app/tests/TestEventLogging.cpp @@ -318,10 +318,10 @@ const nlTest sTests[] = { nlTestSuite sSuite = { "EventLogging", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; } // namespace diff --git a/src/app/tests/TestEventLoggingNoUTCTime.cpp b/src/app/tests/TestEventLoggingNoUTCTime.cpp index 77a8463a5f9718..c6dc4182b79e0e 100644 --- a/src/app/tests/TestEventLoggingNoUTCTime.cpp +++ b/src/app/tests/TestEventLoggingNoUTCTime.cpp @@ -84,16 +84,16 @@ class TestContext : public chip::Test::AppContext { public: // Performs shared setup for all tests in the test suite - void SetUpTestSuite() override + static void SetUpTestSuite() { chip::Test::AppContext::SetUpTestSuite(); - mClock.Emplace(chip::System::SystemClock()); + sClock.Emplace(chip::System::SystemClock()); } // Performs shared teardown for all tests in the test suite - void TearDownTestSuite() override + static void TearDownTestSuite() { - mClock.ClearValue(); + sClock.ClearValue(); chip::Test::AppContext::TearDownTestSuite(); } @@ -125,9 +125,11 @@ class TestContext : public chip::Test::AppContext private: chip::MonotonicallyIncreasingCounter mEventCounter; - chip::Optional mClock; + static chip::Optional sClock; }; +chip::Optional TestContext::sClock; + void ENFORCE_FORMAT(1, 2) SimpleDumpWriter(const char * aFormat, ...) { va_list args; @@ -370,10 +372,10 @@ const nlTest sTests[] = { nlTestSuite sSuite = { "EventLogging", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; } // namespace diff --git a/src/app/tests/TestEventOverflow.cpp b/src/app/tests/TestEventOverflow.cpp index a328bec9783ef2..23615f401d6f75 100644 --- a/src/app/tests/TestEventOverflow.cpp +++ b/src/app/tests/TestEventOverflow.cpp @@ -169,10 +169,10 @@ nlTestSuite sSuite = { "TestEventOverflow", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/app/tests/TestFabricScopedEventLogging.cpp b/src/app/tests/TestFabricScopedEventLogging.cpp index 082aca0a2ecb7d..2ed758573aa5b6 100644 --- a/src/app/tests/TestFabricScopedEventLogging.cpp +++ b/src/app/tests/TestFabricScopedEventLogging.cpp @@ -278,10 +278,10 @@ nlTestSuite sSuite = { "TestFabricScopedEventLogging", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/app/tests/TestInteractionModelEngine.cpp b/src/app/tests/TestInteractionModelEngine.cpp index 4f0b75315355ad..3d6abd9e651d49 100644 --- a/src/app/tests/TestInteractionModelEngine.cpp +++ b/src/app/tests/TestInteractionModelEngine.cpp @@ -773,10 +773,10 @@ nlTestSuite sSuite = { "TestInteractionModelEngine", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index 7e18cca7883c8f..e06721806732f6 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -79,13 +79,13 @@ class TestContext : public chip::Test::AppContext { public: // Performs shared setup for all tests in the test suite - void SetUpTestSuite() override + static void SetUpTestSuite() { chip::Test::AppContext::SetUpTestSuite(); gRealClock = &chip::System::SystemClock(); chip::System::Clock::Internal::SetSystemClockForTesting(&gMockClock); - if (mSyncScheduler) + if (sSyncScheduler) { gReportScheduler = chip::app::reporting::GetSynchronizedReportScheduler(); sUsingSubSync = true; @@ -96,14 +96,8 @@ class TestContext : public chip::Test::AppContext } } - static int nlTestSetUpTestSuite_Sync(void * context) - { - static_cast(context)->mSyncScheduler = true; - return nlTestSetUpTestSuite(context); - } - // Performs shared teardown for all tests in the test suite - void TearDownTestSuite() override + static void TearDownTestSuite() { chip::System::Clock::Internal::SetSystemClockForTesting(gRealClock); chip::Test::AppContext::TearDownTestSuite(); @@ -133,9 +127,21 @@ class TestContext : public chip::Test::AppContext chip::Test::AppContext::TearDown(); } -private: +protected: chip::MonotonicallyIncreasingCounter mEventCounter; - bool mSyncScheduler = false; + static bool sSyncScheduler; +}; + +bool TestContext::sSyncScheduler = false; + +class TestSyncContext : public TestContext +{ +public: + static void SetUpTestSuite() + { + sSyncScheduler = true; + TestContext::SetUpTestSuite(); + } }; class TestEventGenerator : public chip::app::EventLoggingDelegate @@ -5146,19 +5152,19 @@ const nlTest sTests[] = { nlTestSuite sSuite = { "TestReadInteraction", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; nlTestSuite sSyncSuite = { "TestSyncReadInteraction", &sTests[0], - TestContext::nlTestSetUpTestSuite_Sync, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestSyncContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestSyncContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestSyncContext, SetUp), + NL_TEST_WRAP_METHOD(TestSyncContext, TearDown), }; } // namespace diff --git a/src/app/tests/TestReportScheduler.cpp b/src/app/tests/TestReportScheduler.cpp index 5219943136847d..b7289f5f2daa90 100644 --- a/src/app/tests/TestReportScheduler.cpp +++ b/src/app/tests/TestReportScheduler.cpp @@ -821,10 +821,10 @@ static nlTest sTests[] = { nlTestSuite sSuite = { "TestReportScheduler", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; } // namespace diff --git a/src/app/tests/TestReportingEngine.cpp b/src/app/tests/TestReportingEngine.cpp index 618a2e892e789b..459c9752016e48 100644 --- a/src/app/tests/TestReportingEngine.cpp +++ b/src/app/tests/TestReportingEngine.cpp @@ -350,10 +350,10 @@ nlTestSuite sSuite = { "TestReportingEngine", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/app/tests/TestTimedHandler.cpp b/src/app/tests/TestTimedHandler.cpp index 29e8aac71d35a7..64e174a2b9e7d7 100644 --- a/src/app/tests/TestTimedHandler.cpp +++ b/src/app/tests/TestTimedHandler.cpp @@ -264,10 +264,10 @@ nlTestSuite sSuite = { "TestTimedHandler", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/app/tests/TestWriteInteraction.cpp b/src/app/tests/TestWriteInteraction.cpp index 16647ca523829e..25c9106f2986a0 100644 --- a/src/app/tests/TestWriteInteraction.cpp +++ b/src/app/tests/TestWriteInteraction.cpp @@ -1063,10 +1063,10 @@ const nlTest sTests[] = nlTestSuite sSuite = { "TestWriteInteraction", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; } // namespace diff --git a/src/inet/tests/TestInetCommonOptions.cpp b/src/inet/tests/TestInetCommonOptions.cpp index fdc79b11954a27..7e4648d7466b1b 100644 --- a/src/inet/tests/TestInetCommonOptions.cpp +++ b/src/inet/tests/TestInetCommonOptions.cpp @@ -51,7 +51,7 @@ NetworkOptions::NetworkOptions() static OptionDef optionDefs[] = { { "local-addr", kArgumentRequired, 'a' }, { "node-addr", kArgumentRequired, kToolCommonOpt_NodeAddr }, /* alias for local-addr */ -#if CHIP_SYSTEM_CONFIG_USE_LWIP +#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT { "tap-device", kArgumentRequired, kToolCommonOpt_TapDevice }, { "ipv4-gateway", kArgumentRequired, kToolCommonOpt_IPv4GatewayAddr }, { "ipv6-gateway", kArgumentRequired, kToolCommonOpt_IPv6GatewayAddr }, @@ -59,7 +59,7 @@ NetworkOptions::NetworkOptions() { "debug-lwip", kNoArgument, kToolCommonOpt_DebugLwIP }, { "event-delay", kArgumentRequired, kToolCommonOpt_EventDelay }, { "tap-system-config", kNoArgument, kToolCommonOpt_TapInterfaceConfig }, -#endif +#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT {} }; OptionDefs = optionDefs; @@ -69,7 +69,7 @@ NetworkOptions::NetworkOptions() OptionHelp = " -a, --local-addr, --node-addr \n" " Local address for the node.\n" "\n" -#if CHIP_SYSTEM_CONFIG_USE_LWIP +#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT " --tap-device \n" " TAP device name for LwIP hosted OS usage. Defaults to chip-dev-.\n" "\n" @@ -91,14 +91,14 @@ NetworkOptions::NetworkOptions() " --tap-system-config\n" " Use configuration on each of the Linux TAP interfaces to configure LwIP's interfaces.\n" "\n" -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP +#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT ; // Defaults. LocalIPv4Addr.clear(); LocalIPv6Addr.clear(); -#if CHIP_SYSTEM_CONFIG_USE_LWIP +#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT TapDeviceName.clear(); LwIPDebugFlags = 0; EventDelay = 0; @@ -106,7 +106,7 @@ NetworkOptions::NetworkOptions() IPv6GatewayAddr.clear(); DNSServerAddr = Inet::IPAddress::Any; TapUseSystemConfig = false; -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP +#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT } bool NetworkOptions::HandleOption(const char * progName, OptionSet * optSet, int id, const char * name, const char * arg) diff --git a/src/inet/tests/TestInetCommonOptions.h b/src/inet/tests/TestInetCommonOptions.h index 9b3cd2e59b4f3b..a67536dda1b266 100644 --- a/src/inet/tests/TestInetCommonOptions.h +++ b/src/inet/tests/TestInetCommonOptions.h @@ -59,7 +59,7 @@ class NetworkOptions : public chip::ArgParser::OptionSetBase std::vector LocalIPv4Addr; std::vector LocalIPv6Addr; -#if CHIP_SYSTEM_CONFIG_USE_LWIP +#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT std::vector IPv4GatewayAddr; std::vector IPv6GatewayAddr; chip::Inet::IPAddress DNSServerAddr; @@ -67,7 +67,7 @@ class NetworkOptions : public chip::ArgParser::OptionSetBase uint8_t LwIPDebugFlags; uint32_t EventDelay; bool TapUseSystemConfig; -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP +#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT NetworkOptions(); diff --git a/src/inet/tests/TestInetCommonPosix.cpp b/src/inet/tests/TestInetCommonPosix.cpp index 9d5e4588979d1a..6fc53a15fbb980 100644 --- a/src/inet/tests/TestInetCommonPosix.cpp +++ b/src/inet/tests/TestInetCommonPosix.cpp @@ -337,7 +337,7 @@ void InitNetwork() #if INET_CONFIG_ENABLE_TCP_ENDPOINT gTCP.Init(gSystemLayer); #endif -#if INET_CONFIG_ENABLE_TCP_ENDPOINT +#if INET_CONFIG_ENABLE_UDP_ENDPOINT gUDP.Init(gSystemLayer); #endif } @@ -368,14 +368,14 @@ void ServiceEvents(uint32_t aSleepTimeMilliseconds) gSystemLayer.HandleEvents(); #endif -#if CHIP_SYSTEM_CONFIG_USE_LWIP +#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT if (gSystemLayer.IsInitialized()) { static uint32_t sRemainingSystemLayerEventDelay = 0; if (sRemainingSystemLayerEventDelay == 0) { -#if CHIP_DEVICE_LAYER_TARGET_OPEN_IOT_SDK +#if CHIP_DEVICE_LAYER_TARGET_OPEN_IOT_SDK || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT // We need to terminate event loop after performance single step. // Event loop processing work items until StopEventLoopTask is called. // Scheduling StopEventLoop task guarantees correct operation of the loop. @@ -390,7 +390,7 @@ void ServiceEvents(uint32_t aSleepTimeMilliseconds) gSystemLayer.HandlePlatformTimer(); } -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP +#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT } #if CHIP_SYSTEM_CONFIG_USE_LWIP && !(CHIP_SYSTEM_CONFIG_LWIP_SKIP_INIT) diff --git a/src/lib/core/tests/BUILD.gn b/src/lib/core/tests/BUILD.gn index 30d50ee9493699..001078019a7e83 100644 --- a/src/lib/core/tests/BUILD.gn +++ b/src/lib/core/tests/BUILD.gn @@ -30,9 +30,14 @@ chip_test_suite("tests") { "TestOptional.cpp", "TestReferenceCounted.cpp", "TestTLV.cpp", - "TestTLVVectorWriter.cpp", ] + # requires large amount of heap for multiple unfragmented 10k buffers + # skip for efr32 to allow flash space for other tests + if (chip_device_platform != "efr32") { + test_sources += [ "TestTLVVectorWriter.cpp" ] + } + cflags = [ "-Wconversion" ] public_deps = [ diff --git a/src/lib/support/UnitTestRegistration.h b/src/lib/support/UnitTestRegistration.h index 791a62be855a36..be7cc710a9278d 100644 --- a/src/lib/support/UnitTestRegistration.h +++ b/src/lib/support/UnitTestRegistration.h @@ -48,6 +48,20 @@ VerifyOrDie(chip::RegisterUnitTests(&FUNCTION) == CHIP_NO_ERROR); \ } +// TODO: remove these once transition to pw_unit_test is completed +#define NL_TEST_WRAP_FUNCTION(FUNCTION) \ + [](void * _context) -> int { \ + FUNCTION(); \ + return SUCCESS; \ + } + +#define NL_TEST_WRAP_METHOD(CLASS, METHOD) \ + [](void * context) -> int { \ + auto ctx = static_cast(context); \ + ctx->METHOD(); \ + return SUCCESS; \ + } + namespace chip { typedef int (*UnitTestTriggerFunction)(); diff --git a/src/lib/support/UnitTestUtils.cpp b/src/lib/support/UnitTestUtils.cpp index 84976405a20940..0d3acae6487106 100644 --- a/src/lib/support/UnitTestUtils.cpp +++ b/src/lib/support/UnitTestUtils.cpp @@ -51,7 +51,7 @@ uint64_t TimeMonotonicMillis() void SleepMillis(uint64_t millisecs) { - uint32_t ticks = static_cast(millisecs / portTICK_PERIOD_MS); + uint32_t ticks = pdMS_TO_TICKS(millisecs); vTaskDelay(ticks == 0 ? 1 : ticks); // delay at least 1 tick } diff --git a/src/messaging/tests/BUILD.gn b/src/messaging/tests/BUILD.gn index a78dcce953756b..89f0934486b9c1 100644 --- a/src/messaging/tests/BUILD.gn +++ b/src/messaging/tests/BUILD.gn @@ -49,27 +49,20 @@ static_library("helpers") { chip_test_suite_using_nltest("tests") { output_name = "libMessagingLayerTests" - test_sources = [] - - if (chip_device_platform != "efr32") { - # TODO(#10447): ReliableMessage Test has HF, and ExchangeMgr hangs on EFR32. - # And TestAbortExchangesForFabric does not link on EFR32 for some reason. - # TODO #33372: TestExchange.cpp asserts in ExchangeContext::SendMessage - test_sources += [ - "TestAbortExchangesForFabric.cpp", - "TestExchange.cpp", - "TestExchangeMgr.cpp", - "TestReliableMessageProtocol.cpp", - ] + test_sources = [ + "TestAbortExchangesForFabric.cpp", + "TestExchange.cpp", + "TestExchangeMgr.cpp", + "TestReliableMessageProtocol.cpp", + ] - if (chip_device_platform != "esp32" && chip_device_platform != "mbed" && - chip_device_platform != "nrfconnect" && chip_device_platform != "nxp") { - test_sources += [ "TestExchangeHolder.cpp" ] - } + if (chip_device_platform != "esp32" && chip_device_platform != "mbed" && + chip_device_platform != "nrfconnect" && chip_device_platform != "nxp") { + test_sources += [ "TestExchangeHolder.cpp" ] + } - if (chip_device_platform == "linux") { - test_sources += [ "TestMessagingLayer.cpp" ] - } + if (chip_device_platform == "linux") { + test_sources += [ "TestMessagingLayer.cpp" ] } cflags = [ "-Wconversion" ] diff --git a/src/messaging/tests/MessagingContext.cpp b/src/messaging/tests/MessagingContext.cpp index 72ab1650da552c..61565da1cd4ac0 100644 --- a/src/messaging/tests/MessagingContext.cpp +++ b/src/messaging/tests/MessagingContext.cpp @@ -58,7 +58,7 @@ CHIP_ERROR MessagingContext::Init(TransportMgrBase * transport, IOContext * ioCo ReturnErrorOnFailure(mExchangeManager.Init(&mSessionManager)); ReturnErrorOnFailure(mMessageCounterManager.Init(&mExchangeManager)); - if (mInitializeNodes) + if (sInitializeNodes) { ReturnErrorOnFailure(CreateAliceFabric()); ReturnErrorOnFailure(CreateBobFabric()); @@ -112,6 +112,8 @@ using namespace System::Clock::Literals; constexpr chip::System::Clock::Timeout MessagingContext::kResponsiveIdleRetransTimeout; constexpr chip::System::Clock::Timeout MessagingContext::kResponsiveActiveRetransTimeout; +bool MessagingContext::sInitializeNodes = true; + void MessagingContext::SetMRPMode(MRPMode mode) { if (mode == MRPMode::kDefault) @@ -302,6 +304,10 @@ Messaging::ExchangeContext * MessagingContext::NewExchangeToBob(Messaging::Excha return mExchangeManager.NewContext(GetSessionAliceToBob(), delegate, isInitiator); } +LoopbackTransportManager LoopbackMessagingContext::sLoopbackTransportManager; + +UDPTransportManager UDPMessagingContext::sUDPTransportManager; + void MessageCapturer::OnMessageReceived(const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, const SessionHandle & session, DuplicateMessage isDuplicate, System::PacketBufferHandle && msgBuf) diff --git a/src/messaging/tests/MessagingContext.h b/src/messaging/tests/MessagingContext.h index 9ed82de60e4d5d..ab9912924e713c 100644 --- a/src/messaging/tests/MessagingContext.h +++ b/src/messaging/tests/MessagingContext.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -100,7 +101,7 @@ class MessagingContext : public PlatformMemoryUser ~MessagingContext() { VerifyOrDie(mInitialized == false); } // Whether Alice and Bob are initialized, must be called before Init - void ConfigInitializeNodes(bool initializeNodes) { mInitializeNodes = initializeNodes; } + static void ConfigInitializeNodes(bool initializeNodes) { sInitializeNodes = initializeNodes; } /// Initialize the underlying layers and test suite pointer CHIP_ERROR Init(TransportMgrBase * transport, IOContext * io); @@ -177,7 +178,7 @@ class MessagingContext : public PlatformMemoryUser System::Layer & GetSystemLayer() { return mIOContext->GetSystemLayer(); } private: - bool mInitializeNodes = true; + static bool sInitializeNodes; bool mInitialized; FabricTable mFabricTable; @@ -206,26 +207,38 @@ class MessagingContext : public PlatformMemoryUser }; // LoopbackMessagingContext enriches MessagingContext with an async loopback transport -class LoopbackMessagingContext : public LoopbackTransportManager, public MessagingContext +class LoopbackMessagingContext : public MessagingContext { public: virtual ~LoopbackMessagingContext() {} + // These functions wrap sLoopbackTransportManager methods + static auto & GetSystemLayer() { return sLoopbackTransportManager.GetSystemLayer(); } + static auto & GetLoopback() { return sLoopbackTransportManager.GetLoopback(); } + static auto & GetTransportMgr() { return sLoopbackTransportManager.GetTransportMgr(); } + static auto & GetIOContext() { return sLoopbackTransportManager.GetIOContext(); } + + template + static void DrainAndServiceIO(Ts... args) + { + return sLoopbackTransportManager.DrainAndServiceIO(args...); + } + // Performs shared setup for all tests in the test suite - virtual void SetUpTestSuite() + static void SetUpTestSuite() { CHIP_ERROR err = CHIP_NO_ERROR; // TODO: use ASSERT_EQ, once transition to pw_unit_test is complete VerifyOrDieWithMsg((err = chip::Platform::MemoryInit()) == CHIP_NO_ERROR, AppServer, "Init CHIP memory failed: %" CHIP_ERROR_FORMAT, err.Format()); - VerifyOrDieWithMsg((err = LoopbackTransportManager::Init()) == CHIP_NO_ERROR, AppServer, + VerifyOrDieWithMsg((err = sLoopbackTransportManager.Init()) == CHIP_NO_ERROR, AppServer, "Init LoopbackTransportManager failed: %" CHIP_ERROR_FORMAT, err.Format()); } // Performs shared teardown for all tests in the test suite - virtual void TearDownTestSuite() + static void TearDownTestSuite() { - LoopbackTransportManager::Shutdown(); + sLoopbackTransportManager.Shutdown(); chip::Platform::MemoryShutdown(); } @@ -240,100 +253,48 @@ class LoopbackMessagingContext : public LoopbackTransportManager, public Messagi // Performs teardown for each individual test in the test suite virtual void TearDown() { MessagingContext::Shutdown(); } - // Helpers that can be used directly by the nlTestSuite - - static int nlTestSetUpTestSuite(void * context) - { - static_cast(context)->SetUpTestSuite(); - return SUCCESS; - } - - static int nlTestTearDownTestSuite(void * context) - { - static_cast(context)->TearDownTestSuite(); - return SUCCESS; - } - - static int nlTestSetUp(void * context) - { - static_cast(context)->SetUp(); - return SUCCESS; - } - - static int nlTestTearDown(void * context) - { - static_cast(context)->TearDown(); - return SUCCESS; - } - - using LoopbackTransportManager::GetSystemLayer; + static LoopbackTransportManager sLoopbackTransportManager; }; // UDPMessagingContext enriches MessagingContext with an UDP transport -class UDPMessagingContext : public UDPTransportManager, public MessagingContext +class UDPMessagingContext : public MessagingContext { public: virtual ~UDPMessagingContext() {} + static auto & GetSystemLayer() { return sUDPTransportManager.GetSystemLayer(); } + static auto & GetTransportMgr() { return sUDPTransportManager.GetTransportMgr(); } + static auto & GetIOContext() { return sUDPTransportManager.GetIOContext(); } + // Performs shared setup for all tests in the test suite - virtual CHIP_ERROR SetUpTestSuite() + static void SetUpTestSuite() { CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrExit((err = chip::Platform::MemoryInit()) == CHIP_NO_ERROR, - ChipLogError(AppServer, "Init CHIP memory failed: %" CHIP_ERROR_FORMAT, err.Format())); - VerifyOrExit((err = UDPTransportManager::Init()) == CHIP_NO_ERROR, - ChipLogError(AppServer, "Init UDPTransportManager failed: %" CHIP_ERROR_FORMAT, err.Format())); - exit: - return err; + VerifyOrDieWithMsg((err = chip::Platform::MemoryInit()) == CHIP_NO_ERROR, AppServer, + "Init CHIP memory failed: %" CHIP_ERROR_FORMAT, err.Format()); + VerifyOrDieWithMsg((err = sUDPTransportManager.Init()) == CHIP_NO_ERROR, AppServer, + "Init UDPTransportManager failed: %" CHIP_ERROR_FORMAT, err.Format()); } // Performs shared teardown for all tests in the test suite - virtual void TearDownTestSuite() + static void TearDownTestSuite() { - UDPTransportManager::Shutdown(); + sUDPTransportManager.Shutdown(); chip::Platform::MemoryShutdown(); } // Performs setup for each individual test in the test suite - virtual CHIP_ERROR SetUp() + virtual void SetUp() { CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrExit((err = MessagingContext::Init(&GetTransportMgr(), &GetIOContext())) == CHIP_NO_ERROR, - ChipLogError(AppServer, "Init MessagingContext failed: %" CHIP_ERROR_FORMAT, err.Format())); - exit: - return err; + VerifyOrDieWithMsg((err = MessagingContext::Init(&GetTransportMgr(), &GetIOContext())) == CHIP_NO_ERROR, AppServer, + "Init MessagingContext failed: %" CHIP_ERROR_FORMAT, err.Format()); } // Performs teardown for each individual test in the test suite virtual void TearDown() { MessagingContext::Shutdown(); } - // Helpers that can be used directly by the nlTestSuite - - static int nlTestSetUpTestSuite(void * context) - { - auto err = static_cast(context)->SetUpTestSuite(); - return err == CHIP_NO_ERROR ? SUCCESS : FAILURE; - } - - static int nlTestTearDownTestSuite(void * context) - { - static_cast(context)->TearDownTestSuite(); - return SUCCESS; - } - - static int nlTestSetUp(void * context) - { - auto err = static_cast(context)->SetUp(); - return err == CHIP_NO_ERROR ? SUCCESS : FAILURE; - } - - static int nlTestTearDown(void * context) - { - static_cast(context)->TearDown(); - return SUCCESS; - } - - using UDPTransportManager::GetSystemLayer; + static UDPTransportManager sUDPTransportManager; }; // Class that can be used to capture decrypted message traffic in tests using diff --git a/src/messaging/tests/TestAbortExchangesForFabric.cpp b/src/messaging/tests/TestAbortExchangesForFabric.cpp index 1540b91725a3aa..d5c945c848a9aa 100644 --- a/src/messaging/tests/TestAbortExchangesForFabric.cpp +++ b/src/messaging/tests/TestAbortExchangesForFabric.cpp @@ -273,10 +273,10 @@ const nlTest sTests[] = { nlTestSuite sSuite = { "Test-AbortExchangesForFabric", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/messaging/tests/TestExchange.cpp b/src/messaging/tests/TestExchange.cpp index 67b9ab6d16d0d3..fbc1c9e505204d 100644 --- a/src/messaging/tests/TestExchange.cpp +++ b/src/messaging/tests/TestExchange.cpp @@ -241,10 +241,10 @@ nlTestSuite sSuite = { "Test-Exchange", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/messaging/tests/TestExchangeHolder.cpp b/src/messaging/tests/TestExchangeHolder.cpp index 9325350d262e1b..849c1856d9b013 100644 --- a/src/messaging/tests/TestExchangeHolder.cpp +++ b/src/messaging/tests/TestExchangeHolder.cpp @@ -821,10 +821,10 @@ nlTestSuite sSuite = { "Test-TestExchangeHolder", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/messaging/tests/TestExchangeMgr.cpp b/src/messaging/tests/TestExchangeMgr.cpp index cc4dbf10e5a4f4..efca83e6d1a92a 100644 --- a/src/messaging/tests/TestExchangeMgr.cpp +++ b/src/messaging/tests/TestExchangeMgr.cpp @@ -301,10 +301,10 @@ nlTestSuite sSuite = { "Test-CHIP-ExchangeManager", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/messaging/tests/TestMessagingLayer.cpp b/src/messaging/tests/TestMessagingLayer.cpp index 2c05c067989e42..00dca89f2b6639 100644 --- a/src/messaging/tests/TestMessagingLayer.cpp +++ b/src/messaging/tests/TestMessagingLayer.cpp @@ -162,10 +162,10 @@ nlTestSuite sSuite = { "Test-CHIP-MessagingLayer", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/messaging/tests/TestReliableMessageProtocol.cpp b/src/messaging/tests/TestReliableMessageProtocol.cpp index 057aa599726df3..68342838a735b1 100644 --- a/src/messaging/tests/TestReliableMessageProtocol.cpp +++ b/src/messaging/tests/TestReliableMessageProtocol.cpp @@ -2229,10 +2229,10 @@ const nlTest sTests[] = { nlTestSuite sSuite = { "Test-CHIP-ReliableMessageProtocol", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp index c28cb86edf0085..12f9af57a44342 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp @@ -227,18 +227,22 @@ void GenericThreadStackManagerImpl_OpenThread::_OnPlatformEvent(const ThreadDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetThreadDiagnosticsDelegate(); - if (mIsAttached) + if (delegate) { - delegate->OnConnectionStatusChanged(app::Clusters::ThreadNetworkDiagnostics::ConnectionStatusEnum::kConnected); - } - else - { - delegate->OnConnectionStatusChanged(app::Clusters::ThreadNetworkDiagnostics::ConnectionStatusEnum::kNotConnected); + if (mIsAttached) + { + delegate->OnConnectionStatusChanged(app::Clusters::ThreadNetworkDiagnostics::ConnectionStatusEnum::kConnected); + } + else + { + delegate->OnConnectionStatusChanged( + app::Clusters::ThreadNetworkDiagnostics::ConnectionStatusEnum::kNotConnected); - GeneralFaults current; - current.add(to_underlying(chip::app::Clusters::ThreadNetworkDiagnostics::NetworkFaultEnum::kLinkDown)); - delegate->OnNetworkFaultChanged(mNetworkFaults, current); - mNetworkFaults = current; + GeneralFaults current; + current.add(to_underlying(chip::app::Clusters::ThreadNetworkDiagnostics::NetworkFaultEnum::kLinkDown)); + delegate->OnNetworkFaultChanged(mNetworkFaults, current); + mNetworkFaults = current; + } } } diff --git a/src/platform/silabs/CHIPDevicePlatformConfig.h b/src/platform/silabs/CHIPDevicePlatformConfig.h index e8601e5feedaf9..feabf306ab0772 100644 --- a/src/platform/silabs/CHIPDevicePlatformConfig.h +++ b/src/platform/silabs/CHIPDevicePlatformConfig.h @@ -96,7 +96,9 @@ #endif /* CHIP_ENABLE_OPENTHREAD */ #endif /* defined(SL_WIFI) */ +#ifndef CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE #define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1 +#endif #if defined(SL_WIFI) diff --git a/src/protocols/secure_channel/tests/TestCASESession.cpp b/src/protocols/secure_channel/tests/TestCASESession.cpp index 1ef821f30c8b50..5fc6a37f72f4ab 100644 --- a/src/protocols/secure_channel/tests/TestCASESession.cpp +++ b/src/protocols/secure_channel/tests/TestCASESession.cpp @@ -61,9 +61,9 @@ class TestContext : public Test::LoopbackMessagingContext { public: // Performs shared setup for all tests in the test suite - void SetUpTestSuite() override; + static void SetUpTestSuite(); // Performs shared teardown for all tests in the test suite - void TearDownTestSuite() override; + static void TearDownTestSuite(); }; void ServiceEvents(TestContext & ctx) @@ -1240,10 +1240,10 @@ static nlTestSuite sSuite = { "Test-CHIP-SecurePairing-CASE", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/protocols/secure_channel/tests/TestPASESession.cpp b/src/protocols/secure_channel/tests/TestPASESession.cpp index 368811a273ff66..d610b304cec481 100644 --- a/src/protocols/secure_channel/tests/TestPASESession.cpp +++ b/src/protocols/secure_channel/tests/TestPASESession.cpp @@ -89,7 +89,7 @@ class TestContext : public chip::Test::LoopbackMessagingContext { public: // Performs shared setup for all tests in the test suite - void SetUpTestSuite() override + static void SetUpTestSuite() { ConfigInitializeNodes(false); chip::Test::LoopbackMessagingContext::SetUpTestSuite(); @@ -541,10 +541,10 @@ static nlTestSuite sSuite = { "Test-CHIP-SecurePairing-PASE", &sTests[0], - TestContext::nlTestSetUpTestSuite, - TestContext::nlTestTearDownTestSuite, - TestContext::nlTestSetUp, - TestContext::nlTestTearDown, + NL_TEST_WRAP_FUNCTION(TestContext::SetUpTestSuite), + NL_TEST_WRAP_FUNCTION(TestContext::TearDownTestSuite), + NL_TEST_WRAP_METHOD(TestContext, SetUp), + NL_TEST_WRAP_METHOD(TestContext, TearDown), }; // clang-format on diff --git a/src/system/tests/TestSystemTimer.cpp b/src/system/tests/TestSystemTimer.cpp index 6c065b96a01f9a..6271836238b55c 100644 --- a/src/system/tests/TestSystemTimer.cpp +++ b/src/system/tests/TestSystemTimer.cpp @@ -70,7 +70,7 @@ class LayerEvents class LayerEvents::value>::type> @@ -87,7 +87,7 @@ class LayerEvents #include #include +#include #include +#include #include #include +#include #include #include #include @@ -37,6 +40,8 @@ #include #include +#include "SilabsDeviceDataProvider.h" + extern "C" int printf(const char * format, ...) { va_list args; @@ -56,8 +61,11 @@ class NlTest : public pw_rpc::nanopb::NlTest::Service stream_writer = &writer; nlTestSetLogger(&nl_test_logger); - RunRegisteredUnitTests(); - + printf("--- Running nltest ---"); + int status = RunRegisteredUnitTests(); + printf("--- Running gtest ---"); + status += chip::test::RunAllTests(); + printf("Test status: %d", status); stream_writer = nullptr; writer.Finish(); } @@ -194,6 +202,9 @@ int main(void) chip::Platform::MemoryInit(); chip::DeviceLayer::PlatformMgr().InitChipStack(); + // required for inits tied to the event loop + chip::DeviceLayer::SetDeviceInstanceInfoProvider(&chip::DeviceLayer::Silabs::SilabsDeviceDataProvider::GetDeviceDataProvider()); + chip::DeviceLayer::SetCommissionableDataProvider(&chip::DeviceLayer::Silabs::SilabsDeviceDataProvider::GetDeviceDataProvider()); SILABS_LOG("***** CHIP EFR32 device tests *****\r\n"); diff --git a/src/transport/raw/tests/NetworkTestHelpers.h b/src/transport/raw/tests/NetworkTestHelpers.h index bf1e812a87fe02..49890406bc6afb 100644 --- a/src/transport/raw/tests/NetworkTestHelpers.h +++ b/src/transport/raw/tests/NetworkTestHelpers.h @@ -72,7 +72,12 @@ class LoopbackTransportDelegate class LoopbackTransport : public Transport::Base { public: - void InitLoopbackTransport(System::Layer * systemLayer) { mSystemLayer = systemLayer; } + void InitLoopbackTransport(System::Layer * systemLayer) + { + Reset(); + mSystemLayer = systemLayer; + } + void ShutdownLoopbackTransport() { // Make sure no one left packets hanging out that they thought got