From bf8d9f4726e38defc3855919b1586a948cb38d53 Mon Sep 17 00:00:00 2001 From: Richard Barry Date: Tue, 6 Mar 2018 17:23:55 +0000 Subject: [PATCH] Start moving code coverage tests from VisualStudio (not checked in) to the MingW project (checked in) by creating a second build configuration in the Windows Eclipse project that includes the code coverage command line options. Additionally make minor code updates to ensure configASSERT() is not defined, and the application runs for a finite time, when the code coverage build configuration is used. --- .../Demo/Common/Minimal/MessageBufferAMP.c | 1 + FreeRTOS/Demo/WIN32-MingW/.cproject | 76 ++++++++++++++++++- .../org.eclipse.cdt.managedbuilder.core.prefs | 10 +++ FreeRTOS/Demo/WIN32-MingW/FreeRTOSConfig.h | 20 +++-- FreeRTOS/Demo/WIN32-MingW/main_full.c | 13 ++++ FreeRTOS/Source/list.c | 2 +- 6 files changed, 114 insertions(+), 8 deletions(-) diff --git a/FreeRTOS/Demo/Common/Minimal/MessageBufferAMP.c b/FreeRTOS/Demo/Common/Minimal/MessageBufferAMP.c index 0d50295b2b..dd7a209c79 100644 --- a/FreeRTOS/Demo/Common/Minimal/MessageBufferAMP.c +++ b/FreeRTOS/Demo/Common/Minimal/MessageBufferAMP.c @@ -230,6 +230,7 @@ char cReceivedString[ 15 ]; /* Check the number of bytes received was as expected. */ configASSERT( xReceivedBytes == strlen( cExpectedString ) ); + ( void ) xReceivedBytes; /* Incase configASSERT() is not defined. */ /* If the received string matches that expected then increment the loop counter so the check task knows this task is still running. */ diff --git a/FreeRTOS/Demo/WIN32-MingW/.cproject b/FreeRTOS/Demo/WIN32-MingW/.cproject index c4882f3f4e..c2bd401d5f 100644 --- a/FreeRTOS/Demo/WIN32-MingW/.cproject +++ b/FreeRTOS/Demo/WIN32-MingW/.cproject @@ -2,7 +2,7 @@ - + @@ -12,7 +12,7 @@ - + @@ -71,6 +71,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FreeRTOS/Demo/WIN32-MingW/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/FreeRTOS/Demo/WIN32-MingW/.settings/org.eclipse.cdt.managedbuilder.core.prefs index 253db6839e..3bed239d5f 100644 --- a/FreeRTOS/Demo/WIN32-MingW/.settings/org.eclipse.cdt.managedbuilder.core.prefs +++ b/FreeRTOS/Demo/WIN32-MingW/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -5,6 +5,12 @@ environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug. environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.1332190083/C_INCLUDE_PATH/operation=remove environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.1332190083/append=true environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.1332190083/appendContributed=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.539393069/CPATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.539393069/CPATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.539393069/C_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.539393069/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.539393069/append=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.539393069/appendContributed=true environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239/CPATH/delimiter=; environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239/CPATH/operation=remove environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239/C_INCLUDE_PATH/delimiter=; @@ -15,6 +21,10 @@ environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug. environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.1332190083/LIBRARY_PATH/operation=remove environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.1332190083/append=true environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.1332190083/appendContributed=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.539393069/LIBRARY_PATH/delimiter=; +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.539393069/LIBRARY_PATH/operation=remove +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.539393069/append=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239.539393069/appendContributed=true environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239/LIBRARY_PATH/delimiter=; environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239/LIBRARY_PATH/operation=remove environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.396692239/append=true diff --git a/FreeRTOS/Demo/WIN32-MingW/FreeRTOSConfig.h b/FreeRTOS/Demo/WIN32-MingW/FreeRTOSConfig.h index 671508c9a8..b73d975247 100644 --- a/FreeRTOS/Demo/WIN32-MingW/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/WIN32-MingW/FreeRTOSConfig.h @@ -109,17 +109,27 @@ functions anyway. */ #define INCLUDE_xTimerPendFunctionCall 1 #define INCLUDE_xTaskAbortDelay 1 -/* It is a good idea to define configASSERT() while developing. configASSERT() -uses the same semantics as the standard C assert() macro. */ -extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName ); -#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __LINE__, __FILE__ ) - #define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0 #if ( configINCLUDE_MESSAGE_BUFFER_AMP_DEMO == 1 ) extern void vGenerateCoreBInterrupt( void * xUpdatedMessageBuffer ); #define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreBInterrupt( pxStreamBuffer ) #endif /* configINCLUDE_MESSAGE_BUFFER_AMP_DEMO */ +extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName ); +#define configCOVERAGE_TEST 1 +#if( configCOVERAGE_TEST == 1 ) + /* Insert NOPs in empty decision paths to ensure both true and false paths + are being tested. */ + #define mtCOVERAGE_TEST_MARKER() __asm volatile( "NOP" ) +#else + /* It is a good idea to define configASSERT() while developing. configASSERT() + uses the same semantics as the standard C assert() macro. Don't define + configASSERT() when performing code coverage tests though, as it is not + intended to asserts() to fail, some some code is intended not to run if no + errors are present. */ + #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __LINE__, __FILE__ ) +#endif + /* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */ #include "trcRecorder.h" diff --git a/FreeRTOS/Demo/WIN32-MingW/main_full.c b/FreeRTOS/Demo/WIN32-MingW/main_full.c index 38e303521e..96f02c4522 100644 --- a/FreeRTOS/Demo/WIN32-MingW/main_full.c +++ b/FreeRTOS/Demo/WIN32-MingW/main_full.c @@ -445,6 +445,19 @@ void *pvAllocated; allocations so there is no need to test here. */ pvAllocated = pvPortMalloc( ( rand() % 500 ) + 1 ); vPortFree( pvAllocated ); + + /* Exit after a fixed time so code coverage results are written to the + disk. */ + #if( configCOVERAGE_TEST == 1 ) + { + const TickType_t xMaxRunTime = pdMS_TO_TICKS( 60000UL ); + + if( xTaskGetTickCount() >= xMaxRunTime ) + { + exit( 0 ); + } + } + #endif } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/list.c b/FreeRTOS/Source/list.c index e3a54e3609..88191c5f8c 100644 --- a/FreeRTOS/Source/list.c +++ b/FreeRTOS/Source/list.c @@ -114,7 +114,7 @@ const TickType_t xValueOfInsertion = pxNewListItem->xItemValue; /* Insert the new list item into the list, sorted in xItemValue order. If the list already contains a list item with the same item value then the - new list item should be placed after it. This ensures that TCB's which are + new list item should be placed after it. This ensures that TCBs which are stored in ready lists (all of which have the same xItemValue value) get a share of the CPU. However, if the xItemValue is the same as the back marker the iteration loop below will not end. Therefore the value is checked