[Silabs]Fix efr32 test driver event loop, run gtests, enable more test on efr… (#33430)
* Fix efr32 test driver event loop, run gtests, enable more test on efr32 test drivers
* add github issue in comments
diff --git a/src/BUILD.gn b/src/BUILD.gn
index 01aae8a..cf15f40 100644
--- a/src/BUILD.gn
+++ b/src/BUILD.gn
@@ -92,9 +92,9 @@
]
}
+ # 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 @@
# 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 6cba8c3..45e7816 100644
--- a/src/app/icd/server/tests/TestICDManager.cpp
+++ b/src/app/icd/server/tests/TestICDManager.cpp
@@ -1061,10 +1061,15 @@
// 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/inet/tests/TestInetCommonOptions.cpp b/src/inet/tests/TestInetCommonOptions.cpp
index fdc79b1..7e4648d 100644
--- a/src/inet/tests/TestInetCommonOptions.cpp
+++ b/src/inet/tests/TestInetCommonOptions.cpp
@@ -51,7 +51,7 @@
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 @@
{ "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 @@
OptionHelp = " -a, --local-addr, --node-addr <ip-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 <tap-dev-name>\n"
" TAP device name for LwIP hosted OS usage. Defaults to chip-dev-<node-id>.\n"
"\n"
@@ -91,14 +91,14 @@
" --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 @@
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 9b3cd2e..a67536d 100644
--- a/src/inet/tests/TestInetCommonOptions.h
+++ b/src/inet/tests/TestInetCommonOptions.h
@@ -59,7 +59,7 @@
std::vector<chip::Inet::IPAddress> LocalIPv4Addr;
std::vector<chip::Inet::IPAddress> LocalIPv6Addr;
-#if CHIP_SYSTEM_CONFIG_USE_LWIP
+#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
std::vector<chip::Inet::IPAddress> IPv4GatewayAddr;
std::vector<chip::Inet::IPAddress> IPv6GatewayAddr;
chip::Inet::IPAddress DNSServerAddr;
@@ -67,7 +67,7 @@
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 9d5e458..6fc53a1 100644
--- a/src/inet/tests/TestInetCommonPosix.cpp
+++ b/src/inet/tests/TestInetCommonPosix.cpp
@@ -337,7 +337,7 @@
#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 @@
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 @@
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 30d50ee..0010780 100644
--- a/src/lib/core/tests/BUILD.gn
+++ b/src/lib/core/tests/BUILD.gn
@@ -30,9 +30,14 @@
"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/UnitTestUtils.cpp b/src/lib/support/UnitTestUtils.cpp
index 8497640..0d3acae 100644
--- a/src/lib/support/UnitTestUtils.cpp
+++ b/src/lib/support/UnitTestUtils.cpp
@@ -51,7 +51,7 @@
void SleepMillis(uint64_t millisecs)
{
- uint32_t ticks = static_cast<uint32_t>(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 a78dcce..89f0934 100644
--- a/src/messaging/tests/BUILD.gn
+++ b/src/messaging/tests/BUILD.gn
@@ -49,27 +49,20 @@
chip_test_suite_using_nltest("tests") {
output_name = "libMessagingLayerTests"
- test_sources = []
+ test_sources = [
+ "TestAbortExchangesForFabric.cpp",
+ "TestExchange.cpp",
+ "TestExchangeMgr.cpp",
+ "TestReliableMessageProtocol.cpp",
+ ]
- 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",
- ]
+ 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/platform/silabs/CHIPDevicePlatformConfig.h b/src/platform/silabs/CHIPDevicePlatformConfig.h
index e8601e5..feabf30 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/system/tests/TestSystemTimer.cpp b/src/system/tests/TestSystemTimer.cpp
index 6c065b9..6271836 100644
--- a/src/system/tests/TestSystemTimer.cpp
+++ b/src/system/tests/TestSystemTimer.cpp
@@ -70,7 +70,7 @@
#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
-#if CHIP_SYSTEM_CONFIG_USE_LWIP
+#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
template <class LayerImpl>
class LayerEvents<LayerImpl, typename std::enable_if<std::is_base_of<LayerImplFreeRTOS, LayerImpl>::value>::type>
@@ -87,7 +87,7 @@
}
};
-#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
+#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
// Test input vector format.
static const uint32_t MAX_NUM_TIMERS = 1000;
diff --git a/src/test_driver/efr32/args.gni b/src/test_driver/efr32/args.gni
index 76d4cdc..71bf093 100644
--- a/src/test_driver/efr32/args.gni
+++ b/src/test_driver/efr32/args.gni
@@ -23,7 +23,7 @@
chip_enable_pw_rpc = true
chip_build_tests = true
chip_enable_openthread = true
-chip_openthread_ftd = true
+chip_openthread_ftd = false # use mtd as it is smaller.
chip_monolithic_tests = true
openthread_external_platform =
diff --git a/src/test_driver/efr32/include/CHIPProjectConfig.h b/src/test_driver/efr32/include/CHIPProjectConfig.h
index 2122abe..d54c343 100644
--- a/src/test_driver/efr32/include/CHIPProjectConfig.h
+++ b/src/test_driver/efr32/include/CHIPProjectConfig.h
@@ -70,7 +70,7 @@
*
* Enable support for Chip-over-BLE (CHIPoBLE).
*/
-#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1
+#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 0
/**
* CHIP_DEVICE_CONFIG_USE_TEST_SERIAL_NUMBER
diff --git a/src/test_driver/efr32/include/FreeRTOSConfig.h b/src/test_driver/efr32/include/FreeRTOSConfig.h
index cffb27f..7a02673 100644
--- a/src/test_driver/efr32/include/FreeRTOSConfig.h
+++ b/src/test_driver/efr32/include/FreeRTOSConfig.h
@@ -146,7 +146,7 @@
/* Some of the standard demo test tasks assume a tick rate of 1KHz, even
though that is faster than would normally be warranted by a real
application. */
-#define configTICK_RATE_HZ (1000)
+#define configTICK_RATE_HZ (1024)
/* Energy saving modes. */
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
diff --git a/src/test_driver/efr32/src/main.cpp b/src/test_driver/efr32/src/main.cpp
index 57d0bab..2634d94 100644
--- a/src/test_driver/efr32/src/main.cpp
+++ b/src/test_driver/efr32/src/main.cpp
@@ -22,9 +22,12 @@
#include <FreeRTOS.h>
#include <PigweedLogger.h>
#include <PigweedLoggerMutex.h>
+#include <credentials/DeviceAttestationCredsProvider.h>
#include <cstring>
+#include <examples/platform/silabs/SilabsDeviceAttestationCreds.h>
#include <lib/support/CHIPMem.h>
#include <lib/support/CHIPPlatformMemory.h>
+#include <lib/support/UnitTest.h>
#include <lib/support/UnitTestRegistration.h>
#include <mbedtls/platform.h>
#include <nl_test_service/nl_test.rpc.pb.h>
@@ -37,6 +40,8 @@
#include <sl_system_kernel.h>
#include <task.h>
+#include "SilabsDeviceDataProvider.h"
+
extern "C" int printf(const char * format, ...)
{
va_list args;
@@ -56,8 +61,11 @@
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 @@
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");