From 7111cc1d21ea6e4b250779b55857b24c4cf06a5d Mon Sep 17 00:00:00 2001 From: Artie Poole Date: Fri, 27 Mar 2026 12:38:27 +0000 Subject: [PATCH 1/4] tests: coverage - fix llvm-cov deprecated --export-prefix solves [#164](https://github.com/canonical/fpgad/issues/164) Signed-off-by: Artie Poole --- tests/coverage_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/coverage_test.sh b/tests/coverage_test.sh index b8a23b60..f903a4be 100755 --- a/tests/coverage_test.sh +++ b/tests/coverage_test.sh @@ -15,7 +15,7 @@ set -xeu # Enable llvm-coverage build results -eval "$(cargo llvm-cov show-env --export-prefix)" +eval "$(cargo llvm-cov show-env --sh)" export RUSTFLAGS="$RUSTFLAGS -C llvm-args=-runtime-counter-relocation" From d0ce10a4b7a48816b457f90f745538b4102b02a7 Mon Sep 17 00:00:00 2001 From: Artie Poole Date: Fri, 27 Mar 2026 12:39:26 +0000 Subject: [PATCH 2/4] tests: workflows: fix binary test passing even if the script errored sets pipefail flag and catches sub-script return state disable -e only around coverage pipeline Signed-off-by: Artie Poole --- .../test_binary_device_script.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/testflinger-assets/test_binary_device_script.sh b/.github/testflinger-assets/test_binary_device_script.sh index ce19e986..54516f22 100755 --- a/.github/testflinger-assets/test_binary_device_script.sh +++ b/.github/testflinger-assets/test_binary_device_script.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -x +set -euxo pipefail echo "INFO: Installing dependencies" sudo env DEBIAN_FRONTEND=noninteractive apt update && sudo env DEBIAN_FRONTEND=noninteractive apt install build-essential -y @@ -18,5 +18,15 @@ cd fpgad mkdir -p artifacts sudo journalctl -f -n0 > artifacts/journal.log 2>&1 & JOURNAL_PID=$! + +# Temporarily disable -e to capture the test exit status even on failure +set +e ./tests/coverage_test.sh 2>&1 | tee artifacts/coverage_test.log -sudo kill ${JOURNAL_PID} || true +TEST_EXIT_STATUS=${PIPESTATUS[0]} +set -e + +# Cleanup regardless of test result +sudo kill ${JOURNAL_PID} || true + +# Exit with the test's exit status +exit $TEST_EXIT_STATUS From 5dcbd9590d0cf8a9a0acac12632a2dc18eaf8bba Mon Sep 17 00:00:00 2001 From: Artie Poole Date: Fri, 27 Mar 2026 14:07:45 +0000 Subject: [PATCH 3/4] tests: binary - the TF job did not catch the error from _run it seems Signed-off-by: Artie Poole --- .github/testflinger-assets/testflinger_job.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/testflinger-assets/testflinger_job.yaml b/.github/testflinger-assets/testflinger_job.yaml index 85a98029..e52b250b 100644 --- a/.github/testflinger-assets/testflinger_job.yaml +++ b/.github/testflinger-assets/testflinger_job.yaml @@ -34,6 +34,7 @@ test_data: - agent: device_script.sh local: ./device_script.sh test_cmds: | + set -e # get hw-cert-team helper tools echo "INFO: setting up scriptlets" export TOOLS_PATH=tools @@ -47,8 +48,16 @@ test_data: echo "INFO: Running script on DUT" _run 'chmod +x /home/ubuntu/device_script.sh' + + # Run the test script, but always retrieve artifacts even if it fails + set +e _run '/home/ubuntu/device_script.sh' + TEST_SCRIPT_EXIT=$? + set -e echo "INFO: Retrieving artifacts" mkdir -p artifacts _get fpgad/artifacts/* artifacts + + # Fail the job if the test script failed + exit $TEST_SCRIPT_EXIT From d2f512fb81f53bbddfbf2736cc365b33acb6e0f2 Mon Sep 17 00:00:00 2001 From: Artie Poole Date: Fri, 27 Mar 2026 15:20:45 +0000 Subject: [PATCH 4/4] tests: coverage-test default RUSTFLAGS to empty in export call Signed-off-by: Artie Poole --- tests/coverage_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/coverage_test.sh b/tests/coverage_test.sh index f903a4be..f1412a8b 100755 --- a/tests/coverage_test.sh +++ b/tests/coverage_test.sh @@ -17,7 +17,7 @@ set -xeu # Enable llvm-coverage build results eval "$(cargo llvm-cov show-env --sh)" -export RUSTFLAGS="$RUSTFLAGS -C llvm-args=-runtime-counter-relocation" +export RUSTFLAGS="${RUSTFLAGS:-} -C llvm-args=-runtime-counter-relocation" # build the daemon only, to avoid getting coverage for cli (no tests written) cargo build --bin daemon