diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index 2a28d51ba..9e8ef1626 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -1515,13 +1515,11 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode /*-----------------------------------------------------------*/ #if ( INCLUDE_uxTaskPriorityGet == 1 ) -/* ToDo: Make this multicore-compatible. */ UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask ) { TCB_t *pxTCB; UBaseType_t uxReturn; - UNTESTED_FUNCTION(); taskENTER_CRITICAL(&xTaskQueueMutex); { /* If null is passed in here then we are changing the @@ -1538,7 +1536,6 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode /*-----------------------------------------------------------*/ #if ( INCLUDE_uxTaskPriorityGet == 1 ) -/* ToDo: Make this multicore-compatible. */ UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) { TCB_t *pxTCB; diff --git a/components/freertos/test/test_task_priorities.c b/components/freertos/test/test_task_priorities.c new file mode 100644 index 000000000..75df3598b --- /dev/null +++ b/components/freertos/test/test_task_priorities.c @@ -0,0 +1,81 @@ +/* + Unit tests for FreeRTOS task priority get/set +*/ + +#include +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "unity.h" + + +static void counter_task(void *param) +{ + volatile uint32_t *counter = (volatile uint32_t *)param; + while (1) { + (*counter)++; + } +} + + +TEST_CASE("Get/Set Priorities", "[freertos]") +{ + /* Two tasks per processor */ + TaskHandle_t tasks[portNUM_PROCESSORS][2] = { 0 }; + unsigned volatile counters[portNUM_PROCESSORS][2] = { 0 }; + + TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY, uxTaskPriorityGet(NULL)); + + /* create a matrix of counter tasks on each core */ + for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) { + for (int task = 0; task < 2; task++) { + xTaskCreatePinnedToCore(counter_task, "count", 2048, (void *)&(counters[cpu][task]), UNITY_FREERTOS_PRIORITY - task, &(tasks[cpu][task]), cpu); + } + } + + /* check they were created with the expected priorities */ + for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) { + for (int task = 0; task < 2; task++) { + TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY - task, uxTaskPriorityGet(tasks[cpu][task])); + } + } + + vTaskDelay(10); + + /* at this point, only the higher priority tasks (first index) should be counting */ + for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) { + TEST_ASSERT_NOT_EQUAL(0, counters[cpu][0]); + TEST_ASSERT_EQUAL(0, counters[cpu][1]); + } + + /* swap priorities! */ + for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) { + vTaskPrioritySet(tasks[cpu][0], UNITY_FREERTOS_PRIORITY - 1); + vTaskPrioritySet(tasks[cpu][1], UNITY_FREERTOS_PRIORITY); + } + + /* check priorities have swapped... */ + for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) { + TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY -1, uxTaskPriorityGet(tasks[cpu][0])); + TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY, uxTaskPriorityGet(tasks[cpu][1])); + } + + /* check the tasks which are counting have also swapped now... */ + for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) { + unsigned old_counters[2]; + old_counters[0] = counters[cpu][0]; + old_counters[1] = counters[cpu][1]; + vTaskDelay(10); + TEST_ASSERT_EQUAL(old_counters[0], counters[cpu][0]); + TEST_ASSERT_NOT_EQUAL(old_counters[1], counters[cpu][1]); + } + + /* clean up */ + for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) { + for (int task = 0; task < 2; task++) { + vTaskDelete(tasks[cpu][task]); + } + } +} diff --git a/tools/unit-test-app/sdkconfig b/tools/unit-test-app/sdkconfig index e4b897348..abbb29229 100644 --- a/tools/unit-test-app/sdkconfig +++ b/tools/unit-test-app/sdkconfig @@ -111,12 +111,9 @@ CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y # CONFIG_ESP32_APPTRACE_DEST_UART is not set CONFIG_ESP32_APPTRACE_DEST_NONE=y # CONFIG_ESP32_APPTRACE_ENABLE is not set -CONFIG_BASE_MAC_STORED_DEFAULT_EFUSE=y -# CONFIG_BASE_MAC_STORED_CUSTOMER_DEFINED_EFUSE is not set -# CONFIG_BASE_MAC_STORED_OTHER_CUSTOMER_DEFINED_PLACE is not set -# CONFIG_TWO_MAC_ADDRESS_FROM_EFUSE is not set -CONFIG_FOUR_MAC_ADDRESS_FROM_EFUSE=y -CONFIG_NUMBER_OF_MAC_ADDRESS_GENERATED_FROM_EFUSE=4 +# CONFIG_TWO_UNIVERSAL_MAC_ADDRESS is not set +CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y +CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4 CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2048 CONFIG_MAIN_TASK_STACK_SIZE=4096