refactor(freertos): Updated FreeRTOS component files to astyle format

This commit updates the FreeRTOS component source files (excluding
upstream source files) to the astyle coding format.
This commit is contained in:
Sudeep Mohanty 2024-01-26 15:07:54 +01:00 committed by BOT
parent b2b84f9b5c
commit 061da98124
34 changed files with 384 additions and 402 deletions

View File

@ -51,7 +51,7 @@ For now, AMP is not supported (i.e., running FreeRTOS on one core and a bare met
CONFIG_FREERTOS_UNICORE and CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE should be identical. We add a check for this here.
*/
#if CONFIG_FREERTOS_UNICORE != CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
#error "AMP not supported. FreeRTOS number of cores and system number of cores must be identical"
#error "AMP not supported. FreeRTOS number of cores and system number of cores must be identical"
#endif
// -------------------- Declarations -----------------------

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -30,21 +30,21 @@
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 0 )
#error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0
#error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0
#endif
#include "esp_heap_caps.h"
#if !CONFIG_IDF_TARGET_LINUX
/* Memory util functions are not implemented in the Linux simulator */
#include "esp_memory_utils.h"
/* Memory util functions are not implemented in the Linux simulator */
#include "esp_memory_utils.h"
#endif /* CONFIG_IDF_TARGET_LINUX */
#define portFREERTOS_HEAP_CAPS ( MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT )
/*-----------------------------------------------------------*/
void * pvPortMalloc( size_t xWantedSize )
void * pvPortMalloc(size_t xWantedSize)
{
void * pvReturn = NULL;
@ -52,57 +52,57 @@ void * pvPortMalloc( size_t xWantedSize )
* users need to allocate FreeRTOS objects into external RAM, they should
* use the "static" equivalents of FreeRTOS API to create FreeRTOS objects
* (e.g., queues). */
pvReturn = heap_caps_malloc( xWantedSize, portFREERTOS_HEAP_CAPS );
pvReturn = heap_caps_malloc(xWantedSize, portFREERTOS_HEAP_CAPS);
return pvReturn;
}
/*-----------------------------------------------------------*/
void vPortFree( void * pv )
void vPortFree(void * pv)
{
heap_caps_free( pv );
heap_caps_free(pv);
}
/*-----------------------------------------------------------*/
size_t xPortGetFreeHeapSize( void )
size_t xPortGetFreeHeapSize(void)
{
return heap_caps_get_free_size( portFREERTOS_HEAP_CAPS );
return heap_caps_get_free_size(portFREERTOS_HEAP_CAPS);
}
/*-----------------------------------------------------------*/
size_t xPortGetMinimumEverFreeHeapSize( void )
size_t xPortGetMinimumEverFreeHeapSize(void)
{
return heap_caps_get_minimum_free_size( portFREERTOS_HEAP_CAPS );
return heap_caps_get_minimum_free_size(portFREERTOS_HEAP_CAPS);
}
/*-----------------------------------------------------------*/
bool xPortCheckValidListMem( const void * ptr )
bool xPortCheckValidListMem(const void * ptr)
{
#if CONFIG_IDF_TARGET_LINUX
return true;
#else /* CONFIG_IDF_TARGET_LINUX */
return esp_ptr_internal( ptr ) && esp_ptr_byte_accessible( ptr );
#endif /* CONFIG_IDF_TARGET_LINUX */
#if CONFIG_IDF_TARGET_LINUX
return true;
#else /* CONFIG_IDF_TARGET_LINUX */
return esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr);
#endif /* CONFIG_IDF_TARGET_LINUX */
}
bool xPortCheckValidTCBMem( const void * ptr )
bool xPortCheckValidTCBMem(const void * ptr)
{
#if CONFIG_IDF_TARGET_LINUX
return true;
#else /* CONFIG_IDF_TARGET_LINUX */
return esp_ptr_internal( ptr ) && esp_ptr_byte_accessible( ptr );
#endif /* CONFIG_IDF_TARGET_LINUX */
#if CONFIG_IDF_TARGET_LINUX
return true;
#else /* CONFIG_IDF_TARGET_LINUX */
return esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr);
#endif /* CONFIG_IDF_TARGET_LINUX */
}
bool xPortcheckValidStackMem( const void * ptr )
bool xPortcheckValidStackMem(const void * ptr)
{
#if CONFIG_IDF_TARGET_LINUX
return true;
#else /* CONFIG_IDF_TARGET_LINUX */
#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
return esp_ptr_byte_accessible( ptr );
#else
return esp_ptr_internal( ptr ) && esp_ptr_byte_accessible( ptr );
#endif
#endif /* CONFIG_IDF_TARGET_LINUX */
#if CONFIG_IDF_TARGET_LINUX
return true;
#else /* CONFIG_IDF_TARGET_LINUX */
#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
return esp_ptr_byte_accessible(ptr);
#else
return esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr);
#endif
#endif /* CONFIG_IDF_TARGET_LINUX */
}

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -27,7 +27,7 @@ We simply allocate the IDLE/Timer tasks memory from the FreeRTOS heap.
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
StackType_t **ppxIdleTaskStackBuffer,
uint32_t *pulIdleTaskStackSize )
uint32_t *pulIdleTaskStackSize)
{
StaticTask_t *pxTCBBufferTemp;
StackType_t *pxStackBufferTemp;
@ -37,17 +37,17 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
* If the stack grows down then allocate the stack then the TCB so the stack
* does not grow into the TCB. Likewise if the stack grows up then allocate
* the TCB then the stack. */
#if (portSTACK_GROWTH > 0)
#if (portSTACK_GROWTH > 0)
{
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
pxStackBufferTemp = pvPortMalloc(configMINIMAL_STACK_SIZE);
}
#else /* portSTACK_GROWTH */
#else /* portSTACK_GROWTH */
{
pxStackBufferTemp = pvPortMalloc(configMINIMAL_STACK_SIZE);
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
}
#endif /* portSTACK_GROWTH */
#endif /* portSTACK_GROWTH */
assert(pxTCBBufferTemp != NULL);
assert(pxStackBufferTemp != NULL);
@ -59,7 +59,7 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
StackType_t **ppxTimerTaskStackBuffer,
uint32_t *pulTimerTaskStackSize )
uint32_t *pulTimerTaskStackSize)
{
StaticTask_t *pxTCBBufferTemp;
StackType_t *pxStackBufferTemp;
@ -69,17 +69,17 @@ void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
* If the stack grows down then allocate the stack then the TCB so the stack
* does not grow into the TCB. Likewise if the stack grows up then allocate
* the TCB then the stack. */
#if (portSTACK_GROWTH > 0)
#if (portSTACK_GROWTH > 0)
{
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
pxStackBufferTemp = pvPortMalloc(configTIMER_TASK_STACK_DEPTH);
}
#else /* portSTACK_GROWTH */
#else /* portSTACK_GROWTH */
{
pxStackBufferTemp = pvPortMalloc(configTIMER_TASK_STACK_DEPTH);
pxTCBBufferTemp = pvPortMalloc(sizeof(StaticTask_t));
}
#endif /* portSTACK_GROWTH */
#endif /* portSTACK_GROWTH */
assert(pxTCBBufferTemp != NULL);
assert(pxStackBufferTemp != NULL);

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -10,18 +10,18 @@
#include "FreeRTOS.h"
#include "task.h"
#if ( !CONFIG_FREERTOS_SMP && ( configNUM_CORES > 1 ) )
/* Required for xTaskIncrementTickOtherCores() */
#include "esp_private/freertos_idf_additions_priv.h"
/* Required for xTaskIncrementTickOtherCores() */
#include "esp_private/freertos_idf_additions_priv.h"
#endif /* ( !CONFIG_FREERTOS_SMP && ( configNUM_CORES > 1 ) ) */
#if CONFIG_FREERTOS_SYSTICK_USES_CCOUNT
#if CONFIG_FREERTOS_CORETIMER_0
#define SYSTICK_INTR_ID (ETS_INTERNAL_TIMER0_INTR_SOURCE + ETS_INTERNAL_INTR_SOURCE_OFF)
#else /* CONFIG_FREERTOS_CORETIMER_1 */
#define SYSTICK_INTR_ID (ETS_INTERNAL_TIMER1_INTR_SOURCE + ETS_INTERNAL_INTR_SOURCE_OFF)
#endif
#if CONFIG_FREERTOS_CORETIMER_0
#define SYSTICK_INTR_ID (ETS_INTERNAL_TIMER0_INTR_SOURCE + ETS_INTERNAL_INTR_SOURCE_OFF)
#else /* CONFIG_FREERTOS_CORETIMER_1 */
#define SYSTICK_INTR_ID (ETS_INTERNAL_TIMER1_INTR_SOURCE + ETS_INTERNAL_INTR_SOURCE_OFF)
#endif
#else /* CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER */
#define SYSTICK_INTR_ID (ETS_SYSTIMER_TARGET0_INTR_SOURCE)
#define SYSTICK_INTR_ID (ETS_SYSTIMER_TARGET0_INTR_SOURCE)
#endif /* CONFIG_FREERTOS_SYSTICK_USES_CCOUNT */
BaseType_t xPortSysTickHandler(void);
@ -168,15 +168,15 @@ void SysTickIsrHandler(void *arg)
*/
void vPortSetupTimer(void)
{
#if CONFIG_FREERTOS_SYSTICK_USES_CCOUNT
extern void _frxt_tick_timer_init(void);
extern void _xt_tick_divisor_init(void);
/* Init the tick divisor value */
_xt_tick_divisor_init();
_frxt_tick_timer_init();
#else /* CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER */
vSystimerSetup();
#endif /* CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER */
#if CONFIG_FREERTOS_SYSTICK_USES_CCOUNT
extern void _frxt_tick_timer_init(void);
extern void _xt_tick_divisor_init(void);
/* Init the tick divisor value */
_xt_tick_divisor_init();
_frxt_tick_timer_init();
#else /* CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER */
vSystimerSetup();
#endif /* CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER */
}
/**
@ -200,39 +200,39 @@ BaseType_t xPortSysTickHandler(void)
// Call FreeRTOS Increment tick function
BaseType_t xSwitchRequired;
#if CONFIG_FREERTOS_SMP
// Amazon SMP FreeRTOS requires that only core 0 calls xTaskIncrementTick()
#if ( configNUM_CORES > 1 )
if (portGET_CORE_ID() == 0) {
xSwitchRequired = xTaskIncrementTick();
} else {
xSwitchRequired = pdFALSE;
}
#else /* configNUM_CORES > 1 */
xSwitchRequired = xTaskIncrementTick();
#endif /* configNUM_CORES > 1 */
#else /* !CONFIG_FREERTOS_SMP */
#if ( configNUM_CORES > 1 )
/*
Multi-core IDF FreeRTOS requires that...
- core 0 calls xTaskIncrementTick()
- core 1 calls xTaskIncrementTickOtherCores()
*/
if (xPortGetCoreID() == 0) {
xSwitchRequired = xTaskIncrementTick();
} else {
xSwitchRequired = xTaskIncrementTickOtherCores();
}
#else /* configNUM_CORES > 1 */
/*
Vanilla (single core) FreeRTOS expects that xTaskIncrementTick() cannot be interrupted (i.e., no nested
interrupts). Thus we have to disable interrupts before calling it.
*/
UBaseType_t uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
xSwitchRequired = xTaskIncrementTick();
portCLEAR_INTERRUPT_MASK_FROM_ISR(uxSavedInterruptStatus);
#endif /* configNUM_CORES > 1 */
#endif /* !CONFIG_FREERTOS_SMP */
#if CONFIG_FREERTOS_SMP
// Amazon SMP FreeRTOS requires that only core 0 calls xTaskIncrementTick()
#if ( configNUM_CORES > 1 )
if (portGET_CORE_ID() == 0) {
xSwitchRequired = xTaskIncrementTick();
} else {
xSwitchRequired = pdFALSE;
}
#else /* configNUM_CORES > 1 */
xSwitchRequired = xTaskIncrementTick();
#endif /* configNUM_CORES > 1 */
#else /* !CONFIG_FREERTOS_SMP */
#if ( configNUM_CORES > 1 )
/*
Multi-core IDF FreeRTOS requires that...
- core 0 calls xTaskIncrementTick()
- core 1 calls xTaskIncrementTickOtherCores()
*/
if (xPortGetCoreID() == 0) {
xSwitchRequired = xTaskIncrementTick();
} else {
xSwitchRequired = xTaskIncrementTickOtherCores();
}
#else /* configNUM_CORES > 1 */
/*
Vanilla (single core) FreeRTOS expects that xTaskIncrementTick() cannot be interrupted (i.e., no nested
interrupts). Thus we have to disable interrupts before calling it.
*/
UBaseType_t uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
xSwitchRequired = xTaskIncrementTick();
portCLEAR_INTERRUPT_MASK_FROM_ISR(uxSavedInterruptStatus);
#endif /* configNUM_CORES > 1 */
#endif /* !CONFIG_FREERTOS_SMP */
// Check if yield is required
if (xSwitchRequired != pdFALSE) {

View File

@ -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
*/
@ -35,7 +35,7 @@ static void task_event_group_call_response(void *param)
for (int i = 0; i < COUNT; i++) {
/* Wait until the common "call" bit is set, starts off all tasks
(clear on return) */
TEST_ASSERT( xEventGroupWaitBits(eg, BIT_CALL(task_num), true, false, portMAX_DELAY) );
TEST_ASSERT(xEventGroupWaitBits(eg, BIT_CALL(task_num), true, false, portMAX_DELAY));
/* Set our individual "response" bit */
xEventGroupSetBits(eg, BIT_RESPONSE(task_num));
@ -78,7 +78,7 @@ TEST_CASE("FreeRTOS Event Groups", "[freertos]")
/* Ensure all tasks have suspend themselves */
for (int c = 0; c < NUM_TASKS; c++) {
TEST_ASSERT( xSemaphoreTake(done_sem, 100 / portTICK_PERIOD_MS) );
TEST_ASSERT(xSemaphoreTake(done_sem, 100 / portTICK_PERIOD_MS));
}
for (int c = 0; c < NUM_TASKS; c++) {
@ -120,12 +120,12 @@ TEST_CASE("FreeRTOS Event Group Sync", "[freertos]")
for (int c = 0; c < NUM_TASKS; c++) {
printf("Waiting on %d (0x%08x)\n", c, BIT_RESPONSE(c));
TEST_ASSERT( xEventGroupWaitBits(eg, BIT_RESPONSE(c), false, false, portMAX_DELAY) );
TEST_ASSERT(xEventGroupWaitBits(eg, BIT_RESPONSE(c), false, false, portMAX_DELAY));
}
/* Ensure all tasks cleaned up correctly */
for (int c = 0; c < NUM_TASKS; c++) {
TEST_ASSERT( xSemaphoreTake(done_sem, 100 / portTICK_PERIOD_MS) );
TEST_ASSERT(xSemaphoreTake(done_sem, 100 / portTICK_PERIOD_MS));
}
vSemaphoreDelete(done_sem);

View File

@ -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
*/
@ -10,63 +10,63 @@
#if ( configNUM_CORES > 1 )
typedef struct {
const TestFunction_t pxTestCode;
void * const pvTestCodeArg;
const SemaphoreHandle_t xTaskDoneSem;
} TestArgs_t;
typedef struct {
const TestFunction_t pxTestCode;
void * const pvTestCodeArg;
const SemaphoreHandle_t xTaskDoneSem;
} TestArgs_t;
static void test_func_task( void * pvParameters )
{
TestArgs_t * pxTestArgs = ( TestArgs_t * ) pvParameters;
/* Call the test function */
pxTestArgs->pxTestCode( pxTestArgs->pvTestCodeArg );
/* Indicate completion to the creation task and wait to be deleted. */
xSemaphoreGive( pxTestArgs->xTaskDoneSem );
vTaskSuspend( NULL );
static void test_func_task(void * pvParameters)
{
TestArgs_t * pxTestArgs = (TestArgs_t *) pvParameters;
/* Call the test function */
pxTestArgs->pxTestCode(pxTestArgs->pvTestCodeArg);
/* Indicate completion to the creation task and wait to be deleted. */
xSemaphoreGive(pxTestArgs->xTaskDoneSem);
vTaskSuspend(NULL);
}
void vTestOnAllCores(TestFunction_t pxTestCode, void * pvTestCodeArg, uint32_t ulStackDepth, UBaseType_t uxPriority)
{
SemaphoreHandle_t xTaskDoneSem = xSemaphoreCreateCounting(configNUM_CORES, 0);
TaskHandle_t xTaskHandles[ configNUM_CORES ];
TestArgs_t xTestArgs = {
.pxTestCode = pxTestCode,
.pvTestCodeArg = pvTestCodeArg,
.xTaskDoneSem = xTaskDoneSem,
};
/* Create a separate task on each core to run the test function */
for (BaseType_t xCoreID = 0; xCoreID < configNUM_CORES; xCoreID++) {
#if ( CONFIG_FREERTOS_SMP == 1 )
xTaskCreateAffinitySet(test_func_task,
"task",
ulStackDepth,
(void *) &xTestArgs,
uxPriority,
(UBaseType_t)(1 << xCoreID),
&(xTaskHandles[ xCoreID ]));
#else
xTaskCreatePinnedToCore(test_func_task,
"task",
ulStackDepth,
(void *) &xTestArgs,
uxPriority,
&(xTaskHandles[ xCoreID ]),
xCoreID);
#endif
}
void vTestOnAllCores( TestFunction_t pxTestCode, void * pvTestCodeArg, uint32_t ulStackDepth, UBaseType_t uxPriority )
{
SemaphoreHandle_t xTaskDoneSem = xSemaphoreCreateCounting( configNUM_CORES, 0 );
TaskHandle_t xTaskHandles[ configNUM_CORES ];
TestArgs_t xTestArgs = {
.pxTestCode = pxTestCode,
.pvTestCodeArg = pvTestCodeArg,
.xTaskDoneSem = xTaskDoneSem,
};
/* Create a separate task on each core to run the test function */
for( BaseType_t xCoreID = 0; xCoreID < configNUM_CORES; xCoreID++ ) {
#if ( CONFIG_FREERTOS_SMP == 1 )
xTaskCreateAffinitySet( test_func_task,
"task",
ulStackDepth,
( void * ) &xTestArgs,
uxPriority,
( UBaseType_t ) ( 1 << xCoreID ),
&( xTaskHandles[ xCoreID ] ) );
#else
xTaskCreatePinnedToCore( test_func_task,
"task",
ulStackDepth,
( void * ) &xTestArgs,
uxPriority,
&( xTaskHandles[ xCoreID ] ),
xCoreID );
#endif
}
/* Wait for each tasks to complete test */
for( BaseType_t xCoreID = 0; xCoreID < configNUM_CORES; xCoreID++ ) {
xSemaphoreTake( xTaskDoneSem, portMAX_DELAY );
}
/* Cleanup */
for( BaseType_t xCoreID = 0; xCoreID < configNUM_CORES; xCoreID++ ) {
vTaskDelete( xTaskHandles[ xCoreID ] );
}
vSemaphoreDelete( xTaskDoneSem );
/* Wait for each tasks to complete test */
for (BaseType_t xCoreID = 0; xCoreID < configNUM_CORES; xCoreID++) {
xSemaphoreTake(xTaskDoneSem, portMAX_DELAY);
}
/* Cleanup */
for (BaseType_t xCoreID = 0; xCoreID < configNUM_CORES; xCoreID++) {
vTaskDelete(xTaskHandles[ xCoreID ]);
}
vSemaphoreDelete(xTaskDoneSem);
}
#endif /* ( configNUM_CORES > 1 ) */

View File

@ -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
*/
@ -9,24 +9,24 @@
#if ( configNUM_CORES > 1 )
/**
* @brief Prototype for test function.
*
* A test function can be passed to vTestOnAllCores() which will run the test function from a task on each core.
*/
typedef void (* TestFunction_t)( void * );
/**
* @brief Prototype for test function.
*
* A test function can be passed to vTestOnAllCores() which will run the test function from a task on each core.
*/
typedef void (* TestFunction_t)(void *);
/**
* @brief Run a test function on each core
*
* This function will internally create a task pinned to each core, where each task will call the provided test
* function. This function will block until all cores finish executing the test function.
*
* @param pxTestCode Test function
* @param pvTestCodeArg Argument provided to test function
* @param ulStackDepth Stack depth of the created tasks
* @param uxPriority Priority of the created tasks
*/
void vTestOnAllCores( TestFunction_t pxTestCode, void * pvTestCodeArg, uint32_t ulStackDepth, UBaseType_t uxPriority );
/**
* @brief Run a test function on each core
*
* This function will internally create a task pinned to each core, where each task will call the provided test
* function. This function will block until all cores finish executing the test function.
*
* @param pxTestCode Test function
* @param pvTestCodeArg Argument provided to test function
* @param ulStackDepth Stack depth of the created tasks
* @param uxPriority Priority of the created tasks
*/
void vTestOnAllCores(TestFunction_t pxTestCode, void * pvTestCodeArg, uint32_t ulStackDepth, UBaseType_t uxPriority);
#endif /* ( configNUM_CORES > 1 ) */

View File

@ -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
*/
@ -70,7 +70,7 @@ TEST_CASE("Test FreeRTOS backported timer functions", "[freertos]")
TEST_ASSERT_UINT32_WITHIN(TICK_DELTA, tmr_ideal_exp, xTimerGetExpiryTime(tmr_handle)); //Test xTimerGetExpiryTime()
vTaskDelay(2*TMR_PERIOD_TICKS); //Delay until one shot timer has triggered
vTaskDelay(2 * TMR_PERIOD_TICKS); //Delay until one shot timer has triggered
TEST_ASSERT_EQUAL(pdPASS, xTimerDelete(tmr_handle, portMAX_DELAY)); //Clean up
}
@ -90,22 +90,22 @@ TEST_CASE("Test FreeRTOS backported timer functions", "[freertos]")
#define DELAY_TICKS 2
static StaticQueue_t queue_buffer; //Queues, Semaphores, and Mutex use the same queue structure
static uint8_t queue_storage_area[(ITEM_SIZE*NO_OF_ITEMS)]; //Queue storage provided in separate buffer to queue struct
static uint8_t queue_storage_area[(ITEM_SIZE * NO_OF_ITEMS)]; //Queue storage provided in separate buffer to queue struct
TEST_CASE("Test FreeRTOS backported Queue and Semphr functions", "[freertos]")
{
//Test static queue
uint8_t queue_item_to_send[ITEM_SIZE];
uint8_t queue_item_received[ITEM_SIZE];
for(int i = 0; i < ITEM_SIZE; i++){
for (int i = 0; i < ITEM_SIZE; i++) {
queue_item_to_send[i] = (0xF << i);
}
QueueHandle_t handle = xQueueCreateStatic(NO_OF_ITEMS, ITEM_SIZE,(uint8_t*) &queue_storage_area, &queue_buffer);
QueueHandle_t handle = xQueueCreateStatic(NO_OF_ITEMS, ITEM_SIZE, (uint8_t*) &queue_storage_area, &queue_buffer);
TEST_ASSERT_EQUAL(pdTRUE, xQueueSendToBack(handle, &queue_item_to_send, DELAY_TICKS));
vTaskDelay(1);
TEST_ASSERT_EQUAL(pdTRUE, xQueueReceive(handle, queue_item_received, DELAY_TICKS));
vTaskDelay(1);
for(int i = 0; i < ITEM_SIZE; i++){
for (int i = 0; i < ITEM_SIZE; i++) {
TEST_ASSERT_EQUAL(queue_item_to_send[i], queue_item_received[i]); //Check received contents are correct
}
vQueueDelete(handle); //Technically not needed as deleting static queue/semphr doesn't clear static memory
@ -120,12 +120,12 @@ TEST_CASE("Test FreeRTOS backported Queue and Semphr functions", "[freertos]")
//Test static counting semaphore and uxSemaphoreGetCount()
handle = xSemaphoreCreateCountingStatic(NO_OF_ITEMS, 0, &queue_buffer);
for(int i = 0; i < NO_OF_ITEMS; i++){
for (int i = 0; i < NO_OF_ITEMS; i++) {
TEST_ASSERT_EQUAL(pdTRUE, xSemaphoreGive(handle));
}
vTaskDelay(1);
TEST_ASSERT_EQUAL(NO_OF_ITEMS, uxSemaphoreGetCount(handle)); //Test uxSemaphoreGetCount()
for(int i = 0; i < NO_OF_ITEMS; i++){
for (int i = 0; i < NO_OF_ITEMS; i++) {
TEST_ASSERT_EQUAL(pdTRUE, xSemaphoreTake(handle, DELAY_TICKS));
}
vTaskDelay(1);
@ -144,12 +144,12 @@ TEST_CASE("Test FreeRTOS backported Queue and Semphr functions", "[freertos]")
//Test static mutex recursive
handle = xSemaphoreCreateRecursiveMutexStatic(&queue_buffer);
for(int i = 0; i < NO_OF_ITEMS; i++){
for (int i = 0; i < NO_OF_ITEMS; i++) {
TEST_ASSERT_EQUAL(pdTRUE, xSemaphoreTakeRecursive(handle, DELAY_TICKS));
}
vTaskDelay(1);
TEST_ASSERT_EQUAL_PTR((void *)xTaskGetCurrentTaskHandle(), xSemaphoreGetMutexHolder(handle)); //Current task should hold mutex
for(int i = 0; i < NO_OF_ITEMS; i++){
for (int i = 0; i < NO_OF_ITEMS; i++) {
TEST_ASSERT_EQUAL(pdTRUE, xSemaphoreGiveRecursive(handle));
}
vTaskDelay(1);
@ -177,7 +177,7 @@ static void task(void *arg)
TEST_CASE("Test FreeRTOS static task allocation", "[freertos]")
{
for(int core = 0; core < portNUM_PROCESSORS; core++){
for (int core = 0; core < portNUM_PROCESSORS; core++) {
has_run[core] = false; //Clear has_run flag
TaskHandle_t handle = xTaskCreateStaticPinnedToCore(task, "static task", STACK_SIZE, NULL,
UNITY_FREERTOS_PRIORITY + 1, (StackType_t *)&task_stack,

View File

@ -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
*/
@ -35,22 +35,22 @@ void test_queue_registry_task(void *arg)
int core = xPortGetCoreID();
int offset = core * NO_OF_QUEUES_PER_CORE;
//Create queues and accompanying queue names
for(int i = 0; i < NO_OF_QUEUES_PER_CORE; i++){
handles[i + offset] = xQueueCreate(1,1); //Create queues
for (int i = 0; i < NO_OF_QUEUES_PER_CORE; i++) {
handles[i + offset] = xQueueCreate(1, 1); //Create queues
names[i + offset] = calloc(QUEUE_NAME_MAX_LENGTH, sizeof(char));
sprintf(names[i + offset], "Queue%d%d", core, i);
}
xSemaphoreTake(start_sem[core], portMAX_DELAY); //Wait for start vQueueAddToRegistry()
for(int i = 0; i < NO_OF_QUEUES_PER_CORE; i++){
vQueueAddToRegistry(handles[i + offset] , names[i + offset]); //Register queues to queue registry
for (int i = 0; i < NO_OF_QUEUES_PER_CORE; i++) {
vQueueAddToRegistry(handles[i + offset], names[i + offset]); //Register queues to queue registry
}
xSemaphoreGive(done_sem); //Signal that vQueueAddToRegistry() has completed
vTaskDelay(1);
xSemaphoreTake(start_sem[core], portMAX_DELAY); //Wait to start vQueueUnregisterQueue()
for(int i = 0; i < NO_OF_QUEUES_PER_CORE; i++){
for (int i = 0; i < NO_OF_QUEUES_PER_CORE; i++) {
vQueueDelete(handles[i + offset]); //Internally calls vQueueUnregisterQueue
}
xSemaphoreGive(done_sem); //Signal done
@ -62,44 +62,44 @@ TEST_CASE("Test FreeRTOS Queue Registry", "[freertos]")
{
//Create synchronization semaphores and tasks to test queue registry
done_sem = xSemaphoreCreateCounting(portNUM_PROCESSORS, 0);
for(int i = 0; i < portNUM_PROCESSORS; i++){
for (int i = 0; i < portNUM_PROCESSORS; i++) {
start_sem[i] = xSemaphoreCreateBinary();
xTaskCreatePinnedToCore(test_queue_registry_task, "testing task", 4096, NULL, UNITY_FREERTOS_PRIORITY+1, NULL, i);
xTaskCreatePinnedToCore(test_queue_registry_task, "testing task", 4096, NULL, UNITY_FREERTOS_PRIORITY + 1, NULL, i);
}
portDISABLE_INTERRUPTS();
for(int i = 0; i < portNUM_PROCESSORS; i++){
for (int i = 0; i < portNUM_PROCESSORS; i++) {
xSemaphoreGive(start_sem[i]); //Trigger start
}
portENABLE_INTERRUPTS();
for(int i = 0; i < portNUM_PROCESSORS; i++){
for (int i = 0; i < portNUM_PROCESSORS; i++) {
xSemaphoreTake(done_sem, portMAX_DELAY); //Wait for tasks to complete vQueueAddToRegistry
}
for(int i = 0; i < NO_OF_QUEUES_TOTAL; i++){
for (int i = 0; i < NO_OF_QUEUES_TOTAL; i++) {
const char *addr = pcQueueGetName(handles[i]);
TEST_ASSERT(addr == names[i]); //Check vQueueAddToRegistry was successful
}
portDISABLE_INTERRUPTS();
for(int i = 0; i < portNUM_PROCESSORS; i++){
for (int i = 0; i < portNUM_PROCESSORS; i++) {
xSemaphoreGive(start_sem[i]); //Trigger start
}
portENABLE_INTERRUPTS();
for(int i = 0; i < portNUM_PROCESSORS; i++){
for (int i = 0; i < portNUM_PROCESSORS; i++) {
xSemaphoreTake(done_sem, portMAX_DELAY); //Wait for tasks to complete vQueueUnregisterQueue
}
for(int i = 0; i < NO_OF_QUEUES_TOTAL; i++){
for (int i = 0; i < NO_OF_QUEUES_TOTAL; i++) {
const char *addr = pcQueueGetName(handles[i]);
TEST_ASSERT(addr == NULL); //Check vQueueUnregisterQueue was successful
handles[i] = NULL;
}
//Cleanup
for(int i = 0; i < NO_OF_QUEUES_TOTAL; i++){
for (int i = 0; i < NO_OF_QUEUES_TOTAL; i++) {
free(names[i]);
names[i] = NULL;
}
for(int i = 0; i < portNUM_PROCESSORS; i++){
for (int i = 0; i < portNUM_PROCESSORS; i++) {
vSemaphoreDelete(start_sem[i]);
start_sem[i] = NULL;
}

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -64,11 +64,11 @@ TEST_CASE("Stream Buffer: Send-receive tasks", "[freertos]")
BaseType_t sender_core_id;
BaseType_t receiver_core_id;
sender_core_id = 0;
#if CONFIG_FREERTOS_UNICORE
receiver_core_id = 0;
#else
receiver_core_id = 1;
#endif
#if CONFIG_FREERTOS_UNICORE
receiver_core_id = 0;
#else
receiver_core_id = 1;
#endif
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(sender_task, "sender", 4096, &test_args, UNITY_FREERTOS_PRIORITY + 2, NULL, sender_core_id));
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(receiver_task, "receiver", 4096, &test_args, UNITY_FREERTOS_PRIORITY + 1, NULL, receiver_core_id));

View File

@ -26,7 +26,7 @@ Expected:
static void blocked_task(void *arg)
{
vTaskDelay(portMAX_DELAY-1);
vTaskDelay(portMAX_DELAY - 1);
// Shouldn't need to self delete, but added for extra safety
vTaskDelete(NULL);
}

View File

@ -81,7 +81,7 @@ void vTaskPreDeletionHook(void *pxTCB)
TEST_CASE("static task cleanup hook is called based on config", "[freertos]")
{
for(int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < portNUM_PROCESSORS; i++) {
printf("Creating task CPU %d\n", i);
TaskHandle_t new_task = NULL;
deleted_tcb = NULL;

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -33,32 +33,32 @@ static void task_should_never_run(void *arg)
}
static BaseType_t create_task(TaskFunction_t function,
size_t stack_size,
void *task_arg,
int core_num,
UBaseType_t heap_caps,
TaskHandle_t *task_handle)
size_t stack_size,
void *task_arg,
int core_num,
UBaseType_t heap_caps,
TaskHandle_t *task_handle)
{
#if CONFIG_FREERTOS_SMP
UBaseType_t core_affinity_mask = (core_num == -1) ? tskNO_AFFINITY : 1 << core_num;
return prvTaskCreateDynamicAffinitySetWithCaps(function,
"self_delete",
stack_size,
task_arg,
UNITY_FREERTOS_PRIORITY + 1,
core_affinity_mask,
heap_caps,
task_handle);
"self_delete",
stack_size,
task_arg,
UNITY_FREERTOS_PRIORITY + 1,
core_affinity_mask,
heap_caps,
task_handle);
#else
const BaseType_t task_core_num = (core_num == -1) ? tskNO_AFFINITY : core_num;
return prvTaskCreateDynamicPinnedToCoreWithCaps(function,
"self_delete",
stack_size,
task_arg,
UNITY_FREERTOS_PRIORITY + 1,
task_core_num,
heap_caps,
task_handle);
"self_delete",
stack_size,
task_arg,
UNITY_FREERTOS_PRIORITY + 1,
task_core_num,
heap_caps,
task_handle);
#endif
}
@ -69,11 +69,11 @@ TEST_CASE("Out of memory failure", "[freertos][psram]")
UBaseType_t HEAP_CAPS = (MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
BaseType_t result = create_task(task_should_never_run,
STACK_SIZE,
(void *)xTaskGetCurrentTaskHandle(),
-1,
HEAP_CAPS,
&task_handle);
STACK_SIZE,
(void *)xTaskGetCurrentTaskHandle(),
-1,
HEAP_CAPS,
&task_handle);
TEST_ASSERT_EQUAL(errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY, result);
(void)task_handle;
}
@ -85,11 +85,11 @@ TEST_CASE("Task with stack memory in PSRAM", "[freertos][psram]")
UBaseType_t HEAP_CAPS = (MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
BaseType_t result = create_task(task_delete_itself,
STACK_SIZE,
(void *)xTaskGetCurrentTaskHandle(),
-1,
HEAP_CAPS,
&task_handle);
STACK_SIZE,
(void *)xTaskGetCurrentTaskHandle(),
-1,
HEAP_CAPS,
&task_handle);
TEST_ASSERT_EQUAL(pdPASS, result);
// synchronize with the task to make sure we don't return too early, thus giving it enough time
@ -126,11 +126,11 @@ TEST_CASE("Task on specific core works", "[freertos][psram]")
corenum_info.parent_handle = xTaskGetCurrentTaskHandle();
UBaseType_t HEAP_CAPS = (MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
BaseType_t result = create_task(task_report_corenum,
STACK_SIZE,
(void *) &(corenum_info),
corenum,
HEAP_CAPS,
&task_handle);
STACK_SIZE,
(void *) & (corenum_info),
corenum,
HEAP_CAPS,
&task_handle);
TEST_ASSERT_EQUAL(pdPASS, result);

View File

@ -70,7 +70,7 @@ static void spin_task(void *arg)
//Last iteration of the last spin task on this core. Reenable this core's tick interrupt
if (total_iter_count[xPortGetCoreID()] == (NUM_PINNED_SPIN_TASK_PER_CORE * SPIN_TASK_NUM_ITER)) {
esp_cpu_intr_enable(1 <<TICK_INTR_IDX);
esp_cpu_intr_enable(1 << TICK_INTR_IDX);
}
vTaskDelete(NULL);
}

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -33,8 +33,7 @@
/* Caps of all memory which is allocated from when a task is created */
#define HEAP_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
#define DELAY_US_ITERATIONS 1000
#define DELAY_US_ITERATIONS 1000
static void tsk_self_del(void *param)
{
@ -55,11 +54,11 @@ static void tsk_self_del_us_delay(void *param)
TEST_CASE("FreeRTOS Delete Tasks", "[freertos]")
{
/* -------------- Test vTaskDelete() on currently running tasks ----------------*/
/* -------------- Test vTaskDelete() on currently running tasks ----------------*/
uint32_t before_count = uxTaskGetNumberOfTasks();
uint32_t before_heap = heap_caps_get_free_size(HEAP_CAPS);
for(int i = 0; i < portNUM_PROCESSORS; i++){
for(int j = 0; j < NO_OF_TSKS; j++){
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int j = 0; j < NO_OF_TSKS; j++) {
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(tsk_self_del, "tsk_self", 1024, NULL, configMAX_PRIORITIES - 1, NULL, i));
}
}
@ -67,22 +66,22 @@ TEST_CASE("FreeRTOS Delete Tasks", "[freertos]")
TEST_ASSERT_EQUAL(before_count, uxTaskGetNumberOfTasks());
TEST_ASSERT_EQUAL(before_heap, heap_caps_get_free_size(HEAP_CAPS));
/* ------------- Test vTaskDelete() on not currently running tasks ------------ */
/* ------------- Test vTaskDelete() on not currently running tasks ------------ */
TaskHandle_t handles[NO_OF_TSKS];
before_heap = heap_caps_get_free_size(HEAP_CAPS);
//Create task pinned to the same core that will not run during task deletion
for(int j = 0 ; j < NO_OF_TSKS; j++){
for (int j = 0 ; j < NO_OF_TSKS; j++) {
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(tsk_extern_del, "tsk_extern", 4096, NULL, configMAX_PRIORITIES - 1, &handles[j], xPortGetCoreID()));
}
TEST_ASSERT_NOT_EQUAL(before_heap, heap_caps_get_free_size(HEAP_CAPS)); //Check tasks have been created
//Delete the tasks, memory should be freed immediately
for(int j = 0; j < NO_OF_TSKS; j++){
for (int j = 0; j < NO_OF_TSKS; j++) {
vTaskDelete(handles[j]);
}
TEST_ASSERT_EQUAL(before_heap, heap_caps_get_free_size(HEAP_CAPS));
/* Test self deleting no affinity task is not removed by idle task of other core before context switch */
for(int i = 0; i < DELAY_US_ITERATIONS; i+= 10){
/* Test self deleting no affinity task is not removed by idle task of other core before context switch */
for (int i = 0; i < DELAY_US_ITERATIONS; i += 10) {
vTaskDelay(1); //Sync to next tick interrupt
xTaskCreatePinnedToCore(tsk_self_del_us_delay, "delay", 1024, (void *)i, UNITY_FREERTOS_PRIORITY - 1, NULL, tskNO_AFFINITY);
esp_rom_delay_us(10); //Busy wait to ensure no affinity task runs on opposite core
@ -90,7 +89,6 @@ TEST_CASE("FreeRTOS Delete Tasks", "[freertos]")
}
typedef struct {
SemaphoreHandle_t sem;
volatile bool deleted; // Check the deleted task doesn't keep running after being deleted
@ -130,10 +128,10 @@ TEST_CASE("FreeRTOS Delete Blocked Tasks", "[freertos]")
(1000 iterations takes about 9 seconds on ESP32 dual core)
*/
for(unsigned iter = 0; iter < 1000; iter++) {
for (unsigned iter = 0; iter < 1000; iter++) {
// Create everything
SemaphoreHandle_t sem = xSemaphoreCreateMutex();
for(unsigned i = 0; i < portNUM_PROCESSORS + 1; i++) {
for (unsigned i = 0; i < portNUM_PROCESSORS + 1; i++) {
params[i].deleted = false;
params[i].sem = sem;
@ -145,7 +143,7 @@ TEST_CASE("FreeRTOS Delete Blocked Tasks", "[freertos]")
vTaskDelay(5); // Let the tasks juggle the mutex for a bit
for(unsigned i = 0; i < portNUM_PROCESSORS + 1; i++) {
for (unsigned i = 0; i < portNUM_PROCESSORS + 1; i++) {
vTaskDelete(blocking_tasks[i]);
params[i].deleted = true;
}

View File

@ -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
*/
@ -62,7 +62,7 @@ void task_test_trace_utilities(void *arg)
TEST_CASE("Test freertos trace facility functions", "[freertos]")
{
for(int i = 0; i < NO_OF_CORES; i++){
for (int i = 0; i < NO_OF_CORES; i++) {
test_queues[i] = xSemaphoreCreateBinary(); //Create a queue as binary semaphore for each core
xTaskCreatePinnedToCore(task_test_trace_utilities, "Test Task", 4096, (void *)(0x0F << i), TSK_PRIORITY, &task_handles[i], i);
}
@ -70,14 +70,14 @@ TEST_CASE("Test freertos trace facility functions", "[freertos]")
vTaskDelay(10);
//Start the tasks
for(int i = NO_OF_CORES - 1; i >= 0; i--){
for (int i = NO_OF_CORES - 1; i >= 0; i--) {
xSemaphoreGive(test_queues[i]);
}
vTaskDelay(10); //Small delay to ensure semaphores are taken
//Wait for done
for(int i = 0; i < NO_OF_CORES; i++){
for (int i = 0; i < NO_OF_CORES; i++) {
xSemaphoreTake(test_queues[i], portMAX_DELAY);
vSemaphoreDelete(test_queues[i]);
}
@ -85,7 +85,6 @@ TEST_CASE("Test freertos trace facility functions", "[freertos]")
vTaskDelay(10); //Give time for idle task to clean up
}
#define MAX_TASKS 15
#define TASKS_TO_CREATE 5
@ -94,7 +93,7 @@ static TaskStatus_t *tsk_status_array;
void created_task(void* arg)
{
while(1){
while (1) {
vTaskDelay(100);
}
}
@ -102,7 +101,7 @@ void created_task(void* arg)
TEST_CASE("Test freertos uxTaskGetSystemState", "[freertos]")
{
tsk_status_array = calloc(MAX_TASKS, sizeof(TaskStatus_t));
for(int i = 0; i < TASKS_TO_CREATE; i++){
for (int i = 0; i < TASKS_TO_CREATE; i++) {
xTaskCreatePinnedToCore(created_task, "Created Task", 1024, NULL, TSK_PRIORITY, &created_handles[i], 0);
}
@ -112,15 +111,15 @@ TEST_CASE("Test freertos uxTaskGetSystemState", "[freertos]")
//Check if get system state has got all created tasks
bool not_found = false;
for(int i = 0; i < TASKS_TO_CREATE; i++){
for (int i = 0; i < TASKS_TO_CREATE; i++) {
bool found = false;
for(int j = 0; j < MAX_TASKS; j++){
if(tsk_status_array[j].xHandle == created_handles[i]){
for (int j = 0; j < MAX_TASKS; j++) {
if (tsk_status_array[j].xHandle == created_handles[i]) {
found = true;
break;
}
}
if(!found){
if (!found) {
not_found = true;
break;
}
@ -128,7 +127,7 @@ TEST_CASE("Test freertos uxTaskGetSystemState", "[freertos]")
TEST_ASSERT(not_found == false);
//Cleanup
for(int i = 0; i < TASKS_TO_CREATE; i++){
for (int i = 0; i < TASKS_TO_CREATE; i++) {
vTaskDelete(created_handles[i]);
}
free(tsk_status_array);

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -31,7 +31,6 @@ static volatile bool flag;
#define MAX_YIELD_COUNT 17000
#endif // CONFIG_FREERTOS_SMP
/* Task:
- Waits for 'trigger' variable to be set
- Reads the cycle count on this CPU
@ -43,7 +42,7 @@ static void task_send_to_queue(void *param)
QueueHandle_t queue = (QueueHandle_t) param;
uint32_t ccount;
while(!trigger) {}
while (!trigger) {}
ccount = esp_cpu_get_cycle_count();
flag = true;
@ -53,7 +52,7 @@ static void task_send_to_queue(void *param)
The task runs until terminated by the main task.
*/
while(1) {}
while (1) {}
}
TEST_CASE("Yield from lower priority task, same CPU", "[freertos]")
@ -73,9 +72,9 @@ TEST_CASE("Yield from lower priority task, same CPU", "[freertos]")
trigger = true;
uint32_t yield_ccount, now_ccount, delta;
TEST_ASSERT( xQueueReceive(queue, &yield_ccount, 100 / portTICK_PERIOD_MS) );
TEST_ASSERT(xQueueReceive(queue, &yield_ccount, 100 / portTICK_PERIOD_MS));
now_ccount = esp_cpu_get_cycle_count();
TEST_ASSERT( flag );
TEST_ASSERT(flag);
delta = now_ccount - yield_ccount;
printf("Yielding from lower priority task took %"PRIu32" cycles\n", delta);
@ -86,7 +85,6 @@ TEST_CASE("Yield from lower priority task, same CPU", "[freertos]")
}
}
#if (portNUM_PROCESSORS == 2) && !CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH
TEST_CASE("Yield from lower priority task, other CPU", "[freertos]")
{
@ -110,9 +108,9 @@ TEST_CASE("Yield from lower priority task, other CPU", "[freertos]")
// yield_ccount is not useful in this test as it's the other core's CCOUNT
// so we use trigger_ccount instead
TEST_ASSERT( xQueueReceive(queue, &yield_ccount, 100 / portTICK_PERIOD_MS) );
TEST_ASSERT(xQueueReceive(queue, &yield_ccount, 100 / portTICK_PERIOD_MS));
now_ccount = esp_cpu_get_cycle_count();
TEST_ASSERT( flag );
TEST_ASSERT(flag);
delta = now_ccount - trigger_ccount;
printf("Yielding from task on other core took %"PRIu32" cycles\n", delta);

View File

@ -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
*/
@ -64,11 +64,11 @@ static void test_vTaskDelay(void *arg)
/* Check that elapsed ticks and ref clock is accurate. We allow TEST_VTASKDELAY_DELTA_TICKS of error in case
* vTaskDelay() or portTEST_REF_CLOCK_GET_TIME() last long enough to cross a tick boundary */
#if ( configUSE_16_BIT_TICKS == 1 )
TEST_ASSERT_UINT16_WITHIN(TEST_VTASKDELAY_DELTA_TICKS, TEST_VTASKDELAY_TICKS, tick_end - tick_start);
#else
TEST_ASSERT_UINT32_WITHIN(TEST_VTASKDELAY_DELTA_TICKS, TEST_VTASKDELAY_TICKS, tick_end - tick_start);
#endif
#if ( configUSE_16_BIT_TICKS == 1 )
TEST_ASSERT_UINT16_WITHIN(TEST_VTASKDELAY_DELTA_TICKS, TEST_VTASKDELAY_TICKS, tick_end - tick_start);
#else
TEST_ASSERT_UINT32_WITHIN(TEST_VTASKDELAY_DELTA_TICKS, TEST_VTASKDELAY_TICKS, tick_end - tick_start);
#endif
TEST_ASSERT_UINT32_WITHIN(portTEST_TICKS_TO_REF_CLOCK(TEST_VTASKDELAY_DELTA_TICKS),
portTEST_TICKS_TO_REF_CLOCK(TEST_VTASKDELAY_TICKS),
ref_clock_end - ref_clock_start);
@ -79,12 +79,12 @@ TEST_CASE("Tasks: Test vTaskDelay", "[freertos]")
{
portTEST_REF_CLOCK_INIT();
#if ( configNUM_CORES > 1 )
vTestOnAllCores(test_vTaskDelay, NULL, configTEST_DEFAULT_STACK_SIZE, configTEST_UNITY_TASK_PRIORITY - 1);
#else
/* Test vTaskDelay directly on the current core */
test_vTaskDelay(NULL);
#endif
#if ( configNUM_CORES > 1 )
vTestOnAllCores(test_vTaskDelay, NULL, configTEST_DEFAULT_STACK_SIZE, configTEST_UNITY_TASK_PRIORITY - 1);
#else
/* Test vTaskDelay directly on the current core */
test_vTaskDelay(NULL);
#endif
portTEST_REF_CLOCK_DEINIT();
}
@ -144,16 +144,15 @@ static void test_vTaskDelayUntil(void *arg)
tick_end = xTaskGetTickCount();
ref_clock_end = portTEST_REF_CLOCK_GET_TIME();
/* Check that elapsed ticks and ref clock is accurate. We allow TEST_VTASKDELAYUNTIL_DELTA_TICKS of error in
* case vTaskDelayUntil() or portTEST_REF_CLOCK_GET_TIME() last long enough to cross a tick boundary */
#if ( configUSE_16_BIT_TICKS == 1 )
TEST_ASSERT_UINT16_WITHIN(TEST_VTASKDELAYUNTIL_DELTA_TICKS, TEST_VTASKDELAYUNTIL_TICKS, tick_end - tick_start);
TEST_ASSERT_UINT16_WITHIN(TEST_VTASKDELAYUNTIL_DELTA_TICKS, tick_end, last_wake_tick);
#else
TEST_ASSERT_UINT32_WITHIN(TEST_VTASKDELAYUNTIL_DELTA_TICKS, TEST_VTASKDELAYUNTIL_TICKS, tick_end - tick_start);
TEST_ASSERT_UINT32_WITHIN(TEST_VTASKDELAYUNTIL_DELTA_TICKS, tick_end, last_wake_tick);
#endif
#if ( configUSE_16_BIT_TICKS == 1 )
TEST_ASSERT_UINT16_WITHIN(TEST_VTASKDELAYUNTIL_DELTA_TICKS, TEST_VTASKDELAYUNTIL_TICKS, tick_end - tick_start);
TEST_ASSERT_UINT16_WITHIN(TEST_VTASKDELAYUNTIL_DELTA_TICKS, tick_end, last_wake_tick);
#else
TEST_ASSERT_UINT32_WITHIN(TEST_VTASKDELAYUNTIL_DELTA_TICKS, TEST_VTASKDELAYUNTIL_TICKS, tick_end - tick_start);
TEST_ASSERT_UINT32_WITHIN(TEST_VTASKDELAYUNTIL_DELTA_TICKS, tick_end, last_wake_tick);
#endif
/* Check that the elapsed ref clock time is accurate. We allow TEST_VTASKDELAYUNTIL_DELTA_TICKS time worth of
* error to account for the execution time of the ref clock functions. */
@ -167,12 +166,12 @@ TEST_CASE("Tasks: Test vTaskDelayUntil", "[freertos]")
{
portTEST_REF_CLOCK_INIT();
#if ( configNUM_CORES > 1 )
vTestOnAllCores(test_vTaskDelayUntil, NULL, configTEST_DEFAULT_STACK_SIZE, configTEST_UNITY_TASK_PRIORITY - 1);
#else
/* Test vTaskDelay directly on the current core */
test_vTaskDelayUntil(NULL);
#endif
#if ( configNUM_CORES > 1 )
vTestOnAllCores(test_vTaskDelayUntil, NULL, configTEST_DEFAULT_STACK_SIZE, configTEST_UNITY_TASK_PRIORITY - 1);
#else
/* Test vTaskDelay directly on the current core */
test_vTaskDelayUntil(NULL);
#endif
portTEST_REF_CLOCK_DEINIT();
}

View File

@ -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
*/
@ -17,7 +17,6 @@
#include "unity.h"
#include "test_utils.h"
static void counter_task(void *param)
{
volatile uint32_t *counter = (volatile uint32_t *)param;
@ -26,7 +25,6 @@ static void counter_task(void *param)
}
}
TEST_CASE("Get/Set Priorities", "[freertos]")
{
/* Two tasks per processor */
@ -38,7 +36,7 @@ TEST_CASE("Get/Set Priorities", "[freertos]")
/* 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);
xTaskCreatePinnedToCore(counter_task, "count", 2048, (void *) & (counters[cpu][task]), UNITY_FREERTOS_PRIORITY - task, &(tasks[cpu][task]), cpu);
}
}
@ -65,7 +63,7 @@ TEST_CASE("Get/Set Priorities", "[freertos]")
/* 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 - 1, uxTaskPriorityGet(tasks[cpu][0]));
TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY, uxTaskPriorityGet(tasks[cpu][1]));
}

View File

@ -69,7 +69,6 @@ static void test_suspend_resume(int target_core)
vTaskDelete(counter_task);
}
TEST_CASE("Suspend/resume task on same core", "[freertos]")
{
test_suspend_resume(UNITY_FREERTOS_CPU);
@ -119,7 +118,6 @@ TEST_CASE("Suspend the current running task", "[freertos]")
TEST_ASSERT_TRUE(resumed);
}
static volatile bool timer_isr_fired;
static gptimer_handle_t gptimer = NULL;
@ -146,7 +144,6 @@ static IRAM_ATTR void task_suspend_self_with_timer(void *vp_resumed)
vTaskDelete(NULL);
}
/* Create a task which suspends itself, then resume it from a timer
* interrupt. */
static void test_resume_task_from_isr(int target_core)

View File

@ -637,7 +637,6 @@ TEST_CASE("Test xTaskResumeAll resumes pended tasks", "[freertos]")
vTaskDelay(10);
}
/* ---------------------------------------------------------------------------------------------------------------------
Test xTaskSuspendAll on both cores pends all tasks and xTaskResumeAll on both cores resumes all tasks
@ -790,7 +789,7 @@ void test_blocked_task(void *arg)
has_run = false;
// Got to blocked state
vTaskDelay( TEST_BLOCKED_TASK_DELAY_MS / portTICK_PERIOD_MS );
vTaskDelay(TEST_BLOCKED_TASK_DELAY_MS / portTICK_PERIOD_MS);
// Mark when this task runs
has_run = true;

View File

@ -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
*/
@ -16,7 +16,7 @@
static void timer_callback(TimerHandle_t timer)
{
volatile int *count;
count = (volatile int *)pvTimerGetTimerID( timer );
count = (volatile int *)pvTimerGetTimerID(timer);
(*count)++;
printf("Callback timer %p count %p = %d\n", timer, count, *count);
}
@ -30,7 +30,7 @@ TEST_CASE("Oneshot FreeRTOS timers", "[freertos]")
TEST_ASSERT_EQUAL(pdFALSE, xTimerIsTimerActive(oneshot));
TEST_ASSERT_EQUAL(0, count);
TEST_ASSERT( xTimerStart(oneshot, 1) );
TEST_ASSERT(xTimerStart(oneshot, 1));
vTaskDelay(2); /* give the timer task a chance to process the message */
TEST_ASSERT_EQUAL(pdTRUE, xTimerIsTimerActive(oneshot));
@ -41,20 +41,19 @@ TEST_CASE("Oneshot FreeRTOS timers", "[freertos]")
TEST_ASSERT_EQUAL(1, count);
TEST_ASSERT_EQUAL(pdFALSE, xTimerIsTimerActive(oneshot));
TEST_ASSERT( xTimerDelete(oneshot, 1) );
TEST_ASSERT(xTimerDelete(oneshot, 1));
}
TEST_CASE("Recurring FreeRTOS timers", "[freertos]")
{
volatile int count = 0;
TimerHandle_t recurring = xTimerCreate("oneshot", 100 / portTICK_PERIOD_MS, pdTRUE,
(void *)&count, timer_callback);
(void *)&count, timer_callback);
TEST_ASSERT(recurring);
TEST_ASSERT_EQUAL(pdFALSE, xTimerIsTimerActive(recurring));
TEST_ASSERT_EQUAL(0, count);
TEST_ASSERT( xTimerStart(recurring, 1) );
TEST_ASSERT(xTimerStart(recurring, 1));
vTaskDelay(2); // let timer task process the queue
TEST_ASSERT_EQUAL(pdTRUE, xTimerIsTimerActive(recurring));
@ -65,7 +64,7 @@ TEST_CASE("Recurring FreeRTOS timers", "[freertos]")
TEST_ASSERT_EQUAL(2, count);
TEST_ASSERT_EQUAL(pdTRUE, xTimerIsTimerActive(recurring));
TEST_ASSERT( xTimerStop(recurring, 1) );
TEST_ASSERT(xTimerStop(recurring, 1));
TEST_ASSERT_EQUAL(2, count);
@ -73,7 +72,7 @@ TEST_CASE("Recurring FreeRTOS timers", "[freertos]")
TEST_ASSERT_EQUAL(2, count); // hasn't gone up
TEST_ASSERT_EQUAL(pdFALSE, xTimerIsTimerActive(recurring));
TEST_ASSERT( xTimerDelete(recurring, 1) );
TEST_ASSERT(xTimerDelete(recurring, 1));
}
TEST_CASE("Static timer creation", "[freertos]")
@ -83,10 +82,10 @@ TEST_CASE("Static timer creation", "[freertos]")
volatile int count = 0;
created_timer = xTimerCreateStatic("oneshot", 100 / portTICK_PERIOD_MS,
pdTRUE,
(void *)&count,
timer_callback,
&static_timer);
pdTRUE,
(void *)&count,
timer_callback,
&static_timer);
TEST_ASSERT_NOT_NULL(created_timer);
}

View File

@ -202,7 +202,7 @@ static void IRAM_ATTR tick_hook(void)
static void suspend_task(void *arg)
{
TaskHandle_t main_task_hdl = ( TaskHandle_t )arg;
TaskHandle_t main_task_hdl = (TaskHandle_t)arg;
/* Fetch the current core ID */
BaseType_t xCoreID = portGET_CORE_ID();

View File

@ -42,8 +42,6 @@ static void tskTestRand(void *pvParameters)
vTaskDelete(NULL);
}
// TODO: split this thing into separate orthogonal tests
TEST_CASE("Test for per-task non-reentrant tasks", "[freertos]")
{

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -25,10 +25,11 @@ typedef struct {
TaskHandle_t t1_handle;
} test_context_t;
static void test_task_1(void *arg) {
static void test_task_1(void *arg)
{
test_context_t *context = (test_context_t *)arg;
for( ;; ) {
for (;;) {
context->before_sched = esp_cpu_get_cycle_count();
vPortYield();
}
@ -36,7 +37,8 @@ static void test_task_1(void *arg) {
vTaskDelete(NULL);
}
static void test_task_2(void *arg) {
static void test_task_2(void *arg)
{
test_context_t *context = (test_context_t *)arg;
uint64_t accumulator = 0;
@ -44,7 +46,7 @@ static void test_task_2(void *arg) {
vTaskPrioritySet(context->t1_handle, CONFIG_UNITY_FREERTOS_PRIORITY + 1);
vPortYield();
for(int i = 0; i < NUMBER_OF_ITERATIONS; i++) {
for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) {
accumulator += (esp_cpu_get_cycle_count() - context->before_sched);
vPortYield();
}
@ -63,14 +65,14 @@ TEST_CASE("scheduling time test", "[freertos]")
TEST_ASSERT(context.end_sema != NULL);
#if !CONFIG_FREERTOS_UNICORE
xTaskCreatePinnedToCore(test_task_1, "test1" , 4096, &context, 1, &context.t1_handle,1);
xTaskCreatePinnedToCore(test_task_2, "test2" , 4096, &context, 1, NULL,1);
xTaskCreatePinnedToCore(test_task_1, "test1", 4096, &context, 1, &context.t1_handle, 1);
xTaskCreatePinnedToCore(test_task_2, "test2", 4096, &context, 1, NULL, 1);
#else
xTaskCreatePinnedToCore(test_task_1, "test1" , 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, &context.t1_handle,0);
xTaskCreatePinnedToCore(test_task_2, "test2" , 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, NULL,0);
xTaskCreatePinnedToCore(test_task_1, "test1", 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, &context.t1_handle, 0);
xTaskCreatePinnedToCore(test_task_2, "test2", 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, NULL, 0);
#endif
BaseType_t result = xSemaphoreTake(context.end_sema, portMAX_DELAY);
TEST_ASSERT_EQUAL_HEX32(pdTRUE, result);
TEST_PERFORMANCE_LESS_THAN(SCHEDULING_TIME , "%"PRIu32" cycles" ,context.cycles_to_sched);
TEST_PERFORMANCE_LESS_THAN(SCHEDULING_TIME, "%"PRIu32" cycles", context.cycles_to_sched);
}

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -38,7 +38,8 @@ static uint32_t cycle_before_exit;
static uint32_t delta_enter_cycles = 0;
static uint32_t delta_exit_cycles = 0;
static void software_isr_using_parameter_vportyield(void *arg) {
static void software_isr_using_parameter_vportyield(void *arg)
{
(void)arg;
BaseType_t yield;
delta_enter_cycles += esp_cpu_get_cycle_count() - cycle_before_trigger;
@ -50,7 +51,8 @@ static void software_isr_using_parameter_vportyield(void *arg) {
cycle_before_exit = esp_cpu_get_cycle_count();
}
static void software_isr_using_no_argument_vportyield(void *arg) {
static void software_isr_using_no_argument_vportyield(void *arg)
{
(void)arg;
BaseType_t yield;
delta_enter_cycles += esp_cpu_get_cycle_count() - cycle_before_trigger;
@ -58,16 +60,17 @@ static void software_isr_using_no_argument_vportyield(void *arg) {
TEST_CLR_INT_MASK(1 << SW_ISR_LEVEL_1);
xSemaphoreGiveFromISR(sync, &yield);
if(yield) {
if (yield) {
portYIELD_FROM_ISR();
}
cycle_before_exit = esp_cpu_get_cycle_count();
}
static void test_task(void *arg) {
static void test_task(void *arg)
{
(void) arg;
for(int i = 0;i < 10000; i++) {
for (int i = 0; i < 10000; i++) {
cycle_before_trigger = esp_cpu_get_cycle_count();
TEST_SET_INT_MASK(1 << SW_ISR_LEVEL_1);
xSemaphoreTake(sync, portMAX_DELAY);
@ -91,12 +94,12 @@ TEST_CASE("isr latency test vport-yield-from-isr with no parameter", "[freertos]
TEST_ASSERT(sync != NULL);
end_sema = xSemaphoreCreateBinary();
TEST_ASSERT(end_sema != NULL);
xTaskCreatePinnedToCore(test_task, "tst" , 4096, NULL, configMAX_PRIORITIES - 1, NULL, 0);
xTaskCreatePinnedToCore(test_task, "tst", 4096, NULL, configMAX_PRIORITIES - 1, NULL, 0);
vTaskDelay(100);
BaseType_t result = xSemaphoreTake(end_sema, portMAX_DELAY);
TEST_ASSERT_EQUAL_HEX32(pdTRUE, result);
TEST_PERFORMANCE_LESS_THAN(ISR_ENTER_CYCLES, "%"PRIu32" cycles" ,delta_enter_cycles);
TEST_PERFORMANCE_LESS_THAN(ISR_EXIT_CYCLES, "%"PRIu32" cycles" ,delta_exit_cycles);
TEST_PERFORMANCE_LESS_THAN(ISR_ENTER_CYCLES, "%"PRIu32" cycles", delta_enter_cycles);
TEST_PERFORMANCE_LESS_THAN(ISR_EXIT_CYCLES, "%"PRIu32" cycles", delta_exit_cycles);
esp_intr_free(handle);
}
@ -111,11 +114,11 @@ TEST_CASE("isr latency test vport-yield-from-isr with parameter", "[freertos][ig
TEST_ASSERT(sync != NULL);
end_sema = xSemaphoreCreateBinary();
TEST_ASSERT(end_sema != NULL);
xTaskCreatePinnedToCore(test_task, "tst" , 4096, NULL, configMAX_PRIORITIES - 1, NULL, 0);
xTaskCreatePinnedToCore(test_task, "tst", 4096, NULL, configMAX_PRIORITIES - 1, NULL, 0);
BaseType_t result = xSemaphoreTake(end_sema, portMAX_DELAY);
TEST_ASSERT_EQUAL_HEX32(pdTRUE, result);
TEST_PERFORMANCE_LESS_THAN(ISR_ENTER_CYCLES, "%"PRIu32" cycles" ,delta_enter_cycles);
TEST_PERFORMANCE_LESS_THAN(ISR_EXIT_CYCLES, "%"PRIu32" cycles" ,delta_exit_cycles);
TEST_PERFORMANCE_LESS_THAN(ISR_ENTER_CYCLES, "%"PRIu32" cycles", delta_enter_cycles);
TEST_PERFORMANCE_LESS_THAN(ISR_EXIT_CYCLES, "%"PRIu32" cycles", delta_exit_cycles);
esp_intr_free(handle);
}

View File

@ -21,7 +21,6 @@
* when the recursive function returns.
*/
/* See test_context_save_clober_func.S */
extern void test_context_save_clober_func(void);

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -194,7 +194,6 @@ typedef struct {
TaskHandle_t main;
} ParamsFPU;
/**
* @brief Function performing some simple calculation using several FPU registers.
* The goal is to be preempted by a task that also uses the FPU on the same core.
@ -206,8 +205,7 @@ void fpu_calculation(void* arg)
const float init = negative ? -1.f : 1.f;
float f = init;
for(int i = 0; i < 10; i++)
{
for (int i = 0; i < 10; i++) {
/* The following calculation doesn't really have any meaning, we try to use several FPU registers and operations */
float delta = negative ? -1.1f : 1.1f;
for (int i = 0; i < 1000; i++) {
@ -222,7 +220,7 @@ void fpu_calculation(void* arg)
* It'll have the sign of the other tasks' `f` value.
* Use assert to make sure the sign is correct. Using TEST_ASSERT_TRUE triggers a stack overflow.
*/
assert( (negative && f < 0.0f) || (!negative && f > 0.0f) );
assert((negative && f < 0.0f) || (!negative && f > 0.0f));
f = init;
/* Give the hand back to FreeRTOS to avoid any watchdog */
@ -233,8 +231,6 @@ void fpu_calculation(void* arg)
vTaskDelete(NULL);
}
TEST_CASE("FPU: Unsolicited context switch between tasks using FPU", "[freertos]")
{
/* Create two tasks that are on the same core and use the same FPU */

View File

@ -41,7 +41,6 @@ static void other_task(void* arg)
vTaskDelete(NULL);
}
TEST_CASE("FPU: Context save does not affect stack watermark", "[freertos]")
{
TaskHandle_t pvCreatedTask;
@ -56,13 +55,13 @@ TEST_CASE("FPU: Context save does not affect stack watermark", "[freertos]")
/* Use the FPU unit, the context will NOT be flushed until another task starts using it */
add_floats(s_float, s_float);
xTaskCreatePinnedToCore( other_task,
"OtherTask",
2048,
(void*) current_handle,
CONFIG_UNITY_FREERTOS_PRIORITY - 1,
&pvCreatedTask,
core_id);
xTaskCreatePinnedToCore(other_task,
"OtherTask",
2048,
(void*) current_handle,
CONFIG_UNITY_FREERTOS_PRIORITY - 1,
&pvCreatedTask,
core_id);
vTaskDelay(10);

View File

@ -24,7 +24,6 @@
static volatile int in_int_context, int_handled;
static void testint(void)
{
esp_rom_printf("INT!\n");
@ -34,7 +33,6 @@ static void testint(void)
int_handled++;
}
static void testthread(void *arg)
{
in_int_context = 0;
@ -49,7 +47,6 @@ static void testthread(void *arg)
vTaskDelete(NULL);
}
TEST_CASE("xPortInIsrContext test", "[freertos]")
{
xTaskCreatePinnedToCore(testthread, "tst", 4096, NULL, 3, NULL, 0);
@ -60,5 +57,4 @@ TEST_CASE("xPortInIsrContext test", "[freertos]")
#endif
}
#endif

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -50,12 +50,12 @@ TEST_CASE("portMUX spinlocks (no contention)", "[freertos]")
BENCHMARK_END("no contention lock");
#ifdef CONFIG_FREERTOS_UNICORE
TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP_UNICORE, "%"PRIu32" cycles/op", ((end - start)/REPEAT_OPS));
TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP_UNICORE, "%"PRIu32" cycles/op", ((end - start) / REPEAT_OPS));
#else
#if CONFIG_SPIRAM
TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP_PSRAM, "%"PRIu32" cycles/op", ((end - start)/REPEAT_OPS));
TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP_PSRAM, "%"PRIu32" cycles/op", ((end - start) / REPEAT_OPS));
#else
TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP, "%"PRIu32" cycles/op", ((end - start)/REPEAT_OPS));
TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP, "%"PRIu32" cycles/op", ((end - start) / REPEAT_OPS));
#endif
#endif
}
@ -107,8 +107,8 @@ TEST_CASE("portMUX cross-core locking", "[freertos]")
xTaskCreatePinnedToCore(task_shared_value_increment, "INC0", 2048, NULL, UNITY_FREERTOS_PRIORITY + 1, NULL, UNITY_FREERTOS_CPU ? 0 : 1);
xTaskCreatePinnedToCore(task_shared_value_increment, "INC1", 2048, NULL, UNITY_FREERTOS_PRIORITY + 1, NULL, UNITY_FREERTOS_CPU);
for(int i = 0; i < 2; i++) {
if(!xSemaphoreTake(done_sem, 10000/portTICK_PERIOD_MS)) {
for (int i = 0; i < 2; i++) {
if (!xSemaphoreTake(done_sem, 10000 / portTICK_PERIOD_MS)) {
TEST_FAIL_MESSAGE("done_sem not released by test task");
}
}
@ -139,8 +139,8 @@ void portmux_high_contention_test(uint32_t lock_malloc_caps)
xTaskCreatePinnedToCore(task_shared_value_increment, "INC1", 2048, NULL, tskIDLE_PRIORITY + 1 + i, NULL, UNITY_FREERTOS_CPU);
}
for(int i = 0; i < TOTAL_TASKS; i++) {
if(!xSemaphoreTake(done_sem, 10000/portTICK_PERIOD_MS)) {
for (int i = 0; i < TOTAL_TASKS; i++) {
if (!xSemaphoreTake(done_sem, 10000 / portTICK_PERIOD_MS)) {
TEST_FAIL_MESSAGE("done_sem not released by test task");
}
}

View File

@ -25,7 +25,6 @@
#define GET_THREADPTR(tp_dest) do { register uint32_t _tp asm("tp"); tp_dest = _tp; } while(0)
#endif
static __thread int tl_test_var1;
static __thread uint8_t tl_test_var2 = 55;
static __thread uint16_t tl_test_var3 = 44;

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -55,28 +55,28 @@ TEST_CASE("LoadStore Exception handler", "[freertos]")
offset32 = offset8 / 4;
arr8[offset8] = val8_0;
arr8[offset8+1] = val8_1;
arr8[offset8+2] = val8_2;
arr8[offset8+3] = val8_3;
arr8[offset8 + 1] = val8_1;
arr8[offset8 + 2] = val8_2;
arr8[offset8 + 3] = val8_3;
// Just to make sure compiler doesn't read stale data
asm volatile("memw\n");
TEST_ASSERT_EQUAL(val8_0, arr8[offset8]);
TEST_ASSERT_EQUAL(val8_1, arr8[offset8+1]);
TEST_ASSERT_EQUAL(val8_2, arr8[offset8+2]);
TEST_ASSERT_EQUAL(val8_3, arr8[offset8+3]);
TEST_ASSERT_EQUAL(val8_1, arr8[offset8 + 1]);
TEST_ASSERT_EQUAL(val8_2, arr8[offset8 + 2]);
TEST_ASSERT_EQUAL(val8_3, arr8[offset8 + 3]);
arr16[offset16] = val16_0;
arr16[offset16+1] = val16_1;
arr16[offset16+2] = val16_2;
arr16[offset16+3] = val16_3;
arr16[offset16 + 1] = val16_1;
arr16[offset16 + 2] = val16_2;
arr16[offset16 + 3] = val16_3;
// Just to make sure compiler doesn't read stale data
asm volatile("memw\n");
TEST_ASSERT_EQUAL(val16_0, arr16[offset16]);
TEST_ASSERT_EQUAL(val16_1, arr16[offset16+1]);
TEST_ASSERT_EQUAL(val16_2, arr16[offset16+2]);
TEST_ASSERT_EQUAL(val16_3, arr16[offset16+3]);
TEST_ASSERT_EQUAL(val16_1, arr16[offset16 + 1]);
TEST_ASSERT_EQUAL(val16_2, arr16[offset16 + 2]);
TEST_ASSERT_EQUAL(val16_3, arr16[offset16 + 3]);
// LoadStoreAlignement Error
@ -112,7 +112,7 @@ TEST_CASE("LoadStore Exception handler", "[freertos]")
*ptr32_2 = val2;
// Just to make sure compiler doesn't read stale data
asm volatile ("memw");
asm volatile("memw");
TEST_ASSERT_EQUAL(0x73, *ptr8_0);
TEST_ASSERT_EQUAL(val0, *ptr32_0);
TEST_ASSERT_EQUAL(0x73, *ptr8_1);

View File

@ -38,7 +38,8 @@ components_not_formatted_temporary:
# To reformat the files:
# - Remove the directory from this exclude list
# - Run 'git add .astyle-rules.yml'
# - Run 'pre-commit run --all-files'
# - Run 'pre-commit run --all-files' to run all pre-commit hooks
# - Run 'pre-commit run astyle_py --all-files' to run only the astyle_py hook
# 2. If no, move it to 'components_not_formatted_permanent' section below.
check: false
include:
@ -74,7 +75,6 @@ components_not_formatted_temporary:
- "/components/espcoredump/"
- "/components/esptool_py/"
- "/components/fatfs/"
- "/components/freertos/"
- "/components/hal/"
- "/components/heap/"
- "/components/idf_test/"
@ -152,10 +152,13 @@ components_not_formatted_permanent:
- "/components/console/linenoise/"
# Catch (upstream source code)
- "/tools/catch/catch.hpp"
# FreeRTOS kernel files (upstream source code).
# FreeRTOS kernel files (upstream source code)
- "/components/freertos/FreeRTOS-Kernel/"
- "/components/freertos/FreeRTOS-Kernel-SMP/"
- "/components/freertos/FreeRTOS-Kernel-V10.5.1/"
# FreeRTOS additions to the upstream source code
- "/components/freertos/esp_additions/"
# FreeRTOS config files maintained in upstream format
- "/components/freertos/config/"
# Segger SystemView (upstream source code).
# Could also try to find suitable astyle options, instead.
- "/components/app_trace/sys_view/Config/"