1 /* 2 Test FreeRTOS support for core dump. 3 */ 4 5 #include <stdio.h> 6 #include "soc/cpu.h" 7 #include "freertos/FreeRTOS.h" 8 #include "freertos/task.h" 9 #include "unity.h" 10 #include "sdkconfig.h" 11 12 #define TEST_MAX_TASKS_NUM 32 13 14 /* simple test to check that in normal conditions uxTaskGetSnapshotAll does not generate exception */ 15 TEST_CASE("Tasks snapshot", "[freertos]") 16 { 17 TaskSnapshot_t tasks[TEST_MAX_TASKS_NUM]; 18 UBaseType_t tcb_sz; 19 #ifndef CONFIG_FREERTOS_UNICORE 20 int other_core_id = xPortGetCoreID() == 0 ? 1 : 0; 21 #endif 22 23 // uxTaskGetSnapshotAll is supposed to be called when all tasks on both CPUs are 24 // inactive and can not alter FreeRTOS internal tasks lists, e.g. from panic handler 25 unsigned state = portENTER_CRITICAL_NESTED(); 26 #ifndef CONFIG_FREERTOS_UNICORE 27 esp_cpu_stall(other_core_id); 28 #endif 29 UBaseType_t task_num = uxTaskGetSnapshotAll(tasks, TEST_MAX_TASKS_NUM, &tcb_sz); 30 #ifndef CONFIG_FREERTOS_UNICORE 31 esp_cpu_unstall(other_core_id); 32 #endif 33 portEXIT_CRITICAL_NESTED(state); 34 35 printf("Dumped %d tasks. TCB size %d\n", task_num, tcb_sz); 36 TEST_ASSERT_NOT_EQUAL(0, task_num); 37 TEST_ASSERT_NOT_EQUAL(0, tcb_sz); 38 } 39