mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-23 23:37:31 +02:00
CI: Added coverage analyzer for esp_modem host tests
This commit is contained in:
92
.github/workflows/gcov_analyzer.yml
vendored
Normal file
92
.github/workflows/gcov_analyzer.yml
vendored
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
name: Code Coverage Analyzer
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
gcovr_analyzer_esp_modem:
|
||||||
|
name: Run gcovr on esp modem host test
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
container: espressif/idf:release-v4.3
|
||||||
|
env:
|
||||||
|
lwip: lwip-2.1.2
|
||||||
|
lwip_contrib: contrib-2.1.0
|
||||||
|
lwip_uri: http://download.savannah.nongnu.org/releases/lwip
|
||||||
|
COMP_DIR: esp-protocols/components/esp_modem
|
||||||
|
steps:
|
||||||
|
- name: Checkout esp-protocols
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
path: esp-protocols
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Build and Test
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get update && apt-get install -y gcc-8 g++-8 python3-pip
|
||||||
|
apt-get install -y rsync
|
||||||
|
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
export LWIP_PATH=`pwd`/${{ env.lwip }}
|
||||||
|
export LWIP_CONTRIB_PATH=`pwd`/${{ env.lwip_contrib }}
|
||||||
|
. ${IDF_PATH}/export.sh
|
||||||
|
${{ env.COMP_DIR }}/test/host_test/env.sh $lwip $lwip_uri $lwip_contrib
|
||||||
|
cd $GITHUB_WORKSPACE/${{ env.COMP_DIR }}/test/host_test
|
||||||
|
cat sdkconfig.ci.coverage >> sdkconfig.defaults
|
||||||
|
idf.py build
|
||||||
|
./build/host_modem_test.elf
|
||||||
|
- name: Run gcovr
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python -m pip install gcovr
|
||||||
|
cd $GITHUB_WORKSPACE/${{ env.COMP_DIR }}
|
||||||
|
gcov-8 `find . -name "esp_modem*gcda" -printf '%h\n' | head -n 1`/*
|
||||||
|
gcovr --gcov-ignore-parse-errors -g -k -r . --html index.html -x esp_modem_coverage.xml
|
||||||
|
mkdir docs_gcovr
|
||||||
|
cp $GITHUB_WORKSPACE/${{ env.COMP_DIR }}/index.html docs_gcovr
|
||||||
|
touch docs_gcovr/.nojekyll
|
||||||
|
|
||||||
|
- name: Code Coverage Summary Report
|
||||||
|
uses: irongut/CodeCoverageSummary@v1.3.0
|
||||||
|
with:
|
||||||
|
filename: esp-protocols/**/esp_modem_coverage.xml
|
||||||
|
badge: true
|
||||||
|
fail_below_min: false
|
||||||
|
format: markdown
|
||||||
|
hide_branch_rate: false
|
||||||
|
hide_complexity: false
|
||||||
|
indicators: true
|
||||||
|
output: both
|
||||||
|
thresholds: '60 80'
|
||||||
|
|
||||||
|
- name: Write to Job Summary
|
||||||
|
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: docs_gcovr
|
||||||
|
path: |
|
||||||
|
${{ env.COMP_DIR }}/docs_gcovr
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
show_report_data:
|
||||||
|
name: Publish-Results
|
||||||
|
if: github.ref == 'refs/heads/master' || github.repository != 'espressif/esp-protocols'
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
needs: gcovr_analyzer_esp_modem
|
||||||
|
steps:
|
||||||
|
- name: Checkout 🛎️
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Download Artifacts
|
||||||
|
uses: actions/download-artifact@v1
|
||||||
|
with:
|
||||||
|
name: docs_gcovr
|
||||||
|
|
||||||
|
- name: Deploy generated docs
|
||||||
|
uses: JamesIves/github-pages-deploy-action@v4
|
||||||
|
with:
|
||||||
|
branch: gh-pages
|
||||||
|
folder: 'docs_gcovr'
|
5
.github/workflows/host-test.yml
vendored
5
.github/workflows/host-test.yml
vendored
@ -26,11 +26,8 @@ jobs:
|
|||||||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
|
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
|
||||||
export LWIP_PATH=`pwd`/${{ env.lwip }}
|
export LWIP_PATH=`pwd`/${{ env.lwip }}
|
||||||
export LWIP_CONTRIB_PATH=`pwd`/${{ env.lwip_contrib }}
|
export LWIP_CONTRIB_PATH=`pwd`/${{ env.lwip_contrib }}
|
||||||
wget --no-verbose ${lwip_uri}/${lwip}.zip
|
|
||||||
unzip -oq ${lwip}.zip
|
|
||||||
wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip
|
|
||||||
unzip -oq ${lwip_contrib}.zip
|
|
||||||
. ${IDF_PATH}/export.sh
|
. ${IDF_PATH}/export.sh
|
||||||
|
${{ GITHUB_WORKSPACE }}/${{ env.COMP_DIR }}/test/host_test/env.sh $lwip $lwip_uri $lwip_contrib
|
||||||
cd $GITHUB_WORKSPACE/esp-protocols/components/esp_modem/examples/linux_modem
|
cd $GITHUB_WORKSPACE/esp-protocols/components/esp_modem/examples/linux_modem
|
||||||
idf.py build
|
idf.py build
|
||||||
cd $GITHUB_WORKSPACE/esp-protocols/components/esp_modem/test/host_test
|
cd $GITHUB_WORKSPACE/esp-protocols/components/esp_modem/test/host_test
|
||||||
|
@ -47,3 +47,15 @@ if(${target} STREQUAL "linux")
|
|||||||
# This is needed for ESP_LOGx() macros, as integer formats differ on ESP32(..) and x64
|
# This is needed for ESP_LOGx() macros, as integer formats differ on ESP32(..) and x64
|
||||||
set_target_properties(${COMPONENT_LIB} PROPERTIES COMPILE_FLAGS -Wno-format)
|
set_target_properties(${COMPONENT_LIB} PROPERTIES COMPILE_FLAGS -Wno-format)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CONFIG_GCOV_ENABLED)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
|
||||||
|
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(
|
||||||
|
CMAKE_CXX_FLAGS_COVERAGE
|
||||||
|
CMAKE_C_FLAGS_COVERAGE
|
||||||
|
CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||||
|
CMAKE_SHARED_LINKER_FLAGS_COVERAGE )
|
||||||
|
endif()
|
||||||
|
@ -13,3 +13,15 @@ idf_component_get_property(esp_modem esp_modem COMPONENT_LIB)
|
|||||||
target_compile_definitions(${esp_modem} PRIVATE "-DCONFIG_COMPILER_CXX_EXCEPTIONS")
|
target_compile_definitions(${esp_modem} PRIVATE "-DCONFIG_COMPILER_CXX_EXCEPTIONS")
|
||||||
target_compile_definitions(${esp_modem} PRIVATE "-DCONFIG_IDF_TARGET_LINUX")
|
target_compile_definitions(${esp_modem} PRIVATE "-DCONFIG_IDF_TARGET_LINUX")
|
||||||
target_link_options(${esp_modem} INTERFACE -fsanitize=address -fsanitize=undefined)
|
target_link_options(${esp_modem} INTERFACE -fsanitize=address -fsanitize=undefined)
|
||||||
|
|
||||||
|
if(CONFIG_GCOV_ENABLED)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
|
||||||
|
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(
|
||||||
|
CMAKE_CXX_FLAGS_COVERAGE
|
||||||
|
CMAKE_C_FLAGS_COVERAGE
|
||||||
|
CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||||
|
CMAKE_SHARED_LINKER_FLAGS_COVERAGE )
|
||||||
|
endif()
|
||||||
|
10
components/esp_modem/test/host_test/env.sh
Executable file
10
components/esp_modem/test/host_test/env.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
lwip=$1
|
||||||
|
lwip_uri=$2
|
||||||
|
lwip_contrib=$3
|
||||||
|
|
||||||
|
wget --no-verbose ${lwip_uri}/${lwip}.zip
|
||||||
|
unzip -oq ${lwip}.zip
|
||||||
|
wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip
|
||||||
|
unzip -oq ${lwip_contrib}.zip
|
9
components/esp_modem/test/host_test/main/Kconfig
Normal file
9
components/esp_modem/test/host_test/main/Kconfig
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
menu "Host-test config"
|
||||||
|
|
||||||
|
config GCOV_ENABLED
|
||||||
|
bool "Coverage analyzer"
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Enables coverage analyzing for host tests.
|
||||||
|
|
||||||
|
endmenu
|
@ -0,0 +1 @@
|
|||||||
|
CONFIG_GCOV_ENABLED=y
|
Reference in New Issue
Block a user