@@ -274,32 +274,42 @@ since it will not be called), and adds a new `FunctionCoverage`, with
274
274
275
275
## Testing LLVM Coverage
276
276
277
+ [ (See also the compiletest documentation for the ` tests/coverage-map ` and
278
+ ` tests/run-coverage ` test suites.)] ( ./tests/compiletest.md#coverage-tests )
279
+
277
280
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.
279
287
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.
284
293
285
294
Finally, the [ ` coverage-llvmir ` ] test compiles a simple Rust program
286
295
with ` -C instrument-coverage ` and compares the compiled program's LLVM IR to
287
296
expected LLVM IR instructions and structured data for a coverage-enabled
288
297
program, including various checks for Coverage Map-related metadata and the LLVM
289
298
intrinsic calls to increment the runtime counters.
290
299
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:
293
302
294
303
``` shell
304
+ ./x test tests/* coverage* --bless
295
305
./x test tests/mir-opt --bless
296
- ./x test tests/run-coverage --bless
297
- ./x test tests/run-coverage-rustdoc --bless
298
306
```
299
307
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
301
311
[ `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
303
313
[ `coverage-llvmir` ] : https://github.com/rust-lang/rust/tree/master/tests/run-make/coverage-llvmir
304
314
305
315
## Implementation Details of the ` InstrumentCoverage ` MIR Pass
0 commit comments