grpc/tools/fuzzing
Yijie Ma bd940c0dd5
[Fuzzing] Add a build config option which enables Clang source-based code coverage (#32858)
This maybe used to quickly verify the code coverage of a modified test
locally (e.g. fuzzer).

Example:
```
# Build and run target; the raw profile will be written to $LLVM_PROFILE_FILE when the program exits
$ bazel build --config=dbg --config=fuzzer_asan --config=coverage //test/core/end2end/fuzzers:api_fuzzer
$ LLVM_PROFILE_FILE="api_fuzzer.profraw" bazel-bin/test/core/end2end/fuzzers/api_fuzzer test/core/end2end/fuzzers/api_fuzzer_corpus/*

# Create coverage report
$ llvm-profdata-14 merge -sparse api_fuzzer.profraw -o api_fuzzer.profdata
$ llvm-cov-14 report ./bazel-bin/test/core/end2end/fuzzers/api_fuzzer --instr-profile=api_fuzzer.profdata
```

Sample report:
f94e444f25/gistfile1.txt

One trick is that the binary needs to be statically linked, e.g. specify
`linkstatic = 1` on the BUILD target.
See https://clang.llvm.org/docs/SourceBasedCodeCoverage.html for more
info.



<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->
2023-04-14 13:03:12 -07:00
..
generate_coverage_report.sh [Fuzzing] Add a build config option which enables Clang source-based code coverage (#32858) 2023-04-14 13:03:12 -07:00
sample_fuzzers.sh [fixit] Make the sampling fuzzer always pass for now (#30718) 2022-08-23 16:50:10 -07:00