blob: 3dab95102156e58f0c0312adda7d990ad77b2ea4 [file] [log] [blame]
Nathan Skrzypczaka2c95092021-10-08 14:05:58 +02001.. _lcov_code_coverage:
2
3Code coverage with lcov
4=======================
5
6Prerequisites
7-------------
8
9The Linux gcov and lcov tools are fussy about gcc / g++ compiler
10versions. As of this writing, Ubuntu 18.04 gcov / lcov work with these
11toolchain versions:
12
13$ gcc version gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0 $ g++ version
14g++ (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0
15
16Refer to
17https://askubuntu.com/questions/26498/how-to-choose-the-default-gcc-and-g-version
18for information on how to install multiple gcc / g++ versions, and
19switch between them.
20
21Youll need to install the following additional packages:
22
23$ sudo apt-get install gcovr ggcov lcov
24
25Compile an instrumented vpp image
26---------------------------------
27
28Two ways:
29
30$ cd $ make test-gcov $ ## interrupt compilation after building the
31image
32
33or $ cd /build-root $ make PLATFORM=vpp TAG=vpp_gcov vpp-install
34
35Initialize the lcov database
36----------------------------
37
38$ cd $ ./extras/lcov/lcov_prep $ make test-gcov or make TEST=my_test
39test-gcov $ # repeat or vary as desired to increase reported coverage $
40# Generate the report: $ ./extras/lcov/lcov_post
41
42You can run vpp manually, do anything you like. Results are cumulative
43until you re-run the prep script.
44
45Look at the results
46-------------------
47
48Point a browser at file:////build-root/html/index.html