From 755daad276d349496100fe542a6978e152f6964e Mon Sep 17 00:00:00 2001 From: Ravishankar Bhagavandas Date: Mon, 15 Mar 2021 18:01:42 -0700 Subject: [PATCH 1/2] Improve comments and assertions in stream buffer (#277) * Improve comments and assertions in stream buffer * Add back null check instead of assert * Adding config assert back --- stream_buffer.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stream_buffer.c b/stream_buffer.c index 5c6a47e2c..0c4f429ce 100644 --- a/stream_buffer.c +++ b/stream_buffer.c @@ -49,7 +49,7 @@ #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */ /* If the user has not provided application specific Rx notification macros, - * or #defined the notification macros away, them provide default implementations + * or #defined the notification macros away, then provide default implementations * that uses task notifications. */ /*lint -save -e9026 Function like macros allowed and needed here so they can be overridden. */ #ifndef sbRECEIVE_COMPLETED @@ -267,7 +267,6 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer, { pucAllocatedMemory = NULL; } - if( pucAllocatedMemory != NULL ) { @@ -466,7 +465,7 @@ BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, /* The trigger level is the number of bytes that must be in the stream * buffer before a task that is waiting for data is unblocked. */ - if( xTriggerLevel <= pxStreamBuffer->xLength ) + if( xTriggerLevel < pxStreamBuffer->xLength ) { pxStreamBuffer->xTriggerLevelBytes = xTriggerLevel; xReturn = pdPASS; @@ -525,14 +524,15 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, size_t xReturn, xSpace = 0; size_t xRequiredSpace = xDataLengthBytes; TimeOut_t xTimeOut; - - /* The maximum amount of space a stream buffer will ever report is its length - * minus 1. */ - const size_t xMaxReportedSpace = pxStreamBuffer->xLength - ( size_t ) 1; + size_t xMaxReportedSpace = 0; configASSERT( pvTxData ); configASSERT( pxStreamBuffer ); + /* The maximum amount of space a stream buffer will ever report is its length + * minus 1. */ + xMaxReportedSpace = pxStreamBuffer->xLength - ( size_t ) 1; + /* This send function is used to write to both message buffers and stream * buffers. If this is a message buffer then the space needed must be * increased by the amount of bytes needed to store the length of the From 95433d02848af0d274648ae4cdd846f6eff76dde Mon Sep 17 00:00:00 2001 From: Paul Bartell Date: Tue, 16 Mar 2021 18:31:37 -0700 Subject: [PATCH 2/2] Run CMock unit tests on each pull request with a github action. (#279) Run CMock unit tests on each pull request with a github action. Include coverage information reported by codecov.io --- .github/workflows/unit-tests.yml | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 000000000..7c4fa8ffb --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,56 @@ +name: CMock Unit Tests +on: [push] + +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Checkout Parent Repo + uses: actions/checkout@v2 + with: + ref: master + repository: FreeRTOS/FreeRTOS + submodules: 'recursive' + fetch-depth: 1 + - name: Clone This Repo + uses: actions/checkout@v2 + with: + path: ./FreeRTOS/Source + + - name: Setup Python + uses: actions/setup-python@master + with: + python-version: 3.8 + + - name: Install packages + run: | + sudo apt-get install lcov cflow ruby doxygen build-essential + - name: Run Unit Tests with ENABLE_SANITIZER=1 + run: | + make -C FreeRTOS/Test/CMock clean + make -C FreeRTOS/Test/CMock ENABLE_SANITIZER=1 run_col_formatted + - name: Run Unit Tests for coverage + run: | + make -C FreeRTOS/Test/CMock clean + make -C FreeRTOS/Test/CMock lcovhtml + lcov --config-file FreeRTOS/Test/CMock/lcovrc --summary FreeRTOS/Test/CMock/build/cmock_test.info > FreeRTOS/Test/CMock/build/cmock_test_summary.txt + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + files: FreeRTOS/Test/CMock/build/cmock_test.info + working-directory: . + root_dir: FreeRTOS/Source + flags: unittests + fail_ci_if_error: false + path_to_write_report: coverage/codecov_report.txt + verbose: false + - name: Archive code coverage data + uses: actions/upload-artifact@v2 + with: + name: coverage-data + path: FreeRTOS/Test/CMock/build/cmock_test* + - name: Archive code coverage html report + uses: actions/upload-artifact@v2 + with: + name: coverage-report + path: FreeRTOS/Test/CMock/build/coverage