From d07c700af88e1039f0d4b3cbfd7aebc84affb06c Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Fri, 20 Sep 2024 10:14:12 +0200 Subject: [PATCH] test(freertos): Added delay to freertos test to avoid memory leaks This commit adds a small delay as tolerance to the "Test xTaskResumeAll resumes pended tasks" test to let the idle task clean up all suspended test tasks and avoid memory leaks at the end of the test. --- .../tasks/test_vTaskSuspendAll_xTaskResumeAll.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/freertos/test/integration/tasks/test_vTaskSuspendAll_xTaskResumeAll.c b/components/freertos/test/integration/tasks/test_vTaskSuspendAll_xTaskResumeAll.c index 4ef4f081e4..f5d62c1c79 100644 --- a/components/freertos/test/integration/tasks/test_vTaskSuspendAll_xTaskResumeAll.c +++ b/components/freertos/test/integration/tasks/test_vTaskSuspendAll_xTaskResumeAll.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -487,6 +487,9 @@ static void test_pended_running_task(void *arg) TEST_ASSERT_EQUAL(true, has_run[i]); } + // Short delay to let the tasks be suspended + vTaskDelay(10); + // Clean up the interrupt and tasks deregister_intr_cb(); for (int i = 0; i < TEST_PENDED_NUM_BLOCKED_TASKS; i++) { @@ -506,6 +509,8 @@ TEST_CASE("Test xTaskResumeAll resumes pended tasks", "[freertos]") TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(test_pended_running_task, "susp", 2048, (void *)xTaskGetCurrentTaskHandle(), UNITY_FREERTOS_PRIORITY + 1, &susp_tsk_hdl, i)); // Wait for to be notified to test completion ulTaskNotifyTake(pdTRUE, portMAX_DELAY); + // Short delay to let the task be suspended + vTaskDelay(10); vTaskDelete(susp_tsk_hdl); } // Add a short delay to allow the idle task to free any remaining task memory