Skip to content

Commit 5485ad0

Browse files
authored
Merge branch 'linux-test-project:master' into master
2 parents 97c717e + d981242 commit 5485ad0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3403
-839
lines changed

CONTRIBUTING

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ may also work, but some older versions are known not to.
8282

8383
Please execute
8484
make checkstyle MODE=full UPDATE=true
85-
on your code and verify correctness of the reformating (if any) before
85+
on your code and verify correctness of the reformatting (if any) before
8686
submitting a pull request.
8787

8888
Testing:
@@ -124,7 +124,7 @@ makes you think of a small project that you want to tackle: excellent.)
124124
Pull requests which add tests for existing features or which enhance
125125
existing tests are actively encouraged.
126126
The lcov maintainers are painfully aware that the code coverage of the
127-
lcov test suite on the lcov code base is embarassingly low.
127+
lcov test suite on the lcov code base is embarrassingly low.
128128

129129
Note that existing tests and/or test drivers may themselves need to be
130130
modified in order to work correctly on other platforms and with other
@@ -162,4 +162,4 @@ With your Signed-off-by, you certify the rules stated in section
162162

163163
[1] https://github.com/linux-test-project/lcov
164164
[2] https://gcc.gnu.org
165-
[3] https://metacpan.org/dist/Perl-Tidy/view/bin/perltidy
165+
[3] https://metacpan.org/dist/Perl-Tidy/view/bin/perltidy

Makefile

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
# --parallel n - use --parallel flag
2525
# --home path - path to lcov script
2626
# --llvm - use LLVM rather than gcc
27-
# --keep-going - don't stop on error
27+
# --keep-going - don't stop on error
28+
# --verbose - echo commands to test.log
2829
# Note that not all tests have been updated to use
2930
# all flags
3031

