diff --git a/.github/workflows/modem__build-host-tests.yml b/.github/workflows/modem__build-host-tests.yml index 21204c6532..af14f19a28 100644 --- a/.github/workflows/modem__build-host-tests.yml +++ b/.github/workflows/modem__build-host-tests.yml @@ -76,10 +76,24 @@ jobs: if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push' uses: "./.github/workflows/run-host-tests.yml" with: - idf_version: "release-v4.3" + idf_version: "latest" app_name: "host_modem_test" app_path: "esp-protocols/components/esp_modem/test/host_test" component_path: "esp-protocols/components/esp_modem" upload_artifacts: true + run_coverage: true pre_run_script: "esp-protocols/components/esp_modem/test/host_test/env.sh" publish_unit_test_result: true + + host_test_linux_modem: + if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push' + uses: "./.github/workflows/run-host-tests.yml" + with: + idf_version: "latest" + app_name: "linux_modem" + app_path: "esp-protocols/components/esp_modem/examples/linux_modem" + component_path: "esp-protocols/components/esp_modem" + upload_artifacts: true + run_executable: false + run_coverage: false + pre_run_script: "esp-protocols/components/esp_modem/test/host_test/env.sh" diff --git a/.github/workflows/run-host-tests.yml b/.github/workflows/run-host-tests.yml index 467e076a9f..cb2c518acd 100644 --- a/.github/workflows/run-host-tests.yml +++ b/.github/workflows/run-host-tests.yml @@ -18,6 +18,12 @@ on: upload_artifacts: type: boolean required: true + run_executable: + type: boolean + required: false + run_coverage: + type: boolean + required: true pre_run_script: type: string required: false @@ -51,7 +57,14 @@ jobs: # The sdkconfig.ci.linux specifies Linux as the build target with apropriate settings. cp sdkconfig.ci.linux sdkconfig.defaults idf.py build - ./build/${{inputs.app_name}}.elf -r junit -o junit.xml + if [ "${{ inputs.run_executable}}" == "false" ]; then + exit 0 + fi + if [ "${{ inputs.publish_unit_test_result }}" == "true" ]; then + ./build/${{inputs.app_name}}.elf -r junit -o junit.xml + else + ./build/${{inputs.app_name}}.elf + fi - name: Publish Unit Test Result uses: EnricoMi/publish-unit-test-result-action@v2 if: ${{ inputs.publish_unit_test_result }} @@ -59,6 +72,7 @@ jobs: files: ${{inputs.component_path}}/**/*junit.xml - name: Build with Coverage Enabled shell: bash + if: ${{ inputs.run_coverage }} run: | component=$(basename ${{ inputs.component_path }}) if [ -f "${{ inputs.pre_run_script }}" ]; then @@ -74,6 +88,7 @@ jobs: ./build/${{inputs.app_name}}.elf - name: Run Coverage shell: bash + if: ${{ inputs.run_coverage }} run: | apt-get update && apt-get install -y python3-pip rsync python -m pip install gcovr @@ -86,6 +101,7 @@ jobs: cp index.html ${{inputs.app_name}}_coverage_report cp -rf ${{inputs.app_name}}_coverage_report ${{inputs.app_name}}_coverage.xml $GITHUB_WORKSPACE - name: Code Coverage Summary Report + if: ${{ inputs.run_coverage }} uses: irongut/CodeCoverageSummary@v1.3.0 with: filename: esp-protocols/**/${{inputs.app_name}}_coverage.xml @@ -99,9 +115,10 @@ jobs: thresholds: '60 80' - name: Write to Job Summary run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY + if: ${{ inputs.run_coverage }} - name: Upload files to artifacts for run-target job uses: actions/upload-artifact@v3 - if: ${{inputs.upload_artifacts}} + if: ${{ inputs.run_coverage }} with: name: ${{inputs.app_name}}_coverage_report path: | diff --git a/.github/workflows/websocket__build-host-tests.yml b/.github/workflows/websocket__build-host-tests.yml index f60c8ef133..40a53c19a9 100644 --- a/.github/workflows/websocket__build-host-tests.yml +++ b/.github/workflows/websocket__build-host-tests.yml @@ -18,3 +18,4 @@ jobs: app_path: "esp-protocols/components/esp_websocket_client/examples/linux" component_path: "esp-protocols/components/esp_websocket_client" upload_artifacts: true + run_coverage: true diff --git a/components/esp_modem/examples/linux_modem/CMakeLists.txt b/components/esp_modem/examples/linux_modem/CMakeLists.txt index dd08e1b21d..ff146c1ab7 100644 --- a/components/esp_modem/examples/linux_modem/CMakeLists.txt +++ b/components/esp_modem/examples/linux_modem/CMakeLists.txt @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(EXTRA_COMPONENT_DIRS ../../port/linux) +set(EXTRA_COMPONENT_DIRS ../../port/linux + "$ENV{IDF_PATH}/tools/mocks/freertos/") set(COMPONENTS main) project(linux_modem) diff --git a/components/esp_modem/test/host_test/CMakeLists.txt b/components/esp_modem/test/host_test/CMakeLists.txt index 8c603a21e5..adebbfab8a 100644 --- a/components/esp_modem/test/host_test/CMakeLists.txt +++ b/components/esp_modem/test/host_test/CMakeLists.txt @@ -4,9 +4,10 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(EXTRA_COMPONENT_DIRS # Add esp_modem component and linux port components ../.. - ../../port/linux) + ../../port/linux + "$ENV{IDF_PATH}/tools/mocks/freertos/") -set(COMPONENTS main) +set(COMPONENTS esp_modem main) project(host_modem_test) idf_component_get_property(esp_modem esp_modem COMPONENT_LIB) diff --git a/components/esp_modem/test/host_test/env.sh b/components/esp_modem/test/host_test/env.sh index 116e13be76..5b39af9228 100755 --- a/components/esp_modem/test/host_test/env.sh +++ b/components/esp_modem/test/host_test/env.sh @@ -3,19 +3,14 @@ idf_version=$1 component=$2 -if [[ "$idf_version" == "release-v4.3" ]] && [[ "$component" == "esp_modem" ]]; then - lwip=lwip-2.1.2 - lwip_uri=http://download.savannah.nongnu.org/releases/lwip - lwip_contrib=contrib-2.1.0 +lwip=lwip-2.1.2 +lwip_uri=http://download.savannah.nongnu.org/releases/lwip +lwip_contrib=contrib-2.1.0 - wget --no-verbose ${lwip_uri}/${lwip}.zip - unzip -oq ${lwip}.zip - wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip - unzip -oq ${lwip_contrib}.zip +wget --no-verbose ${lwip_uri}/${lwip}.zip +unzip -oq ${lwip}.zip +wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip +unzip -oq ${lwip_contrib}.zip - apt-get update && apt-get install -y gcc-8 g++-8 - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8 - rm /usr/bin/gcov && ln -s /usr/bin/gcov-8 /usr/bin/gcov - export LWIP_PATH=`pwd`/$lwip - export LWIP_CONTRIB_PATH=`pwd`/$lwip_contrib -fi +export LWIP_PATH=`pwd`/$lwip +export LWIP_CONTRIB_PATH=`pwd`/$lwip_contrib diff --git a/components/esp_modem/test/host_test/main/CMakeLists.txt b/components/esp_modem/test/host_test/main/CMakeLists.txt index 9b6d4ab57f..a1ee4557aa 100644 --- a/components/esp_modem/test/host_test/main/CMakeLists.txt +++ b/components/esp_modem/test/host_test/main/CMakeLists.txt @@ -1,11 +1,12 @@ idf_component_register(SRCS "test_modem.cpp" "LoopbackTerm.cpp" - INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch" - REQUIRES esp_modem) + REQUIRES esp_modem WHOLE_ARCHIVE) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) target_link_libraries(${COMPONENT_LIB} PRIVATE Threads::Threads) +target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain) + set_target_properties(${COMPONENT_LIB} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON diff --git a/components/esp_modem/test/host_test/main/idf_component.yml b/components/esp_modem/test/host_test/main/idf_component.yml new file mode 100644 index 0000000000..610cd15498 --- /dev/null +++ b/components/esp_modem/test/host_test/main/idf_component.yml @@ -0,0 +1,4 @@ +dependencies: + espressif/catch2: "^3.4.0" + idf: + version: ">=5.0" diff --git a/components/esp_modem/test/host_test/main/test_modem.cpp b/components/esp_modem/test/host_test/main/test_modem.cpp index d754839e68..235f3598aa 100644 --- a/components/esp_modem/test/host_test/main/test_modem.cpp +++ b/components/esp_modem/test/host_test/main/test_modem.cpp @@ -6,9 +6,10 @@ #define CATCH_CONFIG_MAIN // This tells the catch header to generate a main #include #include -#include "catch.hpp" +#include #include "cxx_include/esp_modem_api.hpp" #include "LoopbackTerm.h" +#include using namespace esp_modem;