diff --git a/src/BUILD.gn b/src/BUILD.gn index ba05860d6a110e..d290cf04cf2737 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -120,7 +120,7 @@ if (chip_build_tests) { tests += [ "${chip_root}/src/lib/dnssd/minimal_mdns/tests" ] } - if (chip_device_platform != "esp32" && chip_device_platform != "ameba") { + if (chip_device_platform != "ameba") { tests += [ "${chip_root}/src/platform/tests" ] } diff --git a/src/platform/tests/BUILD.gn b/src/platform/tests/BUILD.gn index ba092e2f7ee5dd..8ea985de6bc2e2 100644 --- a/src/platform/tests/BUILD.gn +++ b/src/platform/tests/BUILD.gn @@ -60,6 +60,12 @@ if (chip_device_platform != "none" && chip_device_platform != "fake") { "TestConfigurationMgr.cpp", "TestPlatformTime.cpp", ] + + defines = [] + if (chip_device_platform == "esp32") { + # SleepMillis can undersleep by as much as 10ms on esp32-qemu. + defines += [ "CONFIG_WIDER_SLEEP_MARGIN" ] + } } if (chip_enable_openthread) { diff --git a/src/platform/tests/TestPlatformMgr.cpp b/src/platform/tests/TestPlatformMgr.cpp index 51ec10bf8766dc..6592ad91ed2d89 100644 --- a/src/platform/tests/TestPlatformMgr.cpp +++ b/src/platform/tests/TestPlatformMgr.cpp @@ -207,9 +207,15 @@ TEST_F(TestPlatformMgr, RunEventLoopStopBeforeSleep) TEST_F(TestPlatformMgr, TryLockChipStack) { + EXPECT_EQ(PlatformMgr().InitChipStack(), CHIP_NO_ERROR); + bool locked = PlatformMgr().TryLockChipStack(); + EXPECT_EQ(locked, !CHIP_SYSTEM_CONFIG_NO_LOCKING); + if (locked) PlatformMgr().UnlockChipStack(); + + PlatformMgr().Shutdown(); } static int sEventRecieved = 0; diff --git a/src/platform/tests/TestPlatformTime.cpp b/src/platform/tests/TestPlatformTime.cpp index ad7a59052b21f4..e9e15b8ac66510 100644 --- a/src/platform/tests/TestPlatformTime.cpp +++ b/src/platform/tests/TestPlatformTime.cpp @@ -42,7 +42,12 @@ using namespace chip::Logging; using namespace chip::System; using namespace chip::System::Clock::Literals; +#ifdef CONFIG_WIDER_SLEEP_MARGIN +// SleepMillis can undersleep by as much as 10ms on esp32-qemu. +constexpr Clock::Milliseconds64 kTestTimeMarginMs = 10_ms64; +#else constexpr Clock::Milliseconds64 kTestTimeMarginMs = 2_ms64; +#endif constexpr Clock::Microseconds64 kTestTimeMarginUs = 500_us64; // ================================= diff --git a/src/test_driver/esp32/CMakeLists.txt b/src/test_driver/esp32/CMakeLists.txt index c1707cf082f555..1dea06ff1c6c77 100644 --- a/src/test_driver/esp32/CMakeLists.txt +++ b/src/test_driver/esp32/CMakeLists.txt @@ -53,6 +53,7 @@ esp32_unit_test(NAME testMinimalMdnsCore LIBRARY MinimalMdnsCoreTests) esp32_unit_test(NAME testMinimalMdnsRecords LIBRARY MinimalMdnsRecordsTests) esp32_unit_test(NAME testMinimalMdnsResponders LIBRARY MinimalMdnsRespondersTests) esp32_unit_test(NAME testMdns LIBRARY MdnsTests) +esp32_unit_test(NAME testPlatform LIBRARY PlatformTests) esp32_unit_test(NAME testRetransmit LIBRARY RetransmitTests) esp32_unit_test(NAME testSetupPayload LIBRARY SetupPayloadTests) esp32_unit_test(NAME testSystemLayer LIBRARY SystemLayerTests)