Revise the docs for coverage instrumentation tests

This commit is contained in:
Zalathar 2023-09-11 12:28:54 +10:00 committed by Tshepang Mbambo
parent f987fe8382
commit 5813662ef3
1 changed files with 22 additions and 12 deletions

View File

@ -274,13 +274,22 @@ since it will not be called), and adds a new `FunctionCoverage`, with
## Testing LLVM Coverage
Coverage instrumentation in the MIR is validated by a `mir-opt` test:
[`instrument-coverage`][mir-opt-test].
[(See also the compiletest documentation for the `tests/coverage-map` and
`tests/run-coverage` test suites.)](./tests/compiletest.md#coverage-tests)
More complete testing of end-to-end coverage instrumentation and reports are
done in the `run-make-fulldeps` tests, with sample Rust programs (to be
instrumented) in the [`tests/run-coverage`] directory,
together with the actual tests and expected results.
Coverage instrumentation in the MIR is validated by a `mir-opt` test:
[`tests/mir-opt/instrument_coverage.rs`].
Coverage instrumentation in LLVM IR is validated by the [`tests/coverage-map`]
test suite. These tests compile a test program to LLVM IR assembly, and then
use the [`src/tools/coverage-dump`] tool to extract and pretty-print the
coverage mappings that would be embedded in the final binary.
End-to-end testing of coverage instrumentation and coverage reporting is
performed by the [`tests/run-coverage`] and [`tests/run-coverage-rustdoc`]
test suites. These tests compile and run a test program with coverage
instrumentation, then use LLVM tools to convert the coverage data into a
human-readable coverage report.
Finally, the [`coverage-llvmir`] test compiles a simple Rust program
with `-C instrument-coverage` and compares the compiled program's LLVM IR to
@ -288,18 +297,19 @@ expected LLVM IR instructions and structured data for a coverage-enabled
program, including various checks for Coverage Map-related metadata and the LLVM
intrinsic calls to increment the runtime counters.
Expected results for both the `mir-opt` tests and the `coverage*` tests
can be refreshed by running:
Expected results for the `coverage-map`, `run-coverage`, `run-coverage-rustdoc`,
and `mir-opt` tests can be refreshed by running:
```shell
./x test tests/*coverage* --bless
./x test tests/mir-opt --bless
./x test tests/run-coverage --bless
./x test tests/run-coverage-rustdoc --bless
```
[mir-opt-test]: https://github.com/rust-lang/rust/blob/master/tests/mir-opt/instrument_coverage.rs
[`tests/mir-opt/instrument_coverage.rs`]: https://github.com/rust-lang/rust/blob/master/tests/mir-opt/instrument_coverage.rs
[`tests/coverage-map`]: https://github.com/rust-lang/rust/tree/master/tests/coverage-map
[`src/tools/coverage-dump`]: https://github.com/rust-lang/rust/tree/master/src/tools/coverage-dump
[`tests/run-coverage`]: https://github.com/rust-lang/rust/tree/master/tests/run-coverage
[spanview-debugging]: compiler-debugging.md#viewing-spanview-output
[`tests/run-coverage-rustdoc`]: https://github.com/rust-lang/rust/tree/master/tests/run-coverage-rustdoc
[`coverage-llvmir`]: https://github.com/rust-lang/rust/tree/master/tests/run-make/coverage-llvmir
## Implementation Details of the `InstrumentCoverage` MIR Pass