From 4ae2f6a6a11bb56d9c9e35263e37a751d486d0dd Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Thu, 19 Mar 2026 15:08:55 +0100 Subject: [PATCH] fix(freertos): Fix flaky PSRAM tests for freertos This commit adds additional delays to the stress test where we create and self-delete tasks on PSRAM. iSuch tasks rely on the kernel creating a special cleanup task to delete them. Hence, the delays in the main task allow the cleanup task to bescheduled and the deletion to go through. --- .../freertos/test_apps/freertos/misc/test_idf_additions.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/freertos/test_apps/freertos/misc/test_idf_additions.c b/components/freertos/test_apps/freertos/misc/test_idf_additions.c index 99e67eb97b..d9fc67adb7 100644 --- a/components/freertos/test_apps/freertos/misc/test_idf_additions.c +++ b/components/freertos/test_apps/freertos/misc/test_idf_additions.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -103,7 +103,6 @@ TEST_CASE("IDF additions: Task creation with SPIRAM memory caps and self deletio for (int i = 0; i < TEST_NUM_TASKS; i++) { // Create a task with caps TEST_ASSERT_EQUAL(pdPASS, xTaskCreateWithCaps(task_with_caps_self_delete, "task", 4096, NULL, UNITY_FREERTOS_PRIORITY, &task_handle[i], MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)); - TEST_ASSERT_NOT_EQUAL(NULL, task_handle); // Get the task's memory TEST_ASSERT_EQUAL(pdTRUE, xTaskGetStaticBuffers(task_handle[i], &puxStackBuffer, &pxTaskBuffer)); } @@ -112,7 +111,11 @@ TEST_CASE("IDF additions: Task creation with SPIRAM memory caps and self deletio // Notify the task to delete itself xTaskNotifyGive(task_handle[i]); } + // Let the scheduler run the self-delete tasks. + vTaskDelay(1); } + // Allow the last batch to be freed by the cleanup task in vTaskDeleteWithCaps(). + vTaskDelay(50); } #endif /* CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM */