From d2fd7540b19bf560640a4c6f59b045e92fba212f Mon Sep 17 00:00:00 2001 From: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Date: Wed, 22 May 2024 15:19:38 +0800 Subject: [PATCH] Update CI workflow for coverage and manifest check (#170) * Update CI workflow for coverage and manifest check * Update line and branch coverage min to 100% * Update github action version --- .github/workflows/ci.yml | 32 +++++++++------ manifest.yml | 9 +++++ test/unit-test/CMock | 2 +- test/unit-test/cellular_pkthandler_utest.c | 45 +++++++++++++++++++++- 4 files changed, 74 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index add6c89e..5876b0d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone This Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - env: stepName: Build Unit Tests run: | @@ -57,11 +57,13 @@ jobs: uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main with: coverage-file: ./build/coverage.info + branch-coverage-min: 100 + line-coverage-min: 100 complexity: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Check complexity - Common uses: FreeRTOS/CI-CD-Github-Actions/complexity@main with: @@ -70,7 +72,7 @@ jobs: doxygen: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run doxygen build uses: FreeRTOS/CI-CD-Github-Actions/doxygen@main with: @@ -80,7 +82,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone This Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run spellings check uses: FreeRTOS/CI-CD-Github-Actions/spellings@main with: @@ -89,7 +91,7 @@ jobs: formatting: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Check formatting uses: FreeRTOS/CI-CD-Github-Actions/formatting@main with: @@ -98,9 +100,9 @@ jobs: git-secrets: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout awslabs/git-secrets - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: awslabs/git-secrets ref: master @@ -115,11 +117,11 @@ jobs: memory_statistics: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" - name: Install Python3 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.11.0" - name: Measure sizes @@ -131,7 +133,7 @@ jobs: link-verifier: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Check Links env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -140,18 +142,24 @@ jobs: verify-manifest: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true fetch-depth: 0 + # At time of writing the gitmodules are set not to pull + # Even when using fetch submodules. Need to run this command + # To force it to grab them. + - name: Perform Recursive Clone + shell: bash + run: git submodule update --checkout --init --recursive + - name: Run manifest verifier uses: FreeRTOS/CI-CD-GitHub-Actions/manifest-verifier@main with: path: ./ fail-on-incorrect-version: true - proof_ci: if: ${{ github.event.pull_request }} runs-on: cbmc_ubuntu-latest_64-core diff --git a/manifest.yml b/manifest.yml index faedbf7e..36ce2bfa 100644 --- a/manifest.yml +++ b/manifest.yml @@ -3,3 +3,12 @@ version: "v1.3.0" description: | "FreeRTOS Cellular Interface implementation of the 3GPP TS v27.007 standard..\n" license: "MIT" + +dependencies: + - name: "CMock" + version: "v2.5.3" + license: "MIT" + repository: + type: "git" + url: "https://github.com/ThrowTheSwitch/CMock.git" + path: test/unit-test/CMock \ No newline at end of file diff --git a/test/unit-test/CMock b/test/unit-test/CMock index 3b443e55..9d092898 160000 --- a/test/unit-test/CMock +++ b/test/unit-test/CMock @@ -1 +1 @@ -Subproject commit 3b443e551d538e93e86ec7bb56a0d7fde3715a3c +Subproject commit 9d092898ef26ece140d9225e037274b64d4f851e diff --git a/test/unit-test/cellular_pkthandler_utest.c b/test/unit-test/cellular_pkthandler_utest.c index ba6c0693..6cb37d24 100644 --- a/test/unit-test/cellular_pkthandler_utest.c +++ b/test/unit-test/cellular_pkthandler_utest.c @@ -68,6 +68,7 @@ static int32_t pktRespCBReturn = 0; static bool passCompareString = false; static char * pCompareString = NULL; static int32_t undefinedCallbackContext = 0; +static uint32_t lastDelayTimeMs = 0U; void cellularAtParseTokenHandler( CellularContext_t * pContext, char * pInputStr ); @@ -181,6 +182,7 @@ void setUp() queueData = 0; queueReturnFail = 0; pktRespCBReturn = 0; + lastDelayTimeMs = 0U; } /* Called after each test method. */ @@ -203,7 +205,7 @@ int suiteTearDown( int numFailures ) void dummyDelay( uint32_t milliseconds ) { - ( void ) milliseconds; + lastDelayTimeMs = milliseconds; } void * mock_malloc( size_t size ) @@ -1116,6 +1118,47 @@ void test__Cellular_AtcmdDataSend_Happy_Path( void ) TEST_ASSERT_EQUAL( CELLULAR_PKT_STATUS_OK, pktStatus ); } +/** + * @brief Test that happy path case for _Cellular_AtcmdDataSend. + */ +void test__Cellular_AtcmdDataSend_data_send_delay( void ) +{ + CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; + char dataBuf[ CELLULAR_AT_CMD_TYPICAL_MAX_SIZE ] = { '\0' }; + uint32_t sentDataLength = 0; + CellularAtDataReq_t atDataReq = + { + ( const uint8_t * ) dataBuf, + CELLULAR_AT_CMD_TYPICAL_MAX_SIZE, + &sentDataLength, + NULL, + CELLULAR_AT_CMD_TYPICAL_MAX_SIZE + }; + + CellularAtReq_t atReq = + { + "AT+COPS?", + CELLULAR_AT_WITH_PREFIX, + "+COPS", + NULL, + NULL, + sizeof( int32_t ), + }; + CellularContext_t context; + + memset( &context, 0, sizeof( CellularContext_t ) ); + _Cellular_PktioSendAtCmd_IgnoreAndReturn( CELLULAR_PKT_STATUS_OK ); + + /* xQueueReceive true, and the data is CELLULAR_PKT_STATUS_OK. */ + _Cellular_PktioSendData_IgnoreAndReturn( CELLULAR_AT_CMD_TYPICAL_MAX_SIZE ); + queueData = CELLULAR_PKT_STATUS_OK; + + /* Send data with data send delay 100ms. */ + pktStatus = _Cellular_AtcmdDataSend( &context, atReq, atDataReq, NULL, NULL, 0, 0, 100U ); + TEST_ASSERT_EQUAL( 100U, lastDelayTimeMs ); + TEST_ASSERT_EQUAL( CELLULAR_PKT_STATUS_OK, pktStatus ); +} + /** * @brief Test that Test dataReq.pData or dataReq.pSentDataLength null case for _Cellular_AtcmdDataSend. */