From a22b3e5a2d0a093436bdfd5f78813e239f8e476b Mon Sep 17 00:00:00 2001 From: rtel 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. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2533 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../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 0d50295b2..dd7a209c7 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 c4882f3f4..c2bd401d5 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 253db6839..3bed239d5 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 671508c9a..b73d97524 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 38e303521..96f02c452 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 e3a54e360..88191c5f8 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 -- 2.39.2