Skip to content

Commit cf2d2bd

Browse files
authoredMay 14, 2024
[Silabs]Fix efr32 test driver event loop, run gtests, enable more test on efr… (project-chip#33430)
* Fix efr32 test driver event loop, run gtests, enable more test on efr32 test drivers * add github issue in comments
1 parent 0608519 commit cf2d2bd

File tree

14 files changed

+59
-43
lines changed

14 files changed

+59
-43
lines changed
 

‎src/BUILD.gn

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ if (chip_build_tests) {
9292
]
9393
}
9494

95+
# Skip on efr32 due to flash and/or ram limitations.
9596
if (chip_device_platform != "efr32") {
9697
tests += [
97-
# TODO(#10447): App test has HF on EFR32.
9898
"${chip_root}/src/app/tests",
9999
"${chip_root}/src/credentials/tests",
100100
"${chip_root}/src/lib/format/tests",
@@ -128,7 +128,7 @@ if (chip_build_tests) {
128128
# https://github.com/project-chip/connectedhomeip/issues/9630
129129
if (chip_device_platform != "nrfconnect" &&
130130
chip_device_platform != "efr32") {
131-
# TODO(#10447): Controller test has HF on EFR32.
131+
# Doesn't compile on ef32. Multiple definitions issues with attribute storage and overflows flash memory.
132132
tests += [ "${chip_root}/src/controller/tests/data_model" ]
133133

134134
# Skip controller test for Open IoT SDK

‎src/app/icd/server/tests/TestICDManager.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -1061,10 +1061,15 @@ TEST_F(TestICDManager, TestICDStateObserverOnTransitionToIdleModeEqualActiveMode
10611061

10621062
// Expire IdleMode timer
10631063
AdvanceClockAndRunEventLoop(1_s);
1064-
EXPECT_FALSE(mICDStateObserver.mOnTransitionToIdleCalled);
1064+
// In this scenario, The ICD state machine kicked a OnTransitionToIdle timer with a duration of 0 seconds.
1065+
// The freeRTOS systemlayer timer calls a 0s timer's callback instantly while on posix it take and 1 addition event loop.
1066+
// Thefore, the expect result diverges here based on the systemlayer implementation. Skip this check.
1067+
// https://github.com/project-chip/connectedhomeip/issues/33441
1068+
// EXPECT_FALSE(mICDStateObserver.mOnTransitionToIdleCalled);
10651069

10661070
// Expire OnTransitionToIdleMode
10671071
AdvanceClockAndRunEventLoop(1_ms32);
1072+
// All systems should have called the OnTransitionToIdle callback by now.
10681073
EXPECT_TRUE(mICDStateObserver.mOnTransitionToIdleCalled);
10691074

10701075
// Reset Old durations

‎src/inet/tests/TestInetCommonOptions.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ NetworkOptions::NetworkOptions()
5151
static OptionDef optionDefs[] = {
5252
{ "local-addr", kArgumentRequired, 'a' },
5353
{ "node-addr", kArgumentRequired, kToolCommonOpt_NodeAddr }, /* alias for local-addr */
54-
#if CHIP_SYSTEM_CONFIG_USE_LWIP
54+
#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
5555
{ "tap-device", kArgumentRequired, kToolCommonOpt_TapDevice },
5656
{ "ipv4-gateway", kArgumentRequired, kToolCommonOpt_IPv4GatewayAddr },
5757
{ "ipv6-gateway", kArgumentRequired, kToolCommonOpt_IPv6GatewayAddr },
5858
{ "dns-server", kArgumentRequired, 'X' },
5959
{ "debug-lwip", kNoArgument, kToolCommonOpt_DebugLwIP },
6060
{ "event-delay", kArgumentRequired, kToolCommonOpt_EventDelay },
6161
{ "tap-system-config", kNoArgument, kToolCommonOpt_TapInterfaceConfig },
62-
#endif
62+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
6363
{}
6464
};
6565
OptionDefs = optionDefs;
@@ -69,7 +69,7 @@ NetworkOptions::NetworkOptions()
6969
OptionHelp = " -a, --local-addr, --node-addr <ip-addr>\n"
7070
" Local address for the node.\n"
7171
"\n"
72-
#if CHIP_SYSTEM_CONFIG_USE_LWIP
72+
#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
7373
" --tap-device <tap-dev-name>\n"
7474
" TAP device name for LwIP hosted OS usage. Defaults to chip-dev-<node-id>.\n"
7575
"\n"
@@ -91,22 +91,22 @@ NetworkOptions::NetworkOptions()
9191
" --tap-system-config\n"
9292
" Use configuration on each of the Linux TAP interfaces to configure LwIP's interfaces.\n"
9393
"\n"
94-
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
94+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
9595
;
9696

9797
// Defaults.
9898
LocalIPv4Addr.clear();
9999
LocalIPv6Addr.clear();
100100

101-
#if CHIP_SYSTEM_CONFIG_USE_LWIP
101+
#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
102102
TapDeviceName.clear();
103103
LwIPDebugFlags = 0;
104104
EventDelay = 0;
105105
IPv4GatewayAddr.clear();
106106
IPv6GatewayAddr.clear();
107107
DNSServerAddr = Inet::IPAddress::Any;
108108
TapUseSystemConfig = false;
109-
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
109+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
110110
}
111111

112112
bool NetworkOptions::HandleOption(const char * progName, OptionSet * optSet, int id, const char * name, const char * arg)

‎src/inet/tests/TestInetCommonOptions.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ class NetworkOptions : public chip::ArgParser::OptionSetBase
5959
std::vector<chip::Inet::IPAddress> LocalIPv4Addr;
6060
std::vector<chip::Inet::IPAddress> LocalIPv6Addr;
6161

62-
#if CHIP_SYSTEM_CONFIG_USE_LWIP
62+
#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
6363
std::vector<chip::Inet::IPAddress> IPv4GatewayAddr;
6464
std::vector<chip::Inet::IPAddress> IPv6GatewayAddr;
6565
chip::Inet::IPAddress DNSServerAddr;
6666
std::vector<const char *> TapDeviceName;
6767
uint8_t LwIPDebugFlags;
6868
uint32_t EventDelay;
6969
bool TapUseSystemConfig;
70-
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
70+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
7171

7272
NetworkOptions();
7373

‎src/inet/tests/TestInetCommonPosix.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ void InitNetwork()
337337
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
338338
gTCP.Init(gSystemLayer);
339339
#endif
340-
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
340+
#if INET_CONFIG_ENABLE_UDP_ENDPOINT
341341
gUDP.Init(gSystemLayer);
342342
#endif
343343
}
@@ -368,14 +368,14 @@ void ServiceEvents(uint32_t aSleepTimeMilliseconds)
368368
gSystemLayer.HandleEvents();
369369
#endif
370370

371-
#if CHIP_SYSTEM_CONFIG_USE_LWIP
371+
#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
372372
if (gSystemLayer.IsInitialized())
373373
{
374374
static uint32_t sRemainingSystemLayerEventDelay = 0;
375375

376376
if (sRemainingSystemLayerEventDelay == 0)
377377
{
378-
#if CHIP_DEVICE_LAYER_TARGET_OPEN_IOT_SDK
378+
#if CHIP_DEVICE_LAYER_TARGET_OPEN_IOT_SDK || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
379379
// We need to terminate event loop after performance single step.
380380
// Event loop processing work items until StopEventLoopTask is called.
381381
// Scheduling StopEventLoop task guarantees correct operation of the loop.
@@ -390,7 +390,7 @@ void ServiceEvents(uint32_t aSleepTimeMilliseconds)
390390

391391
gSystemLayer.HandlePlatformTimer();
392392
}
393-
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
393+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
394394
}
395395

396396
#if CHIP_SYSTEM_CONFIG_USE_LWIP && !(CHIP_SYSTEM_CONFIG_LWIP_SKIP_INIT)

‎src/lib/core/tests/BUILD.gn

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ chip_test_suite("tests") {
3030
"TestOptional.cpp",
3131
"TestReferenceCounted.cpp",
3232
"TestTLV.cpp",
33-
"TestTLVVectorWriter.cpp",
3433
]
3534

35+
# requires large amount of heap for multiple unfragmented 10k buffers
36+
# skip for efr32 to allow flash space for other tests
37+
if (chip_device_platform != "efr32") {
38+
test_sources += [ "TestTLVVectorWriter.cpp" ]
39+
}
40+
3641
cflags = [ "-Wconversion" ]
3742

3843
public_deps = [

‎src/lib/support/UnitTestUtils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ uint64_t TimeMonotonicMillis()
5151

5252
void SleepMillis(uint64_t millisecs)
5353
{
54-
uint32_t ticks = static_cast<uint32_t>(millisecs / portTICK_PERIOD_MS);
54+
uint32_t ticks = pdMS_TO_TICKS(millisecs);
5555
vTaskDelay(ticks == 0 ? 1 : ticks); // delay at least 1 tick
5656
}
5757

‎src/messaging/tests/BUILD.gn

+12-19
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,20 @@ static_library("helpers") {
4949
chip_test_suite_using_nltest("tests") {
5050
output_name = "libMessagingLayerTests"
5151

52-
test_sources = []
53-
54-
if (chip_device_platform != "efr32") {
55-
# TODO(#10447): ReliableMessage Test has HF, and ExchangeMgr hangs on EFR32.
56-
# And TestAbortExchangesForFabric does not link on EFR32 for some reason.
57-
# TODO #33372: TestExchange.cpp asserts in ExchangeContext::SendMessage
58-
test_sources += [
59-
"TestAbortExchangesForFabric.cpp",
60-
"TestExchange.cpp",
61-
"TestExchangeMgr.cpp",
62-
"TestReliableMessageProtocol.cpp",
63-
]
52+
test_sources = [
53+
"TestAbortExchangesForFabric.cpp",
54+
"TestExchange.cpp",
55+
"TestExchangeMgr.cpp",
56+
"TestReliableMessageProtocol.cpp",
57+
]
6458

65-
if (chip_device_platform != "esp32" && chip_device_platform != "mbed" &&
66-
chip_device_platform != "nrfconnect" && chip_device_platform != "nxp") {
67-
test_sources += [ "TestExchangeHolder.cpp" ]
68-
}
59+
if (chip_device_platform != "esp32" && chip_device_platform != "mbed" &&
60+
chip_device_platform != "nrfconnect" && chip_device_platform != "nxp") {
61+
test_sources += [ "TestExchangeHolder.cpp" ]
62+
}
6963

70-
if (chip_device_platform == "linux") {
71-
test_sources += [ "TestMessagingLayer.cpp" ]
72-
}
64+
if (chip_device_platform == "linux") {
65+
test_sources += [ "TestMessagingLayer.cpp" ]
7366
}
7467

7568
cflags = [ "-Wconversion" ]

‎src/platform/silabs/CHIPDevicePlatformConfig.h

+2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@
9696
#endif /* CHIP_ENABLE_OPENTHREAD */
9797
#endif /* defined(SL_WIFI) */
9898

99+
#ifndef CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
99100
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1
101+
#endif
100102

101103
#if defined(SL_WIFI)
102104

‎src/system/tests/TestSystemTimer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class LayerEvents<LayerImpl, typename std::enable_if<std::is_base_of<LayerSocket
7070

7171
#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
7272

73-
#if CHIP_SYSTEM_CONFIG_USE_LWIP
73+
#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
7474

7575
template <class LayerImpl>
7676
class LayerEvents<LayerImpl, typename std::enable_if<std::is_base_of<LayerImplFreeRTOS, LayerImpl>::value>::type>
@@ -87,7 +87,7 @@ class LayerEvents<LayerImpl, typename std::enable_if<std::is_base_of<LayerImplFr
8787
}
8888
};
8989

90-
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
90+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
9191

9292
// Test input vector format.
9393
static const uint32_t MAX_NUM_TIMERS = 1000;

‎src/test_driver/efr32/args.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")
2323
chip_enable_pw_rpc = true
2424
chip_build_tests = true
2525
chip_enable_openthread = true
26-
chip_openthread_ftd = true
26+
chip_openthread_ftd = false # use mtd as it is smaller.
2727
chip_monolithic_tests = true
2828

2929
openthread_external_platform =

‎src/test_driver/efr32/include/CHIPProjectConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
*
7171
* Enable support for Chip-over-BLE (CHIPoBLE).
7272
*/
73-
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1
73+
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 0
7474

7575
/**
7676
* CHIP_DEVICE_CONFIG_USE_TEST_SERIAL_NUMBER

‎src/test_driver/efr32/include/FreeRTOSConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ extern "C" {
146146
/* Some of the standard demo test tasks assume a tick rate of 1KHz, even
147147
though that is faster than would normally be warranted by a real
148148
application. */
149-
#define configTICK_RATE_HZ (1000)
149+
#define configTICK_RATE_HZ (1024)
150150

151151
/* Energy saving modes. */
152152
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)

‎src/test_driver/efr32/src/main.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222
#include <FreeRTOS.h>
2323
#include <PigweedLogger.h>
2424
#include <PigweedLoggerMutex.h>
25+
#include <credentials/DeviceAttestationCredsProvider.h>
2526
#include <cstring>
27+
#include <examples/platform/silabs/SilabsDeviceAttestationCreds.h>
2628
#include <lib/support/CHIPMem.h>
2729
#include <lib/support/CHIPPlatformMemory.h>
30+
#include <lib/support/UnitTest.h>
2831
#include <lib/support/UnitTestRegistration.h>
2932
#include <mbedtls/platform.h>
3033
#include <nl_test_service/nl_test.rpc.pb.h>
@@ -37,6 +40,8 @@
3740
#include <sl_system_kernel.h>
3841
#include <task.h>
3942

43+
#include "SilabsDeviceDataProvider.h"
44+
4045
extern "C" int printf(const char * format, ...)
4146
{
4247
va_list args;
@@ -56,8 +61,11 @@ class NlTest : public pw_rpc::nanopb::NlTest::Service<NlTest>
5661
stream_writer = &writer;
5762
nlTestSetLogger(&nl_test_logger);
5863

59-
RunRegisteredUnitTests();
60-
64+
printf("--- Running nltest ---");
65+
int status = RunRegisteredUnitTests();
66+
printf("--- Running gtest ---");
67+
status += chip::test::RunAllTests();
68+
printf("Test status: %d", status);
6169
stream_writer = nullptr;
6270
writer.Finish();
6371
}
@@ -194,6 +202,9 @@ int main(void)
194202
chip::Platform::MemoryInit();
195203

196204
chip::DeviceLayer::PlatformMgr().InitChipStack();
205+
// required for inits tied to the event loop
206+
chip::DeviceLayer::SetDeviceInstanceInfoProvider(&chip::DeviceLayer::Silabs::SilabsDeviceDataProvider::GetDeviceDataProvider());
207+
chip::DeviceLayer::SetCommissionableDataProvider(&chip::DeviceLayer::Silabs::SilabsDeviceDataProvider::GetDeviceDataProvider());
197208

198209
SILABS_LOG("***** CHIP EFR32 device tests *****\r\n");
199210

0 commit comments

Comments
 (0)