Skip to content

Commit aafa886

Browse files
Zalathartshepang
authored andcommitted
Revise the docs for coverage instrumentation tests
1 parent 2eb01f9 commit aafa886

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

Diff for: src/llvm-coverage-instrumentation.md

+21-11
Original file line numberDiff line numberDiff line change
@@ -274,32 +274,42 @@ since it will not be called), and adds a new `FunctionCoverage`, with
274274

275275
## Testing LLVM Coverage
276276

277+
[(See also the compiletest documentation for the `tests/coverage-map` and
278+
`tests/run-coverage` test suites.)](./tests/compiletest.md#coverage-tests)
279+
277280
Coverage instrumentation in the MIR is validated by a `mir-opt` test:
278-
[`instrument-coverage`][mir-opt-test].
281+
[`tests/mir-opt/instrument_coverage.rs`].
282+
283+
Coverage instrumentation in LLVM IR is validated by the [`tests/coverage-map`]
284+
test suite. These tests compile a test program to LLVM IR assembly, and then
285+
use the [`src/tools/coverage-dump`] tool to extract and pretty-print the
286+
coverage mappings that would be embedded in the final binary.
279287

280-
More complete testing of end-to-end coverage instrumentation and reports are
281-
done in the `run-make-fulldeps` tests, with sample Rust programs (to be
282-
instrumented) in the [`tests/run-coverage`] directory,
283-
together with the actual tests and expected results.
288+
End-to-end testing of coverage instrumentation and coverage reporting is
289+
performed by the [`tests/run-coverage`] and [`tests/run-coverage-rustdoc`]
290+
test suites. These tests compile and run a test program with coverage
291+
instrumentation, then use LLVM tools to convert the coverage data into a
292+
human-readable coverage report.
284293

285294
Finally, the [`coverage-llvmir`] test compiles a simple Rust program
286295
with `-C instrument-coverage` and compares the compiled program's LLVM IR to
287296
expected LLVM IR instructions and structured data for a coverage-enabled
288297
program, including various checks for Coverage Map-related metadata and the LLVM
289298
intrinsic calls to increment the runtime counters.
290299

291-
Expected results for both the `mir-opt` tests and the `coverage*` tests
292-
can be refreshed by running:
300+
Expected results for the `coverage-map`, `run-coverage`, `run-coverage-rustdoc`,
301+
and `mir-opt` tests can be refreshed by running:
293302

294303
```shell
304+
./x test tests/*coverage* --bless
295305
./x test tests/mir-opt --bless
296-
./x test tests/run-coverage --bless
297-
./x test tests/run-coverage-rustdoc --bless
298306
```
299307

300-
[mir-opt-test]: https://github.com/rust-lang/rust/blob/master/tests/mir-opt/instrument_coverage.rs
308+
[`tests/mir-opt/instrument_coverage.rs`]: https://github.com/rust-lang/rust/blob/master/tests/mir-opt/instrument_coverage.rs
309+
[`tests/coverage-map`]: https://github.com/rust-lang/rust/tree/master/tests/coverage-map
310+
[`src/tools/coverage-dump`]: https://github.com/rust-lang/rust/tree/master/src/tools/coverage-dump
301311
[`tests/run-coverage`]: https://github.com/rust-lang/rust/tree/master/tests/run-coverage
302-
[spanview-debugging]: compiler-debugging.md#viewing-spanview-output
312+
[`tests/run-coverage-rustdoc`]: https://github.com/rust-lang/rust/tree/master/tests/run-coverage-rustdoc
303313
[`coverage-llvmir`]: https://github.com/rust-lang/rust/tree/master/tests/run-make/coverage-llvmir
304314

305315
## Implementation Details of the `InstrumentCoverage` MIR Pass

0 commit comments

Comments
 (0)