@@ -62,12 +63,12 @@ TMP_DIR := $(shell mktemp -d)
6263
FILES := $(wildcard bin/*) $(wildcard man/*) README Makefile \
6364
$(wildcard rpm/*) lcovrc
6465

65-
EXES = lcov genhtml geninfo genpng gendesc
66+
EXES = lcov genhtml geninfo genpng gendesc perl2lcov py2lcov
6667
# there may be both public and non-public user scripts - so lets not show
6768
# any of their names
6869
SCRIPTS = $(shell ls scripts | grep -v -E '([\#\~]|\.orig|\.bak|\.BAK)' )
6970
LIBS = lcovutil.pm
70-
# similarly, lets not talk about man pages
71+
# similarly, lets not talk about man pages
7172
MANPAGES = $(foreach m, $(shell cd man ; ls *.1), man1/$(m)) \
7273
$(foreach m, $(shell cd man ; ls *.5), man5/$(m))
7374

@@ -98,7 +99,7 @@ info:
9899
@echo " check : perform self-tests"
99100
@echo " checkstyle: check source files for coding style issues"
100101
@echo " release : finalize release and create git tag for specified VERSION"
101-
@echo " test : same as 'make check"
102+
@echo " test : same as 'make check'"
102103

103104
clean:
104105
$(call echocmd," CLEAN lcov")
@@ -235,15 +236,17 @@ rpms: lcov-$(VERSION).tar.gz
235236

236237
ifeq ($(COVERAGE), 1)
237238
# write to .../tests/cover_db
238-
export COVER_DB := ./cover_db
239+
export COVER_DB := $(shell echo `pwd`/tests/cover_db)
240+
export PYCOV_DB := $(shell echo `pwd`/tests/pycov.dat)
241+
export HTML_RPT := ./lcov_coverage
239242
endif
240243
export TESTCASE_ARGS
241244

242245
test: check
243246

244247
check:
245-
if [ "x$(COVERAGE)" != 'x' ] && [ ! -d tests/$(COVER_DB) ]; then \
246-
mkdir tests/$(COVER_DB) ; \
248+
if [ "x$(COVERAGE)" != 'x' ] && [ ! -d $(COVER_DB) ]; then \
249+
mkdir $(COVER_DB) ; \
247250
fi
248251
@$(MAKE) -s -C tests check LCOV_HOME=`pwd`
249252
@if [ "x$(COVERAGE)" != 'x' ] ; then \
@@ -278,7 +281,7 @@ endif
278281

279282
release:
280283
@if [ "$(origin VERSION)" != "command line" ] ; then echo "Please specify new version number, e.g. VERSION=1.16" >&2 ; exit 1 ; fi
281-
@if [ -n "$$(git status --porcelain 2>&1)" ] ; then echo "The repository contains uncommited changes" >&2 ; exit 1 ; fi
284+
@if [ -n "$$(git status --porcelain 2>&1)" ] ; then echo "The repository contains uncommitted changes" >&2 ; exit 1 ; fi
282285
@if [ -n "$$(git tag -l v$(VERSION))" ] ; then echo "A tag for the specified version already exists (v$(VERSION))" >&2 ; exit 1 ; fi
283286
@echo "Preparing release tag for version $(VERSION)"
284287
git checkout master

README

Lines changed: 98 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ Further README contents
5454
bin/lcov - Tool for capturing LCOV coverage data
5555
bin/genhtml - Tool for creating HTML output from LCOV data
5656
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
5759
bin/geninfo - Internal tool (creates LCOV data files)
5860
bin/genpng - Internal tool (creates png overviews of source files)
5961
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.
179181

180182
5. An example of how to access coverage data for a user space program
181183
---------------------------------------------------------------------
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'.
185184

186-
Assuming the compile directory is called "appdir", do the following:
185+
a) Capture current coverage state to a file:
187186

188-
a) Resetting counters
187+
i) C/C++ code:
189188

190-
lcov --directory appdir --zerocounters
189+
Compile your program using the '--coverage' GCC or LLVM
190+
option. During linking, make sure to specify '--coverage':
191191

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 ....
193196

194-
lcov --directory appdir --capture --output-file app.info
197+
Run your testcase at least once:
195198

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
199200

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:
203202

204-
c) Getting HTML output
203+
$ lcov --directory path/to/my/testcase --capture --output-file app.info
205204

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.
207209

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.
209213

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.
212216

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]
214243

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:
218245

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.
221266

222267

223268
6. New features:
@@ -238,8 +283,8 @@ New features and capabilities fall into 7 major categories:
238283
and the genhtml man page for details.
239284

240285
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
243288

244289
b) Error handling
245290

@@ -289,7 +334,7 @@ New features and capabilities fall into 7 major categories:
289334

290335
Other options are used to focus on or to exclude certain sections
291336
of code, as well as to do regexp replacement of file names - possibly
292-
using case-insensitve comparison.
337+
using case-insensitive comparison.
293338
(Path munging is useful primarily when the build structure does
294339
not exactly match the layout in your revision control system; this
295340
is common in large projects with reusable components.)
@@ -323,6 +368,9 @@ New features and capabilities fall into 7 major categories:
323368
Sample script: criteria
324369
iv) find source files in more complicated environments - where
325370
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.
326374

327375
The callback may be any desired script or executable - but there
328376
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:
335383

336384
Related options:
337385
--annotate-script, --criteria-script, --version-script
338-
--resolve-script
386+
--resolve-script --select-script
339387

340388
f) Performance
341389

@@ -344,7 +392,7 @@ New features and capabilities fall into 7 major categories:
344392
In general, this provides speedup that is nearly linear in the number
345393
of cores.
346394
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
348396
profile data collection - so you can see where time is going and
349397
thus to hint at potential optimizations. The 'spreadsheet.py'
350398
script can be used to view generated profile data.
@@ -360,11 +408,27 @@ New features and capabilities fall into 7 major categories:
360408

361409
g) Language support
362410

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.
365427

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.
368432

369433
Other languages can be integrated using a similar approach.
370434

0 commit comments

Comments
 (0)