tests docs: fix lcov code coverage report generation
[vpp.git] / docs / developer / build-run-debug / code_coverage.rst
1 .. _lcov_code_coverage:
2
3 Code coverage with lcov
4 =======================
5
6 Prerequisites
7 -------------
8
9 Ensure required packages are installed:
10
11 ::
12
13     $ make install-deps
14
15 The Linux gcov and lcov tools can be fussy about gcc / g++ compiler
16 versions. As of this writing, Ubuntu 22.04 gcov / lcov works with
17 the latest gcc version (``11.3.0``).
18
19 Generate coverage for a test case
20 ---------------------------------
21
22 As a first run, in order to generate the coverage report of
23 a specific plugin or test, run for example
24
25 ::
26
27     $ make test-cov TEST=fib
28
29 Then open the file ``.build-root/test-coverage/html/index.html`` in a Chrome browser.
30
31 Improving test coverage
32 -----------------------
33
34 When doing modifications on the test cases, you can run
35
36 ::
37
38     # This will run the test & report the result in the coverage data
39     $ make test-cov-build TEST=fib
40
41     # This will generate the html report with the current coverage data
42     $ make test-cov-post
43
44     # To reset the coverage data use
45     $ make test-cov-prep