diff --git a/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c b/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c index 91fd82e6074..9899493bafb 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c +++ b/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c @@ -97,6 +97,8 @@ TEST_CASE("light sleep stress test", "[lightsleep]") #if CONFIG_FREERTOS_NUMBER_OF_CORES == 2 xSemaphoreTake(done, portMAX_DELAY); #endif + /* vTaskDelete() only queues TCB/stack for idle; wait for two idle passes. */ + vTaskDelay(2); vSemaphoreDelete(done); } @@ -123,9 +125,12 @@ TEST_CASE("light sleep stress test with periodic esp_timer", "[lightsleep]") #if CONFIG_FREERTOS_NUMBER_OF_CORES == 2 xSemaphoreTake(done, portMAX_DELAY); #endif - vSemaphoreDelete(done); + /* Stop the periodic timer first, otherwise it starves idle and the + * self-deleted worker looks like a leak to Unity. */ esp_timer_stop(timer); esp_timer_delete(timer); + vTaskDelay(2); + vSemaphoreDelete(done); } #endif // !(CONFIG_SPIRAM) || (CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL >= 16384)