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