Skip to content

Commit 51c9571

Browse files
fix[fuzz]: coverage report (#6375)
Signed-off-by: Joe Isaacs <[email protected]>
1 parent edb0c53 commit 51c9571

1 file changed

Lines changed: 30 additions & 12 deletions

File tree

‎.github/workflows/fuzz-coverage.yml‎

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,22 @@ jobs:
3030
with:
3131
repo-token: ${{ secrets.GITHUB_TOKEN }}
3232
toolchain: nightly
33+
components: clippy, rustfmt, llvm-tools
3334

34-
- name: Install llvm
35-
uses: aminya/setup-cpp@v1
36-
with:
37-
compiler: llvm
35+
- name: Ensure llvm-tools are installed
36+
run: |
37+
rustup component add llvm-tools --toolchain nightly || \
38+
rustup component add llvm-tools-preview --toolchain nightly
39+
40+
# Verify llvm-profdata is accessible (cargo-fuzz needs it for coverage merging)
41+
LLVM_PROFDATA="$(rustc +nightly --print sysroot)/lib/rustlib/$(rustc +nightly -vV | sed -n 's|host: ||p')/bin/llvm-profdata"
42+
if [ ! -f "$LLVM_PROFDATA" ]; then
43+
echo "ERROR: llvm-profdata not found at $LLVM_PROFDATA"
44+
echo "Listing bin directory:"
45+
ls -la "$(dirname "$LLVM_PROFDATA")" || echo "Directory does not exist"
46+
exit 1
47+
fi
48+
echo "Found llvm-profdata at $LLVM_PROFDATA"
3849
3950
- name: Install cargo fuzz
4051
run: cargo install --locked cargo-fuzz
@@ -62,33 +73,40 @@ jobs:
6273
run: |
6374
RUSTFLAGS="--cfg vortex_nightly" \
6475
cargo +nightly fuzz coverage --release --debug-assertions \
65-
${{ matrix.fuzz_target }}
76+
${{ matrix.fuzz_target }} \
77+
-- -rss_limit_mb=4096
6678
6779
- name: Generate coverage report
6880
run: |
6981
COVERAGE_DIR="fuzz/coverage/${{ matrix.fuzz_target }}"
7082
71-
llvm-profdata merge -sparse "$COVERAGE_DIR"/raw/*.profraw \
72-
-o "$COVERAGE_DIR/coverage.profdata"
83+
# llvm tools are installed via rustup's llvm-tools component
84+
LLVM_TOOLS_BIN="$(rustc +nightly --print sysroot)/lib/rustlib/$(rustc +nightly -vV | sed -n 's|host: ||p')/bin"
85+
86+
TARGET_TRIPLE=$(rustc +nightly -vV | sed -n 's|host: ||p')
7387
74-
FUZZ_BIN=$(find fuzz/target -name "${{ matrix.fuzz_target }}" -type f -executable -path "*/release/*" | grep -v deps | head -1)
88+
# cargo-fuzz coverage places the binary at:
89+
# target/<triple>/coverage/<triple>/release/<fuzz_target>
90+
FUZZ_BIN="target/${TARGET_TRIPLE}/coverage/${TARGET_TRIPLE}/release/${{ matrix.fuzz_target }}"
7591
76-
if [ -z "$FUZZ_BIN" ]; then
77-
echo "ERROR: Could not find fuzz binary for ${{ matrix.fuzz_target }}"
92+
if [ ! -f "$FUZZ_BIN" ]; then
93+
echo "ERROR: Could not find fuzz binary at $FUZZ_BIN"
94+
echo "Searching for binary in target directories..."
95+
find target -name "${{ matrix.fuzz_target }}" -type f 2>/dev/null || true
7896
exit 1
7997
fi
8098
8199
echo "Using fuzz binary: $FUZZ_BIN"
82100
83101
# HTML report for download
84-
llvm-cov show "$FUZZ_BIN" \
102+
"$LLVM_TOOLS_BIN/llvm-cov" show "$FUZZ_BIN" \
85103
--format=html \
86104
--instr-profile="$COVERAGE_DIR/coverage.profdata" \
87105
--ignore-filename-regex='(\.cargo|rustc|registry)' \
88106
--output-dir=coverage_html/
89107
90108
# Text summary to job log
91-
llvm-cov report "$FUZZ_BIN" \
109+
"$LLVM_TOOLS_BIN/llvm-cov" report "$FUZZ_BIN" \
92110
--instr-profile="$COVERAGE_DIR/coverage.profdata" \
93111
--ignore-filename-regex='(\.cargo|rustc|registry)'
94112

0 commit comments

Comments
 (0)