@@ -54,6 +54,8 @@ Further README contents
54
54
bin/lcov - Tool for capturing LCOV coverage data
55
55
bin/genhtml - Tool for creating HTML output from LCOV data
56
56
bin/gendesc - Tool for creating description files as used by genhtml
57
+ bin/perl2lcov - Tool to translate Perl Devel::Cover data to lcov format
58
+ bin/py2lcov - Tool to translate Python Coverage.py to lcov format
57
59
bin/geninfo - Internal tool (creates LCOV data files)
58
60
bin/genpng - Internal tool (creates png overviews of source files)
59
61
man - Directory containing man pages for included tools
@@ -179,45 +181,88 @@ Point the web browser of your choice to the resulting index.html file.
179
181
180
182
5. An example of how to access coverage data for a user space program
181
183
---------------------------------------------------------------------
182
- Requirements: compile the program in question using GCC with the options
183
- '-fprofile-arcs -ftest-coverage' or '--coverage'. During linking, make sure
184
- to specify '-lgcov' or '--coverage'.
185
184
186
- Assuming the compile directory is called "appdir", do the following :
185
+ a) Capture current coverage state to a file :
187
186
188
- a) Resetting counters
187
+ i) C/C++ code:
189
188
190
- lcov --directory appdir --zerocounters
189
+ Compile your program using the '--coverage' GCC or LLVM
190
+ option. During linking, make sure to specify '--coverage':
191
191
192
- b) Capturing the current coverage state to a file
192
+ $ gcc -o myTest --coverage simple.c
193
+ OR
194
+ $ gcc -c file1.c file2.c ... --coverage
195
+ $ gcc -o myOtherTest --coverage file1.o file2.o ....
193
196
194
- lcov --directory appdir --capture --output-file app.info
197
+ Run your testcase at least once:
195
198
196
- Note that this step only works after the application has
197
- been started and stopped at least once. Otherwise lcov will
198
- abort with an error mentioning that there are no data/.gcda files.
199
+ $ path/to/my/testcase/myTest
199
200
200
- The GCC runtime emits coverage data (the .gcda files) in an atexit
201
- callback. If your application exits abnormally or crashes before
202
- the callback is executed, then no coverage data will be available.
201
+ Capture the current coverage state to a file:
203
202
204
- c) Getting HTML output
203
+ $ lcov --directory path/to/my/testcase --capture -- output-file app.info
205
204
206
- genhtml app.info
205
+ Note that runtime coverage data exists only after the application has
206
+ been started and stopped at least once. Otherwise, no data will be found
207
+ and lcov will abort with an error mentioning that there are no data/.gcda
208
+ files.
207
209
208
- d) Generating a differential coverage report
210
+ The coverage runtime emits data (the .gcda files) in an atexit
211
+ callback. If your application exits abnormally or crashes before
212
+ the callback is executed, then no coverage data will be available.
209
213
210
- See the example in .../example (run "make test_differential")
211
- as well as the examples in .../tests/gendiffcov .
214
+ For further information on the gcc profiling mechanism, please
215
+ consult the gcov man page .
212
216
213
- Point the web browser of your choice to the resulting index.html file.
217
+ See 'man lcov' for more information - especially if your build/test
218
+ environment is not trivial.
219
+
220
+ ii) Python code:
221
+
222
+ - install the Coverage.py module
223
+
224
+ - execute your testcase to produce python coverage data:
225
+
226
+ $ COVERAGE_FILE=./pycov.dat coverage run --append --branch \
227
+ myPythonScript [my script args]
228
+
229
+ - translate Python coverage data to LCOV format:
230
+
231
+ $ py2lcov -o pycov.info [py2lcov_options] pycov.dat [x.dat]+
232
+
233
+ See 'py2lcov --help' and the Coverage.py documentation for more
234
+ information.
235
+
236
+ iii) Perl code:
237
+
238
+ - install the Devel::Cover module
239
+
240
+ - execute your testcase to produce perl coverage data:
241
+
242
+ $ perl -MDevel::Cover=-db,perlcov_db,-coverage,statement,branch,condition,subroutine,-silent,1 myPerlTest.pl [my script args]
214
243
215
- Please note that independently of where the application is installed or
216
- from which directory it is run, the --directory statement needs to
217
- point to the directory in which the application was compiled.
244
+ - translate Perl coverage data to LCOV format:
218
245
219
- For further information on the gcc profiling mechanism, please also
220
- consult the gcov man page.
246
+ $ perl2lcov --output perlcov.info perlcov_db [perl2lcov options]
247
+
248
+ See 'perl2lcov --help' and the Devel::Cover documentation for more
249
+ information.
250
+
251
+ b) Generate an HTML coverage report:
252
+
253
+ Generate an HTML report, combining all of your LCOV data files:
254
+
255
+ $ genhtml -o html_report app.info pycov.info perlcov.info
256
+
257
+ Point the web browser of your choice to the resulting file:
258
+ html_report/index.html.
259
+
260
+ See 'man genhtml' for more details.
261
+
262
+ c) Generate a differential coverage report:
263
+
264
+ See the example in .../example (run "make test_differential")
265
+ as well as the examples in .../tests/gendiffcov.
221
266
222
267
223
268
6. New features:
@@ -238,8 +283,8 @@ New features and capabilities fall into 7 major categories:
238
283
and the genhtml man page for details.
239
284
240
285
Related options:
241
- --baseline-file, --diff-file, --annotate-script, --date-bins,
242
- --new-file-as-baseline, --elide-path-mismtach
286
+ --baseline-file, --diff-file, --annotate-script, --select-script
287
+ --date-bins, -- new-file-as-baseline, --elide-path-mismatch
243
288
244
289
b) Error handling
245
290
@@ -289,7 +334,7 @@ New features and capabilities fall into 7 major categories:
289
334
290
335
Other options are used to focus on or to exclude certain sections
291
336
of code, as well as to do regexp replacement of file names - possibly
292
- using case-insensitve comparison.
337
+ using case-insensitive comparison.
293
338
(Path munging is useful primarily when the build structure does
294
339
not exactly match the layout in your revision control system; this
295
340
is common in large projects with reusable components.)
@@ -323,6 +368,9 @@ New features and capabilities fall into 7 major categories:
323
368
Sample script: criteria
324
369
iv) find source files in more complicated environments - where
325
370
simple substitutions become complicated or unweildy.
371
+ v) select a subset of coverage data to display - e.g., to
372
+ use in a code review which wants to concentrate on only
373
+ the changes caused by a particular commit or range of commits.
326
374
327
375
The callback may be any desired script or executable - but there
328
376
may be performance advantages if it is written as a Perl module.
@@ -335,7 +383,7 @@ New features and capabilities fall into 7 major categories:
335
383
336
384
Related options:
337
385
--annotate-script, --criteria-script, --version-script
338
- --resolve-script
386
+ --resolve-script --select-script
339
387
340
388
f) Performance
341
389
@@ -344,7 +392,7 @@ New features and capabilities fall into 7 major categories:
344
392
In general, this provides speedup that is nearly linear in the number
345
393
of cores.
346
394
There is also an option to throttle parallelism to not exceed peak
347
- memory consumption contraints , as well as options to enable simple
395
+ memory consumption constraints , as well as options to enable simple
348
396
profile data collection - so you can see where time is going and
349
397
thus to hint at potential optimizations. The 'spreadsheet.py'
350
398
script can be used to view generated profile data.
@@ -360,11 +408,27 @@ New features and capabilities fall into 7 major categories:
360
408
361
409
g) Language support
362
410
363
- Added 'py2lcov' script, which translates python Coverage.py XML data
364
- to lcov format.
411
+ Added 'py2lcov' and 'perl2lcov' scripts.
412
+
413
+ - py2lcov:
414
+
415
+ translates python Coverage.py XML data to lcov format.
416
+
417
+ See the Coverage.py documentation at https://coverage.readthedocs.io,
418
+ as well as ".../py2lcov --help"
419
+
420
+ - perl2lcov
421
+
422
+ translates Perl Devel::Cover data to lcov format.
423
+
424
+ See the Devel::Cover documentation at
425
+ https://metacpan.org/pod/Devel::Cover
426
+ to find out how to generate coverage data for Perl code.
365
427
366
- See the Coverage.py documentation at https://coverage.readthedocs.io,
367
- as well as ".../py2lcov --help"
428
+ See "perl2lcov --help" for brief instructions on how to
429
+ use the translator.
430
+ Note that perl2lcov uses a similar set of command line and
431
+ config file options as lcov, genhtml, and geninfo.
368
432
369
433
Other languages can be integrated using a similar approach.
370
434
0 commit comments