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