@@ -55,6 +55,7 @@ Further README contents
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
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
58
59
bin/geninfo - Internal tool (creates LCOV data files)
59
60
bin/genpng - Internal tool (creates png overviews of source files)
60
61
man - Directory containing man pages for included tools
@@ -180,45 +181,88 @@ Point the web browser of your choice to the resulting index.html file.
180
181
181
182
5. An example of how to access coverage data for a user space program
182
183
---------------------------------------------------------------------
183
- Requirements: compile the program in question using GCC with the options
184
- '-fprofile-arcs -ftest-coverage' or '--coverage'. During linking, make sure
185
- to specify '-lgcov' or '--coverage'.
186
184
187
- Assuming the compile directory is called "appdir", do the following :
185
+ a) Capture current coverage state to a file :
188
186
189
- a) Resetting counters
187
+ i) C/C++ code:
190
188
191
- lcov --directory appdir --zerocounters
189
+ Compile your program using the '--coverage' GCC or LLVM
190
+ option. During linking, make sure to specify '--coverage':
192
191
193
- 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 ....
194
196
195
- lcov --directory appdir --capture --output-file app.info
197
+ Run your testcase at least once:
196
198
197
- Note that this step only works after the application has
198
- been started and stopped at least once. Otherwise lcov will
199
- abort with an error mentioning that there are no data/.gcda files.
199
+ $ path/to/my/testcase/myTest
200
200
201
- The GCC runtime emits coverage data (the .gcda files) in an atexit
202
- callback. If your application exits abnormally or crashes before
203
- the callback is executed, then no coverage data will be available.
201
+ Capture the current coverage state to a file:
204
202
205
- c) Getting HTML output
203
+ $ lcov --directory path/to/my/testcase --capture -- output-file app.info
206
204
207
- 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 wil be found
207
+ and lcov will abort with an error mentioning that there are no data/.gcda
208
+ files.
208
209
209
- 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.
210
213
211
- See the example in .../example (run "make test_differential")
212
- as well as the examples in .../tests/gendiffcov .
214
+ For further information on the gcc profiling mechanism, please
215
+ consult the gcov man page .
213
216
214
- 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]
243
+
244
+ - translate Perl coverage data to LCOV format:
245
+
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.
215
261
216
- Please note that independently of where the application is installed or
217
- from which directory it is run, the --directory statement needs to
218
- point to the directory in which the application was compiled.
262
+ c) Generate a differential coverage report:
219
263
220
- For further information on the gcc profiling mechanism, please also
221
- consult the gcov man page .
264
+ See the example in .../example (run "make test_differential")
265
+ as well as the examples in .../tests/gendiffcov .
222
266
223
267
224
268
6. New features:
0 commit comments