Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate a coverage report for End to end tests #5667

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ on:
jobs:
test-simulator:
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:
- name: Install libs needed for native build
shell: bash
run: |
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 lcov

- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -24,7 +27,7 @@ jobs:
shell: bash
run: |
python -m pip install --upgrade pip
pip install -U platformio adafruit-nrfutil
pip install -U platformio adafruit-nrfutil dotmap
pip install -U meshtastic --pre

- name: Upgrade platformio
Expand All @@ -36,17 +39,25 @@ jobs:
run: bin/build-native.sh

# We now run integration test before other build steps (to quickly see runtime failures)
- name: Build for native
run: platformio run -e native
- name: Build for native/coverage
run: |
platformio run -e coverage
lcov ${{ env.LCOV_CAPTURE_FLAGS }} --initial --output-file coverage_base.info

- name: Integration test
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..."
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
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
uses: dorny/[email protected]
Expand All @@ -56,6 +67,19 @@ jobs:
path: testreport.xml
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:
runs-on: test-runner
steps:
Expand Down
2 changes: 1 addition & 1 deletion src/modules/AdminModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
#ifdef ARCH_PORTDUINO
case meshtastic_AdminMessage_exit_simulator_tag:
LOG_INFO("Exiting simulator");
_exit(0);
exit(0);
break;
#endif

Expand Down
6 changes: 2 additions & 4 deletions test/test_crypto/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ void setup()
RUN_TEST(test_DH25519);
RUN_TEST(test_AES_CTR);
RUN_TEST(test_PKC_Decrypt);
exit(UNITY_END()); // stop unit testing
}

void loop()
{
UNITY_END(); // stop unit testing
}
void loop() {}
4 changes: 4 additions & 0 deletions variants/portduino/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino
board = cross_platform
lib_deps = ${portduino_base.lib_deps}
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