Skip to content

Commit

Permalink
Integrate lcov/gcov into Libav
Browse files Browse the repository at this point in the history
The gcov/lcov are a common toolchain for visualizing code coverage with
the GNU/Toolchain. The documentation and implementation of this
integration was heavily inspired from the blog entry by Mike Melanson:
http://multimedia.cx/eggs/using-lcov-with-ffmpeg/
  • Loading branch information
Reinhard Tartler committed Apr 5, 2013
1 parent 52cd84d commit a862c7d
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*.dll
*.exe
*.exp
*.gcda
*.gcno
*.h.c
*.ilk
*.lib
Expand All @@ -22,6 +24,7 @@
/avprobe
/avserver
/config.*
/coverage.info
/version.h
/doc/*.1
/doc/*.html
Expand All @@ -30,6 +33,7 @@
/doc/avoptions_format.texi
/doc/doxy/html/
/doc/print_options
/lcov/
/libavcodec/*_tablegen
/libavcodec/*_tables.c
/libavcodec/*_tables.h
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ clean::
$(RM) $(ALLPROGS)
$(RM) $(CLEANSUFFIXES)
$(RM) $(CLEANSUFFIXES:%=tools/%)
$(RM) -rf coverage.info lcov

distclean::
$(RM) $(DISTCLEANSUFFIXES)
Expand Down
2 changes: 1 addition & 1 deletion common.mak
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $(TOOLOBJS): | tools

OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(TESTOBJS))

CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver
CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.gcno *.gcda
DISTCLEANSUFFIXES = *.pc
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a

Expand Down
4 changes: 4 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,10 @@ case "$toolchain" in
ar_default="lib"
target_os_default="win32"
;;
gcov)
add_cflags -fprofile-arcs -ftest-coverage
add_ldflags -fprofile-arcs -ftest-coverage
;;
?*)
die "Unknown toolchain $toolchain"
;;
Expand Down
24 changes: 24 additions & 0 deletions doc/developer.texi
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,30 @@ why the expected result changed.

Please refer to @url{fate.html}.

@subsection Visualizing Test Coverage

The Libav build system allows visualizing the test coverage in an easy
manner with the coverage tools @code{gcov}/@code{lcov}. This involves
the following steps:

@enumerate
@item
Configure to compile with instrumentation enabled:
@code{configure --toolchain=gcov}.
@item
Run your test case, either manually or via FATE. This can be either
the full FATE regression suite, or any arbitrary invocation of any
front-end tool provided by Libav, in any combination.
@item
Run @code{make lcov} to generate coverage data in HTML format.
@item
View @code{lcov/index.html} in your preferred HTML viewer.
@end enumerate

You can use the command @code{make lcov-reset} to reset the coverage
measurements. You will need to rerun @code{make lcov} after running a
new test.

@anchor{Release process}
@section Release process

Expand Down
16 changes: 15 additions & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ $(FATE): $(FATE_UTILS:%=tests/%$(HOSTEXESUF))
fate-list:
@printf '%s\n' $(sort $(FATE))

coverage.info: TAG = LCOV
coverage.info:
$(M)lcov -d $(CURDIR) -b $(SRC_PATH) --capture -o $@

lcov: TAG = GENHTML
lcov: coverage.info
$(M)genhtml -o $(CURDIR)/lcov $<

lcov-reset: TAG = LCOV
lcov-reset:
$(M)lcov -d $(CURDIR) --zerocounters
$(Q)$(RM) -f coverage.info

clean:: testclean

testclean:
Expand All @@ -132,4 +145,5 @@ testclean:

-include $(wildcard tests/*.d)

.PHONY: fate*
.PHONY: fate* lcov lcov-reset
.INTERMEDIATE: coverage.info

0 comments on commit a862c7d

Please sign in to comment.