diff --git a/src/llvm-coverage-instrumentation.md b/src/llvm-coverage-instrumentation.md index c451c4f0a..5c730d9b3 100644 --- a/src/llvm-coverage-instrumentation.md +++ b/src/llvm-coverage-instrumentation.md @@ -274,13 +274,22 @@ since it will not be called), and adds a new `FunctionCoverage`, with ## Testing LLVM Coverage +[(See also the compiletest documentation for the `tests/coverage-map` and +`tests/run-coverage` test suites.)](./tests/compiletest.md#coverage-tests) + Coverage instrumentation in the MIR is validated by a `mir-opt` test: -[`instrument-coverage`][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. -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. +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