blob: efe750cda21e31672387b77f55bca7940cd7e8b9 [file] [log] [blame]
Dave Wallace1c95e122023-06-21 23:14:38 -04001.. _lcov_code_coverage:
2
3Code coverage with lcov
4=======================
5
6Prerequisites
7-------------
8
9Ensure required packages are installed:
10
11::
12
13 $ make install-deps
14
15The Linux gcov and lcov tools can be fussy about gcc / g++ compiler
16versions. As of this writing, Ubuntu 22.04 gcov / lcov works with
17the latest gcc version (``11.3.0``).
18
19Generate coverage for a test case
20---------------------------------
21
22As a first run, in order to generate the coverage report of
23a specific plugin or test, run for example
24
25::
26
27 $ make test-cov TEST=fib
28
29Then open the file ``.build-root/test-coverage/html/index.html`` in a Chrome browser.
30
31Improving test coverage
32-----------------------
33
34When 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