Skip to content

Commit

Permalink
Merge branch 'main' into fix-pico-ontarget-test
Browse files Browse the repository at this point in the history
  • Loading branch information
chinglee-iot authored Dec 11, 2023
2 parents a072718 + 0857bd7 commit ee9feb3
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 13 deletions.
2 changes: 1 addition & 1 deletion FreeRTOS/Source
Submodule Source updated 243 files
68 changes: 68 additions & 0 deletions FreeRTOS/Test/CMock/smp/config_assert/config_assert_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ extern volatile UBaseType_t uxTopReadyPriority;
extern List_t pxReadyTasksLists[ configMAX_PRIORITIES ];
extern volatile TickType_t xTickCount;
extern volatile TickType_t xNextTaskUnblockTime;
extern TaskHandle_t xIdleTaskHandles[ configNUMBER_OF_CORES ];

/* ========================== STATIC FUNCTIONS ========================== */
static void vFakeAssertStub( bool x,
Expand Down Expand Up @@ -669,3 +670,70 @@ void test_vTaskStepTick_assert_tick_to_jump_eq_0( void )
/* Test Verifications */
validate_and_clear_assertions();
}

/**
* @brief xTaskGetIdleTaskHandleForCore - assert if xCoreID is less than 0
*
* <b>Coverage</b>
* @code{c}
* configASSERT( taskVALID_CORE_ID( xCoreID ) == pdTRUE );
* @endcode
* taskVALID_CORE_ID( xCoreID ) is false with xCoreID less than 0.
*/
void test_xTaskGetIdleTaskHandleForCore_assert_invalid_core_id_lt( void )
{
/* API Call */
EXPECT_ASSERT_BREAK( xTaskGetIdleTaskHandleForCore( -1 ) );

/* Test Verifications */
validate_and_clear_assertions();
}

/**
* @brief xTaskGetIdleTaskHandleForCore - assert if xCoreID is greater or equal
* than configNUMBER_OF_CORES
*
* <b>Coverage</b>
* @code{c}
* configASSERT( taskVALID_CORE_ID( xCoreID ) == pdTRUE );
* @endcode
* taskVALID_CORE_ID( xCoreID ) is false with xCoreID greater or equal than configNUMBER_OF_CORES
*/
void test_xTaskGetIdleTaskHandleForCore_assert_invalid_core_id_ge( void )
{
/* API Call */
EXPECT_ASSERT_BREAK( xTaskGetIdleTaskHandleForCore( configNUMBER_OF_CORES ) );

/* Test Verifications */
validate_and_clear_assertions();
}

/**
* @brief xTaskGetIdleTaskHandleForCore - assert if idle task handle is NULL due to
* scheduler not started.
*
* <b>Coverage</b>
* @code{c}
* configASSERT( ( xIdleTaskHandles[ xCoreID ] != NULL ) );
* @endcode
* ( xIdleTaskHandles[ xCoreID ] != NULL ) is false.
*/
void test_xTaskGetIdleTaskHandleForCore_assert_null_idle_task_handle( void )
{
BaseType_t xCoreID;

/* Setup the variables and structure. */
for( xCoreID = 0; xCoreID < configNUMBER_OF_CORES; xCoreID++ )
{
xIdleTaskHandles[ xCoreID ] = NULL;
}

for( xCoreID = 0; xCoreID < configNUMBER_OF_CORES; xCoreID++ )
{
/* API Call */
EXPECT_ASSERT_BREAK( xTaskGetIdleTaskHandleForCore( xCoreID ) );

/* Test Verifications */
validate_and_clear_assertions();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,7 @@ void test_coverage_xTaskRemoveFromEventList_remove_eq_priority_task( void )
vFakePortGetCoreID_ExpectAndReturn( 0 ); /* Get prvYieldCore. */
vFakePortGetCoreID_ExpectAndReturn( 0 ); /* Get portGET_CRITICAL_NESTING_COUNT. */
vFakePortGetCoreID_ExpectAndReturn( 0 ); /* Get xYieldPendings. */
vFakePortGetCoreID_ExpectAndReturn( 0 ); /* portTASK_SWITCH_HOOK(). */

/* API call. */
xReturn = xTaskRemoveFromEventList( &xEventList );
Expand Down Expand Up @@ -4679,3 +4680,45 @@ void test_coverage_prvCreateIdleTasks_get_static_memory( void )
TEST_ASSERT_EQUAL( xIdleTaskHandles[ xCoreID ]->pxStack, &uxIdleTaskStacks[ xCoreID ][ 0 ] );
}
}

