cargo-fuzz
cargo-fuzz copied to clipboard
cargo-cov doesn't work
Command:
cargo cov -- show fuzz/target/<target triple>/release/my_compiler \
--format=html \
-instr-profile=fuzz/coverage/my_compiler/coverage.profdata \
> index.html
Error response:
error: no such subcommand: `cov`
Did you mean `c`?
I "solved" this by running llvm-cov manually, like so (also install rustfilt):
/Users/user/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/llvm-cov show fuzz/target/x86_64-apple-darwin/release/my_compiler \
--format=html \
-Xdemangler=rustfilt \
--ignore-filename-regex="\.cargo" \
-instr-profile=fuzz/coverage/my_compiler/coverage.profdata \
> index.html
Use the llvm-cov binary you made the coverage with.
hmm, that didn't work for me.
; llvm-cov show --instr-profile=/Users/jyn/src/inventory/fuzz/coverage/my_fuzz_target/coverage.profdata --format=html -Xdemangler=rustfilt /Users/jyn/.local/lib/cargo/target/aarch64-apple-darwin/release/my_fuzz_target
error: Failed to load coverage: '/Users/jyn/.local/lib/cargo/target/aarch64-apple-darwin/release/my_fuzz_target': No coverage data found
; file /Users/jyn/.local/lib/cargo/target/aarch64-apple-darwin/release/my_fuzz_target
/Users/jyn/.local/lib/cargo/target/aarch64-apple-darwin/release/my_fuzz_target: Mach-O 64-bit executable arm64
I was also getting the No coverage data found error, and it seems that the binary compiled with fuzzing instrumentation is at a different path from the main fuzzing binary now, but the documentation was never updated.
For me I had to change target/x86_64-unknown-linux-gnu/release/target_name to target/x86_64-unknown-linux-gnu/coverage/x86_64-unknown-linux-gnu/release/target_name (yes that includes the target triple twice) to make llvm-cov work, which makes sense when only the latter is compiled with coverage instrumentation.
I tried:
llvm-cov show target/x86_64-unknown-linux-gnu/release/fuzz_target_1 --format=html -Xdemangler=rustfilt -instr-profile=coverage/fuzz_target_1/coverage.profdata > index.html
And I get:
error: Failed to load coverage: 'coverage/fuzz_target_1/coverage.profdata': unsupported instrumentation profile format version