Saturate and gate all llvm-cov coverage metrics

Require 100% region, function, instantiation, line, branch, and MC/DC
coverage in run-coverage.sh. Enable MC/DC instrumentation and rewrite the
two decisions that Clang could not instrument cleanly: the crossed-room
ternary, and the nested boolean under negation in crossedCompleteEndLeOne.
This commit is contained in:
andrew committed 2026-11-18 15:10:02 -05:00
1 parent f23d8a28d3
commit bf149c26b5
4 files changed
+46 -27

No files matched your search

+30 -13
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
# Build with Clang source-based coverage and require 100% line and branch
# coverage of the summarised implementation (`src/fast.cpp`). `sweep_test`
# deterministically enumerates a finite class of small readable instances and is
# sufficient on its own.
# Build with Clang source-based coverage and require 100% region, function,
# instantiation, line, branch, and MC/DC coverage of the summarised
# implementation (`src/fast.cpp`). `sweep_test` deterministically enumerates a
# finite class of small readable instances and is sufficient on its own.
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -72,7 +72,7 @@ cmake -S "$here" -B "$build" -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCR_BUILD_FUZZERS=OFF \
-DCR_BUILD_BENCH=OFF \
-DCMAKE_CXX_FLAGS="-fprofile-instr-generate -fcoverage-mapping" \
-DCMAKE_CXX_FLAGS="-fprofile-instr-generate -fcoverage-mapping -fcoverage-mcdc" \
-DCMAKE_EXE_LINKER_FLAGS="-fprofile-instr-generate"
cmake --build "$build" --target sweep_test
@@ -86,18 +86,35 @@ LLVM_PROFILE_FILE="$profdir/sweep-%p.profraw" "$build/sweep_test"
report() {
"$cov" report "$build/sweep_test" \
-instr-profile="$profdir/cov.profdata" src/fast.cpp
-instr-profile="$profdir/cov.profdata" \
--show-branch-summary \
--show-instantiation-summary \
--show-mcdc-summary \
--show-region-summary \
src/fast.cpp
}
output="$(report)"
printf '%s\n' "$output"
line_cover="$(printf '%s\n' "$output" | awk '/fast\.cpp/ { print $10 }')"
branch_cover="$(printf '%s\n' "$output" | awk '/fast\.cpp/ { print $13 }')"
if [[ "$line_cover" != "100.00%" ]]; then
echo "fast.cpp line coverage is $line_cover, expected 100.00%" >&2
# The row fields follow the summary order enabled above:
# region, function, instantiation, line, branch, and MC/DC coverage.
row="$(printf '%s\n' "$output" | awk '/fast\.cpp/ { print; exit }')"
if [[ -z "$row" ]]; then
echo "coverage report did not contain src/fast.cpp" >&2
exit 1
fi
if [[ "$branch_cover" != "100.00%" ]]; then
echo "fast.cpp branch coverage is $branch_cover, expected 100.00%" >&2
read -r -a fields <<< "$row"
metrics=(region function instantiation line branch MC/DC)
columns=(3 6 9 12 15 18)
failed=0
for i in "${!metrics[@]}"; do
cover="${fields[${columns[$i]}]}"
if [[ "$cover" != "100.00%" ]]; then
echo "fast.cpp ${metrics[$i]} coverage is ${cover:-missing}, expected 100.00%" >&2
failed=1
fi
done
if [[ "$failed" -ne 0 ]]; then
exit 1
fi
echo "fast.cpp: 100.00% line and branch coverage"
echo "fast.cpp: 100.00% region, function, instantiation, line, branch, and MC/DC coverage"