/**
* @brief xTaskGetIdleTaskHandleForCore - get the idle task handle by core
*
* Verify idle task handle returned is correct.
*
* <b>Coverage</b>
* @code{c}
* TaskHandle_t xTaskGetIdleTaskHandleForCore( BaseType_t xCoreID )
* {
* ...
* return xIdleTaskHandles[ xCoreID ];
* }
* @endcode
* The happy path test to return the idle task handles.
*/
void test_coverage_xTaskGetIdleTaskHandleForCore_success( void )
{
TCB_t xTaskTCBs[ configNUMBER_OF_CORES ] = { NULL };
TaskHandle_t xReturnedIdleTaskHandle;
BaseType_t xCoreID;

/* Setup the variables and structure. */
/* Create coreNUMBER_OF_CORES idle tasks. */
for( xCoreID = 0; xCoreID < configNUMBER_OF_CORES; xCoreID++ )
{
vCreateStaticTestTask( &xTaskTCBs[ xCoreID ],
tskIDLE_PRIORITY,
xCoreID,
pdTRUE );
xIdleTaskHandles[ xCoreID ] = &xTaskTCBs[ xCoreID ];
}

for( xCoreID = 0; xCoreID < configNUMBER_OF_CORES; xCoreID++ )
{
/* API call. */
xReturnedIdleTaskHandle = xTaskGetIdleTaskHandleForCore( xCoreID );

/* Validation. */
TEST_ASSERT_EQUAL( xIdleTaskHandles[ xCoreID ], xReturnedIdleTaskHandle );
}
}
33 changes: 24 additions & 9 deletions FreeRTOS/Test/CMock/tasks/tasks_freertos/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
*
*/

/*
* The purpose of this header file is to cover configASSERT. struct xSTATIC_TCB is
* updated to cause configASSERT. The rest of this file should be the same as FreeRTOS.h.
*/

#ifndef INC_FREERTOS_H
#define INC_FREERTOS_H

Expand Down Expand Up @@ -516,6 +521,10 @@
#define portSETUP_TCB( pxTCB ) ( void ) ( pxTCB )
#endif

#ifndef portTASK_SWITCH_HOOK
#define portTASK_SWITCH_HOOK( pxTCB ) ( void ) ( pxTCB )
#endif

#ifndef configQUEUE_REGISTRY_SIZE
#define configQUEUE_REGISTRY_SIZE 0U
#endif
Expand Down Expand Up @@ -1884,14 +1893,20 @@
#ifndef traceENTER_xTaskGetIdleTaskHandle
#define traceENTER_xTaskGetIdleTaskHandle()
#endif
#else
#ifndef traceENTER_xTaskGetIdleTaskHandle
#define traceENTER_xTaskGetIdleTaskHandle( xCoreID )
#endif

#if ( configNUMBER_OF_CORES == 1 )
#ifndef traceRETURN_xTaskGetIdleTaskHandle
#define traceRETURN_xTaskGetIdleTaskHandle( xIdleTaskHandle )
#endif
#endif

#ifndef traceRETURN_xTaskGetIdleTaskHandle
#define traceRETURN_xTaskGetIdleTaskHandle( xIdleTaskHandle )
#ifndef traceENTER_xTaskGetIdleTaskHandleForCore
#define traceENTER_xTaskGetIdleTaskHandleForCore( xCoreID )
#endif

#ifndef traceRETURN_xTaskGetIdleTaskHandleForCore
#define traceRETURN_xTaskGetIdleTaskHandleForCore( xIdleTaskHandle )
#endif

#ifndef traceENTER_vTaskStepTick
Expand Down Expand Up @@ -2118,12 +2133,12 @@
#define traceRETURN_xTaskGetCurrentTaskHandle( xReturn )
#endif

#ifndef traceENTER_xTaskGetCurrentTaskHandleCPU
#define traceENTER_xTaskGetCurrentTaskHandleCPU( xCoreID )
#ifndef traceENTER_xTaskGetCurrentTaskHandleForCore
#define traceENTER_xTaskGetCurrentTaskHandleForCore( xCoreID )
#endif

#ifndef traceRETURN_xTaskGetCurrentTaskHandleCPU
#define traceRETURN_xTaskGetCurrentTaskHandleCPU( xReturn )
#ifndef traceRETURN_xTaskGetCurrentTaskHandleForCore
#define traceRETURN_xTaskGetCurrentTaskHandleForCore( xReturn )
#endif

#ifndef traceENTER_xTaskGetSchedulerState
Expand Down
4 changes: 2 additions & 2 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license: "MIT"

dependencies:
- name: "FreeRTOS-Kernel"
version: "dc09a3dd5"
version: "bd0f87c18"
repository:
type: "git"
url: "https://github.com/FreeRTOS/FreeRTOS-Kernel.git"
Expand Down Expand Up @@ -131,7 +131,7 @@ dependencies:
path: "FreeRTOS-Plus/Source/Application-Protocols/coreSNTP"

- name: "FreeRTOS-Community-Supported-Demos"
version: "1ba24b1"
version: "db9704f"
repository:
type: "git"
url: "https://github.com/FreeRTOS/FreeRTOS-Community-Supported-Demos"
Expand Down

0 comments on commit ee9feb3

Please sign in to comment.