mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-26 22:33:24 +00:00
Generate a coverage report for End to end tests (#5667)
* Generate coverage report after running tests * Wait for integration program to stop/start
This commit is contained in:
parent
835344074c
commit
1281da627e
34
.github/workflows/tests.yml
vendored
34
.github/workflows/tests.yml
vendored
@ -8,12 +8,15 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
test-simulator:
|
test-simulator:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
LCOV_CAPTURE_FLAGS: --quiet --capture --include "${PWD}/src/*" --exclude '*/src/mesh/generated/*' --directory .pio/build/coverage/src --base-directory "${PWD}"
|
||||||
steps:
|
steps:
|
||||||
- name: Install libs needed for native build
|
- name: Install libs needed for native build
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update --fix-missing
|
sudo apt-get update --fix-missing
|
||||||
sudo apt-get install -y libbluetooth-dev libgpiod-dev libyaml-cpp-dev openssl libssl-dev libulfius-dev liborcania-dev libusb-1.0-0-dev libi2c-dev
|
sudo apt-get install -y libbluetooth-dev libgpiod-dev libyaml-cpp-dev openssl libssl-dev libulfius-dev liborcania-dev libusb-1.0-0-dev libi2c-dev
|
||||||
|
sudo apt-get install -y lcov
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -24,7 +27,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -U platformio adafruit-nrfutil
|
pip install -U platformio adafruit-nrfutil dotmap
|
||||||
pip install -U meshtastic --pre
|
pip install -U meshtastic --pre
|
||||||
|
|
||||||
- name: Upgrade platformio
|
- name: Upgrade platformio
|
||||||
@ -36,17 +39,25 @@ jobs:
|
|||||||
run: bin/build-native.sh
|
run: bin/build-native.sh
|
||||||
|
|
||||||
# We now run integration test before other build steps (to quickly see runtime failures)
|
# We now run integration test before other build steps (to quickly see runtime failures)
|
||||||
- name: Build for native
|
- name: Build for native/coverage
|
||||||
run: platformio run -e native
|
run: |
|
||||||
|
platformio run -e coverage
|
||||||
|
lcov ${{ env.LCOV_CAPTURE_FLAGS }} --initial --output-file coverage_base.info
|
||||||
|
|
||||||
- name: Integration test
|
- name: Integration test
|
||||||
run: |
|
run: |
|
||||||
.pio/build/native/program & sleep 10 # 5 seconds was not enough
|
.pio/build/coverage/program &
|
||||||
|
PID=$!
|
||||||
|
timeout 20 bash -c "until ls -al /proc/$PID/fd | grep socket; do sleep 1; done"
|
||||||
echo "Simulator started, launching python test..."
|
echo "Simulator started, launching python test..."
|
||||||
python3 -c 'from meshtastic.test import testSimulator; testSimulator()'
|
python3 -c 'from meshtastic.test import testSimulator; testSimulator()'
|
||||||
|
wait
|
||||||
|
lcov ${{ env.LCOV_CAPTURE_FLAGS }} --test-name integration --output-file coverage_integration.info
|
||||||
|
|
||||||
- name: PlatformIO Tests
|
- name: PlatformIO Tests
|
||||||
run: platformio test -e native --junit-output-path testreport.xml
|
run: |
|
||||||
|
platformio test -e coverage --junit-output-path testreport.xml
|
||||||
|
lcov ${{ env.LCOV_CAPTURE_FLAGS }} --test-name tests --output-file coverage_tests.info
|
||||||
|
|
||||||
- name: Test Report
|
- name: Test Report
|
||||||
uses: dorny/test-reporter@v1.9.1
|
uses: dorny/test-reporter@v1.9.1
|
||||||
@ -56,6 +67,19 @@ jobs:
|
|||||||
path: testreport.xml
|
path: testreport.xml
|
||||||
reporter: java-junit
|
reporter: java-junit
|
||||||
|
|
||||||
|
- name: Generate Code Coverage Report
|
||||||
|
run: |
|
||||||
|
lcov --quiet --add-tracefile coverage_base.info --add-tracefile coverage_integration.info --add-tracefile coverage_tests.info --output-file coverage_src.info
|
||||||
|
mkdir code-coverage-report
|
||||||
|
genhtml --quiet --legend --prefix "${PWD}" coverage_src.info --output-directory code-coverage-report
|
||||||
|
mv coverage_*.info code-coverage-report
|
||||||
|
|
||||||
|
- name: Save Code Coverage Report
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: code-coverage-report
|
||||||
|
path: code-coverage-report
|
||||||
|
|
||||||
hardware-tests:
|
hardware-tests:
|
||||||
runs-on: test-runner
|
runs-on: test-runner
|
||||||
steps:
|
steps:
|
||||||
|
@ -358,7 +358,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
|||||||
#ifdef ARCH_PORTDUINO
|
#ifdef ARCH_PORTDUINO
|
||||||
case meshtastic_AdminMessage_exit_simulator_tag:
|
case meshtastic_AdminMessage_exit_simulator_tag:
|
||||||
LOG_INFO("Exiting simulator");
|
LOG_INFO("Exiting simulator");
|
||||||
_exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -176,9 +176,7 @@ void setup()
|
|||||||
RUN_TEST(test_DH25519);
|
RUN_TEST(test_DH25519);
|
||||||
RUN_TEST(test_AES_CTR);
|
RUN_TEST(test_AES_CTR);
|
||||||
RUN_TEST(test_PKC_Decrypt);
|
RUN_TEST(test_PKC_Decrypt);
|
||||||
|
exit(UNITY_END()); // stop unit testing
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop() {}
|
||||||
{
|
|
||||||
UNITY_END(); // stop unit testing
|
|
||||||
}
|
|
@ -9,3 +9,7 @@ build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino
|
|||||||
board = cross_platform
|
board = cross_platform
|
||||||
lib_deps = ${portduino_base.lib_deps}
|
lib_deps = ${portduino_base.lib_deps}
|
||||||
build_src_filter = ${portduino_base.build_src_filter}
|
build_src_filter = ${portduino_base.build_src_filter}
|
||||||
|
|
||||||
|
[env:coverage]
|
||||||
|
extends = env:native
|
||||||
|
build_flags = -lgcov --coverage -fprofile-abs-path ${env:native.build_flags}
|
||||||
|
Loading…
Reference in New Issue
Block a user