Skip to content

Commit 02cd025

Browse files
test(freertos): Added a test for vTaskDeleteWithCaps when stack is in ext RAM
This commit adds a stress tests for creating multiple tasks with xTaskCreateWithCaps such that the stack is allocated in external SPIRAM. Then the tasks self-delete. This is done iteratively as stress test.
1 parent f889414 commit 02cd025

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

components/freertos/test_apps/freertos/misc/test_idf_additions.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,34 @@ TEST_CASE("IDF additions: Task creation with memory caps and self deletion", "[f
8989
xTaskNotifyGive(task_handle);
9090
}
9191

92+
#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
93+
94+
TEST_CASE("IDF additions: Task creation with SPIRAM memory caps and self deletion stress test", "[freertos]")
95+
{
96+
#define TEST_NUM_TASKS 5
97+
#define TEST_NUM_ITERATIONS 1000
98+
TaskHandle_t task_handle[TEST_NUM_TASKS];
99+
StackType_t *puxStackBuffer;
100+
StaticTask_t *pxTaskBuffer;
101+
102+
for (int j = 0; j < TEST_NUM_ITERATIONS; j++) {
103+
for (int i = 0; i < TEST_NUM_TASKS; i++) {
104+
// Create a task with caps
105+
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));
106+
TEST_ASSERT_NOT_EQUAL(NULL, task_handle);
107+
// Get the task's memory
108+
TEST_ASSERT_EQUAL(pdTRUE, xTaskGetStaticBuffers(task_handle[i], &puxStackBuffer, &pxTaskBuffer));
109+
}
110+
111+
for (int i = 0; i < TEST_NUM_TASKS; i++) {
112+
// Notify the task to delete itself
113+
xTaskNotifyGive(task_handle[i]);
114+
}
115+
}
116+
}
117+
118+
#endif /* CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY */
119+
92120
#if ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 )
93121

94122
static void task_with_caps_running_on_other_core(void *arg)

components/freertos/test_apps/freertos/sdkconfig.ci.psram

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CONFIG_IDF_TARGET="esp32"
55
# Enable SPIRAM
66
CONFIG_SPIRAM=y
77
CONFIG_SPIRAM_OCCUPY_NO_HOST=y
8+
CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y
89

910
# Disable encrypted flash reads/writes to save IRAM in this build configuration
1011
CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=n

0 commit comments

Comments
 (0)