Skip to content

Commit b205837

Browse files
authored
Adds platform/tests to the ESP32-QEMU unit-test target (#37753)
* Adds src/platform/tests into esp32-qemu-tests target * CI * Skip TryLockChipStack test on Darwin * Updated to use CHIP_SYSTEM_CONFIG_NO_LOCKING * Comment update * Expect statement checks if lock result matches "no locking" value.
1 parent fa36c44 commit b205837

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

src/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ if (chip_build_tests) {
120120
tests += [ "${chip_root}/src/lib/dnssd/minimal_mdns/tests" ]
121121
}
122122

123-
if (chip_device_platform != "esp32" && chip_device_platform != "ameba") {
123+
if (chip_device_platform != "ameba") {
124124
tests += [ "${chip_root}/src/platform/tests" ]
125125
}
126126

src/platform/tests/BUILD.gn

+6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ if (chip_device_platform != "none" && chip_device_platform != "fake") {
6060
"TestConfigurationMgr.cpp",
6161
"TestPlatformTime.cpp",
6262
]
63+
64+
defines = []
65+
if (chip_device_platform == "esp32") {
66+
# SleepMillis can undersleep by as much as 10ms on esp32-qemu.
67+
defines += [ "CONFIG_WIDER_SLEEP_MARGIN" ]
68+
}
6369
}
6470

6571
if (chip_enable_openthread) {

src/platform/tests/TestPlatformMgr.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,15 @@ TEST_F(TestPlatformMgr, RunEventLoopStopBeforeSleep)
207207

208208
TEST_F(TestPlatformMgr, TryLockChipStack)
209209
{
210+
EXPECT_EQ(PlatformMgr().InitChipStack(), CHIP_NO_ERROR);
211+
210212
bool locked = PlatformMgr().TryLockChipStack();
213+
EXPECT_EQ(locked, !CHIP_SYSTEM_CONFIG_NO_LOCKING);
214+
211215
if (locked)
212216
PlatformMgr().UnlockChipStack();
217+
218+
PlatformMgr().Shutdown();
213219
}
214220

215221
static int sEventRecieved = 0;

src/platform/tests/TestPlatformTime.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ using namespace chip::Logging;
4242
using namespace chip::System;
4343
using namespace chip::System::Clock::Literals;
4444

45+
#ifdef CONFIG_WIDER_SLEEP_MARGIN
46+
// SleepMillis can undersleep by as much as 10ms on esp32-qemu.
47+
constexpr Clock::Milliseconds64 kTestTimeMarginMs = 10_ms64;
48+
#else
4549
constexpr Clock::Milliseconds64 kTestTimeMarginMs = 2_ms64;
50+
#endif
4651
constexpr Clock::Microseconds64 kTestTimeMarginUs = 500_us64;
4752

4853
// =================================

src/test_driver/esp32/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ esp32_unit_test(NAME testMinimalMdnsCore LIBRARY MinimalMdnsCoreTests)
5353
esp32_unit_test(NAME testMinimalMdnsRecords LIBRARY MinimalMdnsRecordsTests)
5454
esp32_unit_test(NAME testMinimalMdnsResponders LIBRARY MinimalMdnsRespondersTests)
5555
esp32_unit_test(NAME testMdns LIBRARY MdnsTests)
56+
esp32_unit_test(NAME testPlatform LIBRARY PlatformTests)
5657
esp32_unit_test(NAME testRetransmit LIBRARY RetransmitTests)
5758
esp32_unit_test(NAME testSetupPayload LIBRARY SetupPayloadTests)
5859
esp32_unit_test(NAME testSystemLayer LIBRARY SystemLayerTests)

0 commit comments

Comments
 (0)