forked from linux-test-project/lcov
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
340 lines (235 loc) · 12 KB
/
README
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
-------------------------------------------------
- README file for the LTP GCOV extension (LCOV) -
- Last changes: 2022-10-04
-------------------------------------------------
Description
-----------
LCOV is an extension of GCOV, a GNU tool which provides information about
what parts of a program are actually executed (i.e. "covered") while running
a particular test case. The extension consists of a set of Perl scripts
which build on the textual GCOV output to implement the following enhanced
functionality:
* HTML based output: coverage rates are additionally indicated using bar
graphs and specific colors.
* Support for large projects: overview pages allow quick browsing of
coverage data by providing a hierarchical directory structure
view, a flat list of all source files in the project, or a three-level detail view: directory, file and source code view.
LCOV was initially designed to support Linux kernel coverage measurements,
but works as well for coverage measurements on standard user space
applications.
LCOV has recently been enhanced to support differential coverage, as well
as date- and owner-binning. See https://arxiv.org/abs/2008.07947 or https://ieeexplore.ieee.org/document/9438597 for
a detailed explanation of the concepts and several possible use models.
A video presentation of the basic ideas can be found at http://doi.org/10.5281/zenodo.4653252
In addition, several other features and capabilities have been added. See section 5, below, for a brief description - and also see the man pages and the test cases.
Further README contents
-----------------------
1. Included files
2. Installing LCOV
3. Dependencies
4. An example of how to access kernel coverage data
5. An example of how to access coverage data for a user space program
6. New features (compared to lcov 1.16).
7. Questions and Comments
1. Important files
------------------
README - This README file
CHANGES - List of changes between releases
bin/lcov - Tool for capturing LCOV coverage data
bin/genhtml - Tool for creating HTML output from LCOV data
bin/gendesc - Tool for creating description files as used by genhtml
bin/geninfo - Internal tool (creates LCOV data files)
bin/genpng - Internal tool (creates png overviews of source files)
bin/install.sh - Internal tool (takes care of un-/installing)
man - Directory containing man pages for included tools
example - Directory containing an example to demonstrate LCOV
lcovrc - LCOV configuration file
Makefile - Makefile providing 'install' and 'uninstall' targets
2. Installing LCOV
------------------
The LCOV package is available as either RPM or tarball from:
https://github.com/linux-test-project/lcov/releases
To install the tarball, unpack it to a directory and run:
make install
Use Git for the most recent (but possibly unstable) version:
git clone https://github.com/linux-test-project/lcov.git
Change to the resulting lcov directory and type:
make install
The default install location is /usr/local. Note that you may need to
have superuser permissions to write into system directories.
To install in a different location - for example, your home directory, run:
make PREFIX=$HOME/my_lcov install
3. Dependencies:
----------------
The lcov module is implemented primarily in Perl - and requires both a
moderately up-to-date Perl installation and multiple Perl packages.
These perl packages include:
- Capture::Tiny
- DateTime
- DateTime::Format::W3CDTF
- Devel::Cover
- Digest::MD5
- File::Spec
- at least one flavor of JSON module.
In order of performance/preference:
- JSON::XS
- Cpanel::JSON::XS
- JSON::PP
- JSON
- Memory::Process
- Time::HiRes
If your system is missing any of these, then you may be able to install them
via:
$ perl -MCPAN -e 'install "packageName"'
You will very likely need superuser access to be able to install Perl
modules.
Some of the applications provided with the lcov module are written
in Python - and may require additional Python packages.
In particular, 'xlsxwriter' is required in order to generate any
of the spreadsheet reports.
To measure Python code coverage, users will need Python packages:
- Coverage.py
In addition, contributors will need:
- perltidy
Your platform may support other mechanisms to install and/or update
required packages.
4. An example of how to access Linux kernel coverage data
---------------------------------------------------------
Requirements: Follow the Linux kernel coverage setup instructions at:
https://docs.kernel.org/dev-tools/gcov.html
As root, do the following:
a) Resetting counters
lcov --zerocounters
b) Capturing the current coverage state to a file
lcov --capture --output-file kernel.info
c) Getting HTML output
genhtml kernel.info
Point the web browser of your choice to the resulting index.html file.
5. An example of how to access coverage data for a user space program
---------------------------------------------------------------------
Requirements: compile the program in question using GCC with the options
'-fprofile-arcs -ftest-coverage' or '--coverage'. During linking, make sure to specify
'-lgcov' or '--coverage'.
Assuming the compile directory is called "appdir", do the following:
a) Resetting counters
lcov --directory appdir --zerocounters
b) Capturing the current coverage state to a file
lcov --directory appdir --capture --output-file app.info
Note that this step only works after the application has
been started and stopped at least once. Otherwise lcov will
abort with an error mentioning that there are no data/.gcda files.
The GCC runtime emits coverage data (the .gcda files) in an atexit
callback. If your application exits abnormally or crashes before
the callback is executed, then no coverage data will be available.
c) Getting HTML output
genhtml app.info
d) Generating a differential coverage report
See the examples in .../tests/gendiffcov.
Point the web browser of your choice to the resulting index.html file.
Please note that independently of where the application is installed or
from which directory it is run, the --directory statement needs to
point to the directory in which the application was compiled.
For further information on the gcc profiling mechanism, please also
consult the gcov man page.
6. New features (compared to lcov 1.16):
----------------------------------------
New features and capabilities fall into 7 major categories:
a) Categorization
This refers primarily to differential coverage categorization as
well as date- and owner-binning. See https://arxiv.org/abs/2008.07947
or https://ieeexplore.ieee.org/document/9438597 for a detailed
description of the concepts.
Differential categorization and binning are orthogonal in the sense
that you can generate differential report without binning as well
as 'vanilla' coverage reports with binning. See the above papers
and the genhtml man page for details.
Related options:
--baseline-file, --diff-file, --annotate-script, --date-bins,
--new-file-as-baseline, --elide-path-mismtach
b) Error handling
A generic - but very simple - error handler has been added to the
lcov tool suite. The error handler is used to report exceptions,
and provides a mechanism for the user to ignore the particular
message if desired.
See the genhtml/lcov/geninfo man pages for details.
Note that some errors are unrecoverable - and cannot be suppressed or
ignored.
Related options: --ignore-error, --keep-going
c) Navigation and display:
Navigation aids such as hyperlinks to the first uncovered region,
to the next uncovered region, etc. have been implemented. Similarly,
new tables, new columns, and new links between tables enable the
user to identify the author of particular code (covered or not
covered), as well as the time period when the code was written.
Collectively, these features help the user to quickly identify the
cause of code coverage issues, and to then decide what to do.
An option to generate a 'hierarchical' coverage report (which follows
the source code directory structure) or 'flat' (all files in top level
of two-level report) as well as various other small features (tooltip
popups, user-specified HTML header, footer, and table labels, etc.) are
also available.
See the genhtml man page for some details, as well as the
'gendiffcov/simple' testcases for some examples.
Related options:
--baseline-title, --baseline-date, --current-date, --flat, --hierarchical,
--show-owners, --show-noncode, --show-navigation, --show-proportion,
--suppress-aliases
d) Data manipulation
Filters are used to suppress or remove certain coverage artifacts -
for example, branches generated by the compiler (e.g., for exception
handling). These artifacts can overwhelm the user code and obscure
coverage features that are interesting to the user.
Other options are used to focus on or to exclude certain sections
of code, as well as to do regexp replacement of file names - possibly
using case-insensitve comparison.
(Path munging is useful primarily when the build structure does
not exactly match the layout in your revision control system; this
is common in large projects with reusable components.)
See the lcov/geninfo/genhtml man pages for a detailed description of
the available filters and manipulation features.
Related options:
--include, --exclude, --erase-functions, --omit-lines,
--substitute, --filter
e) Callbacks/customization
The user can supply callbacks which are used to:
i) interface with the revision control system
Sample scripts:
- Perforce: see 'p4diff' and 'p4annotate'
- Git: see 'gitdiff' and 'gitblame'
ii) verify that source code versions are compatible, and
Sample scripts: see 'get_signature', 'getp4version'
iii) enforce a desired code coverage criteria
Sample script: criteria
See the genhtml/lcov/geninfo man pages for details.
Note that the various sample scripts are found in the source code 'bin'
directory, but are installed in the $LCOV_HOME/share/lcov/support-scripts
directory of the release.
Related options:
--annotate-script, --criteria-script, --version-script
f) Performance
lcov/genhtml/geninfo have been refactored to parallelize computation
across multiple cores, if requested.
In general, this provides speedup that is nearly linear in the number
of cores.
There is also an option to throttle parallelism to not exceed peak
memory consumption contraints, as well as options to enable simple
profile data collection - so you can see where time in going and
thus to hint at potential optimizations. The 'spreadsheet.py'
script can be used to view generated profile data..
See the genhtml/lcov/geninfo man pages for details
Related options: --parallel, --memory, --profile
g) Language support
Added 'py2lcov' script, which translates python Coverage.py XML data
to lcov format.
See the Coverage.py documentation at https://coverage.readthedocs.io,
as well as ".../py2lcov --help"
In general, the new features and options are implemented uniformly in lcov,
genhtml, and geninfo. Most of the features can be enabled/disabled
using either command line options or by setting defaults in your 'lcovrc'
file. See the lcovrc man page for details.
7. Questions and comments
-------------------------
See the included man pages for more information on how to use the LCOV tools.
In case of further questions, feel free to open a new issue using the issue
tracker on the LCOV code repository site at:
https://github.com/linux-test-project/lcov