eBPF-based security platform
ci: reuse the VM build image for guest coverage
Andrea Lattuada2e517ec2335b
diff --git a/.github/scripts/coverage.sh b/.github/scripts/coverage.shindex fccadfee..92ea7268 100755--- a/.github/scripts/coverage.sh+++ b/.github/scripts/coverage.sh@@ -6,7 +6,7 @@# write coverage/shirudo.lcov from the counters of the host's binaries# and, where the test VMs ran, of the target in each guest.#-# .github/scripts/coverage.sh+# .github/scripts/coverage.sh [--sudo-container]set -eu@@ -77,14 +77,26 @@ if [ "${1:-}" = target ]; thenexit 0fi+sudo_container=${1:-}++capture_guest() {+ set -- testing/container/run.sh -v "$PWD/coverage" -- \+ "$PWD/.github/scripts/coverage.sh" target "$1"+ if [ "$sudo_container" = --sudo-container ]; then+ set -- sudo "$@"+ fi+ # Keep the tracefile owned by the caller even if the container runs as root.+ : >coverage/target.lcov+ "$@"+}+capture gcno --initial --output-file coverage/baseline.lcovcapture gcda --output-file coverage/run.lcovset -- --add-tracefile coverage/baseline.lcov --add-tracefile coverage/run.lcovfor bundle in build/test-vm/host-bundle-*; do[ -d "$bundle/coverage" ] || continue- testing/container/run.sh -v "$PWD/coverage" -- \- "$PWD/.github/scripts/coverage.sh" target "$PWD/$bundle"+ capture_guest "$PWD/$bundle"set -- "$@" --add-tracefile coverage/target.lcovbreakdonediff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.ymlindex 402a24b7..c3ac2669 100644--- a/.github/workflows/coverage.yml+++ b/.github/workflows/coverage.yml@@ -95,7 +95,7 @@ jobs:- name: Merge the counters of the host and the guestsid: collectif: ${{ !cancelled() && steps.setup.outcome == 'success' }}- run: .github/scripts/coverage.sh+ run: .github/scripts/coverage.sh --sudo-container- name: Upload coverage to Coverallsif: ${{ !cancelled() && steps.collect.outcome == 'success' }}diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rstindex c58dbcf9..f292bf61 100644--- a/Documentation/contribute/testing/testing.rst+++ b/Documentation/contribute/testing/testing.rst@@ -105,6 +105,9 @@ them in ``build/test-vm/coverage/``. :src:`.github/scripts/coverage.sh`reads them in the build container, whose gcov matches the compiler of thetarget, and merges them with the host's.+If the tests ran under ``sudo``, pass ``--sudo-container`` to+``coverage.sh`` to reuse root's build image for guest coverage.+The report leaves out test code, vendored code and BPF programs, and countsnothing for a process that is killed, as the loads that ``t6143`` and``t6144`` interrupt are, since gcov writes its counters at exit.