-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial middleware + firmware code coverage workflow
- Instrumented firmware unit tests and tcpsigner tests to run with optional coverage - Added lcov to middleware docker image (used to also run firmware tests) - Added firmware code coverage generation script - TCPSigner now catches termination signals so that it can write gcda files when compiled with coverage - Code coverage github workflow is now a single one for both middleware and firmware
- Loading branch information
1 parent
e2f7f3c
commit 9bcea93
Showing
25 changed files
with
192 additions
and
82 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: "Code coverage" | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
coverage: | ||
name: Run tests and generate coverage reports | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Checkout this repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build the middleware docker image | ||
run: docker/mware/build | ||
|
||
- name: Run middleware coverage script | ||
run: middleware/test-all-coverage | ||
|
||
- name: "Upload middleware coverage report" | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: middleware_coverage_report | ||
path: middleware/coverage | ||
|
||
- name: Run firmware coverage script | ||
run: ledger/coverage/gen-coverage | ||
|
||
- name: "Upload firmware coverage report" | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: firmware_coverage_report | ||
path: ledger/coverage/output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
coverage.info | ||
output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ifeq ($(COVERAGE),y) | ||
COVFLAGS = --coverage | ||
else | ||
COVFLAGS = | ||
endif | ||
COVFILES = *.gcda *.gcno |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
if [[ $1 == "exec" ]]; then | ||
BASEDIR=$(realpath $(dirname $0)) | ||
SRCDIR=$(realpath $BASEDIR/../src) | ||
REPOROOT=$(realpath $BASEDIR/../..) | ||
|
||
# Remove any existing coverage data | ||
rm -rf $BASEDIR/coverage.info $BASEDIR/output | ||
find $REPOROOT/ledger -name "*.gcno" -o -name "*.gcda" | xargs rm -f | ||
|
||
# Run firmware unit tests with coverage generation | ||
COVERAGE=y $REPOROOT/ledger/src/signer/test/run-all.sh | ||
COVERAGE=y $REPOROOT/ledger/src/ui/test/run-all.sh | ||
|
||
# Run tcpsigner test suite | ||
pushd $REPOROOT/ledger/src/tcpsigner > /dev/null | ||
COVERAGE=y make clean all | ||
./tcpsigner --checkpoint 0xbdcb3c17c7aee714cec8ad900341bfd987b452280220dcbd6e7191f67ea4209b --difficulty 0x32 --network regtest > /dev/null & | ||
popd > /dev/null | ||
|
||
pushd $REPOROOT/ledger/test > /dev/null | ||
python run.py | ||
err_code=$? | ||
popd > /dev/null | ||
|
||
lcov --capture --directory $SRCDIR --list-full-path --output-file $BASEDIR/coverage.info | ||
genhtml $BASEDIR/coverage.info --output $BASEDIR/output -p $SRCDIR | ||
mv $BASEDIR/coverage.info $BASEDIR/output | ||
else | ||
# Script directory | ||
REPOROOT=$(realpath $(dirname $0)/../..) | ||
SCRIPT=$(realpath $0 --relative-to=$REPOROOT) | ||
|
||
# Generate coverage report | ||
$REPOROOT/docker/mware/do-notty-nousb /hsm2 "./$SCRIPT exec" | ||
err_code=$? | ||
fi | ||
|
||
exit $err_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,7 @@ tcpsigner/**/*.json | |
# Icons hex | ||
signer/icon.hex | ||
ui/icon.hex | ||
|
||
# Code coverage artifacts | ||
*.gcda | ||
*.gcno |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.