Merge branch 'task/fix_flaky_freertos_psram_test_v6.0' into 'release/v6.0'

fix(freertos): Fix flaky PSRAM tests for freertos (v6.0)

See merge request espressif/esp-idf!46924
This commit is contained in:
Marius Vikhammer
2026-03-24 09:19:08 +08:00
4 changed files with 11 additions and 8 deletions
@@ -31,8 +31,8 @@ void setUp(void)
void tearDown(void)
{
// Add a short delay of 10ms to allow the idle task to free an remaining memory
vTaskDelay(pdMS_TO_TICKS(10));
// Add a short delay of 10 ticks to allow the idle task to free remaining memory.
vTaskDelay(10);
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
check_leak(before_free_8bit, after_free_8bit, "8BIT");
@@ -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 */
@@ -354,7 +357,7 @@ TEST_CASE("IDF additions: IDF tick hooks during scheduler suspension", "[freerto
/* Cleanup */
vTaskSuspend(suspend_task_handle[x]);
vTaskDelay(pdMS_TO_TICKS(10));
vTaskDelay(10);
vTaskDelete(suspend_task_handle[x]);
}
}
@@ -67,7 +67,7 @@ TEST_CASE("Test TLSP deletion callbacks", "[freertos]")
TEST_ASSERT_EQUAL(pdPASS, xTaskCreatePinnedToCore(tlsp_task, "tlsp_tsk", configMINIMAL_STACK_SIZE * 2, (void *)&tlsps[i], UNITY_FREERTOS_PRIORITY - 1, &tasks[i], i));
}
// Significant delay to let tasks run and delete themselves
vTaskDelay(pdMS_TO_TICKS(100));
vTaskDelay(100);
// Check the values of the TLSPs to see if the del cb have ran
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
@@ -216,7 +216,7 @@ TEST_CASE("LoadStore: 8/16-bit field access in IRAM from ISRs when pending inter
esp_rom_printf("test passed\n");
heap_caps_free((void *)s_iram);
vTaskDelay(pdMS_TO_TICKS(100)); // Wait for memory to be freed, to avoid affecting other tests.
vTaskDelay(100); // Wait in ticks for memory to be freed, to avoid affecting other tests.
}
TEST_CASE("LoadStore: zero-overhead loop continues after IRAM 8-bit store", "[freertos]")
@@ -273,6 +273,6 @@ TEST_CASE("LoadStore: zero-overhead loop continues after IRAM 8-bit store", "[fr
heap_caps_free(dst);
heap_caps_free(src);
vTaskDelay(pdMS_TO_TICKS(100)); // Wait for free to complete before running other tests.
vTaskDelay(100); // Wait for free to complete before running other tests.
}
#endif // CONFIG_IDF_TARGET_ARCH_XTENSA && CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY