mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-03 00:21:44 +01:00 
			
		
		
		
	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.
This commit is contained in:
		@@ -1,2 +1,2 @@
 | 
			
		||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
 | 
			
		||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
 | 
			
		||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
 | 
			
		||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
 | 
			
		||||
 
 | 
			
		||||
@@ -89,6 +89,34 @@ TEST_CASE("IDF additions: Task creation with memory caps and self deletion", "[f
 | 
			
		||||
    xTaskNotifyGive(task_handle);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
 | 
			
		||||
 | 
			
		||||
TEST_CASE("IDF additions: Task creation with SPIRAM memory caps and self deletion stress test", "[freertos]")
 | 
			
		||||
{
 | 
			
		||||
#define TEST_NUM_TASKS      5
 | 
			
		||||
#define TEST_NUM_ITERATIONS 1000
 | 
			
		||||
    TaskHandle_t task_handle[TEST_NUM_TASKS];
 | 
			
		||||
    StackType_t *puxStackBuffer;
 | 
			
		||||
    StaticTask_t *pxTaskBuffer;
 | 
			
		||||
 | 
			
		||||
    for (int j = 0; j < TEST_NUM_ITERATIONS; j++) {
 | 
			
		||||
        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));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < TEST_NUM_TASKS; i++) {
 | 
			
		||||
            // Notify the task to delete itself
 | 
			
		||||
            xTaskNotifyGive(task_handle[i]);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY */
 | 
			
		||||
 | 
			
		||||
#if ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 )
 | 
			
		||||
 | 
			
		||||
static void task_with_caps_running_on_other_core(void *arg)
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ CONFIG_IDF_TARGET="esp32"
 | 
			
		||||
# Enable SPIRAM
 | 
			
		||||
CONFIG_SPIRAM=y
 | 
			
		||||
CONFIG_SPIRAM_OCCUPY_NO_HOST=y
 | 
			
		||||
CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y
 | 
			
		||||
 | 
			
		||||
# Disable encrypted flash reads/writes to save IRAM in this build configuration
 | 
			
		||||
CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=n
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user