summaryrefslogtreecommitdiffstats
path: root/docs/developer/build-run-debug/code_coverage.rst
blob: efe750cda21e31672387b77f55bca7940cd7e8b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
.. _lcov_code_coverage:

Code coverage with lcov
=======================

Prerequisites
-------------

Ensure required packages are installed:

::

    $ make install-deps

The Linux gcov and lcov tools can be fussy about gcc / g++ compiler
versions. As of this writing, Ubuntu 22.04 gcov / lcov works with
the latest gcc version (``11.3.0``).

Generate coverage for a test case
---------------------------------

As a first run, in order to generate the coverage report of
a specific plugin or test, run for example

::

    $ make test-cov TEST=fib

Then open the file ``.build-root/test-coverage/html/index.html`` in a Chrome browser.

Improving test coverage
-----------------------

When doing modifications on the test cases, you can run

::

    # This will run the test & report the result in the coverage data
    $ make test-cov-build TEST=fib

    # This will generate the html report with the current coverage data
    $ make test-cov-post

    # To reset the coverage data use
    $ make test-cov-prep