-
Notifications
You must be signed in to change notification settings - Fork 1
Coverage tests for prvAddNewTaskToReadyList, vTaskCoreAffinitySet. #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coverage tests for prvAddNewTaskToReadyList, vTaskCoreAffinitySet. #6
Conversation
It looks like the task_creation_covg has similar FreeRTOSConfig.h with multiple_priorities_no_timeslice. Suggest we use the same folder and put the test in covg_multiple_priorities_no_timeslice_utest.c. |
The test case naming is different from the test format guideline. Suggest we update the test case naming. |
FreeRTOS/Test/CMock/smp/task_creation_covg/task_creation_covg_utest.c
Outdated
Show resolved
Hide resolved
|
| xTickCount = 0U; | ||
| vTaskStepTick((TickType_t)10U); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these duplicated test cases?
Can you share your opinion about removing these test cases?
void test_coverage_xTaskResumeFromISR_resume_higher_priority_suspended_task( void )
void test_coverage_xTaskResumeFromISR_resume_lower_priority_suspended_task( void )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, those may be duplicate. In fact they were meant to cover this:
/* Ready lists can be accessed so move the task from the
* suspended list to the ready list directly. */
if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )
{
xYieldRequired = pdTRUE;
/* Mark that a yield is pending in case the user is not
* using the return value to initiate a context switch
* from the ISR using portYIELD_FROM_ISR. */
xYieldPendings[ 0 ] = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
However, the above is within an IFDEF and only applies to single core processing. So I think they are not actually covering the case I intended, and that case is already covered by other tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...est/CMock/smp/multiple_priorities_no_timeslice/covg_multiple_priorities_no_timeslice_utest.c
Show resolved
Hide resolved
| * | ||
| * <b>Coverage</b> | ||
| * @code{c} | ||
| * for( xCoreID = 0; xCoreID < configNUMBER_OF_CORES; xCoreID++ ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the test coverage report, this line doesn't seem to be covered by the test.
My suggestion is that we following the best practice in the document "FreeRTOS SMP coverage test format and guideline". The following implementation of this test case can be referenced.
Please also apply this comment in other test cases if they may be given the same suggestion.
/**
* @brief prvAddNewTaskToReadyList - add a new idle task to the list of ready tasks
*
* This test creates more tasks than ther are cores in order to test the
* branch related to the limit condition of the for loop.
*
* <b>Coverage</b>
* @code{c}
* for( xCoreID = 0; xCoreID < configNUMBER_OF_CORES; xCoreID++ )
* @endcode
* for loop condition ( xCoreID < configNUMBER_OF_CORES ) is false.
*/
void test_coverage_prvAddNewTaskToReadyList_create_more_idle_tasks_than_cores( void )
{
TCB_t xTaskTCBs[ configNUMBER_OF_CORES + 1 ] = { 0 };
uint32_t i;
/* Setup the variables and structure. */
/* Initialize the idle priority ready list and set top ready priority to idle priority. */
vListInitialise( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) );
uxTopReadyPriority = tskIDLE_PRIORITY;
uxCurrentNumberOfTasks = 0;
xSchedulerRunning = pdFALSE;
/* Create idle tasks and add it into the ready list. Create one more idle priority level
* in the loop. */
for( i = 0; i < ( configNUMBER_OF_CORES + 1U ); i++ )
{
xTaskTCBs[ i ].uxPriority = tskIDLE_PRIORITY;
xTaskTCBs[ i ].xStateListItem.pvOwner = &xTaskTCBs[ i ];
xTaskTCBs[ i ].uxCoreAffinityMask = ( ( 1U << configNUMBER_OF_CORES ) - 1U );
xTaskTCBs[ i ].uxTaskAttributes = -1;
if( i < configNUMBER_OF_CORES )
{
/* Create idle tasks with equal number of cores. */
pxCurrentTCBs[ i ] = &xTaskTCBs[ i ];
xTaskTCBs[ i ].xTaskRunState = i;
xTaskTCBs[ i ].xStateListItem.pxContainer = &pxReadyTasksLists[ tskIDLE_PRIORITY ];
listINSERT_END( &pxReadyTasksLists[ tskIDLE_PRIORITY ], &xTaskTCBs[ i ].xStateListItem );
uxCurrentNumberOfTasks = uxCurrentNumberOfTasks + 1;
}
else
{
/* Create one more idle task to be added to ready list. */
xTaskTCBs[ i ].xTaskRunState = -1; /* Set run state to taskTASK_NOT_RUNNING. */
}
}
/* API calls. */
prvAddNewTaskToReadyList( &xTaskTCBs[ configNUMBER_OF_CORES ] );
/* Validateions. The run state of this task is still taskNOT_RUNNING ( -1 ). */
configASSERT( xTaskTCBs[ configNUMBER_OF_CORES + 1U ].xTaskRunState == -1 );
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've included it, but commented out for now as the work to expose private/static functions and variables isn't yet merged or enabled for this subdirectory. Also, the priority to cover operationally unreachable code is I assume very low.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discuss in the meeting,
https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/570ade4001e50adbf06a074582ea993af562e0e1/tasks.c#L107
#ifdef portREMOVE_STATIC_QUALIFIER
#define static
#endif
These code already in kernel and the macro is defined in SMP test groups.
We should be able to access the private function and static variable in tasks.c file without problem.
The code snippet is for your referenced. If you want to use it to commit, at least we should be able to build without problem.
You can add the following extern to fix the compilation problem.
extern List_t pxReadyTasksLists[ configMAX_PRIORITIES ];
extern volatile UBaseType_t uxTopReadyPriority;
extern void prvAddNewTaskToReadyList( TCB_t * pxNewTCB );
the priority to cover operationally unreachable code is I assume very low.
I think you write this test case to cover this line.
If the priority is low, you can feedback in the slack channel and meeting.
We will discuss should we cover this line.
…out for now as the private functions are currently unlinkable.
Update single priority timeslice to sync with JAMA


Add coverage tests for the functions mentioned in the title.
Added new tests to the multiple_priorities_no_timeslice and created a new directory multiple_priorities_no_timeslice_tickless_idle with configUSE_TICKLESS_IDLE set to 1.
Test Steps
From the FreeRTOS/Test/CMock/smp subdirectory run 'make' against the default target followed by running 'make lcovhtml' to generate an HTML coverage report.
Related Issue
TS-24171, TS-24181
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.