diff --git a/.gitignore b/.gitignore index f98c20c2d8..979d6179ae 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ *.dylib *.exe *.exp +*.gcda +*.gcno *.h.c *.ilk *.lib @@ -24,6 +26,7 @@ /ffprobe /ffserver /config.* +/coverage.info /version.h /doc/*.1 /doc/*.3 @@ -44,6 +47,7 @@ /doc/fate.txt /doc/doxy/html/ /doc/print_options +/lcov/ /libavcodec/*_tablegen /libavcodec/*_tables.c /libavcodec/*_tables.h diff --git a/Makefile b/Makefile index 2cafd408dc..7addffbaad 100644 --- a/Makefile +++ b/Makefile @@ -154,8 +154,8 @@ clean:: $(RM) $(ALLPROGS) $(ALLPROGS_G) $(RM) $(CLEANSUFFIXES) $(RM) $(CLEANSUFFIXES:%=tools/%) - $(RM) coverage.info $(RM) -r coverage-html + $(RM) -rf coverage.info lcov distclean:: $(RM) $(DISTCLEANSUFFIXES) @@ -164,15 +164,6 @@ distclean:: config: $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION) -# Without the sed genthml thinks "libavutil" and "./libavutil" are two different things -coverage.info: $(wildcard *.gcda *.gcno */*.gcda */*.gcno */*/*.gcda */*/*.gcno) - $(Q)lcov -c -d . -b . | sed -e 's#/./#/#g' > $@ - -coverage-html: coverage.info - $(Q)mkdir -p $@ - $(Q)genhtml -o $@ $< - $(Q)touch $@ - check: all alltools examples testprogs fate include $(SRC_PATH)/doc/Makefile diff --git a/configure b/configure index 6dcb0c1f3b..0da1f772fa 100755 --- a/configure +++ b/configure @@ -316,7 +316,6 @@ Optimization options (experts only): --disable-fast-unaligned consider unaligned accesses slow Developer options (useful when working on FFmpeg itself): - --enable-coverage build with test coverage instrumentation --disable-debug disable debugging symbols --enable-debug=LEVEL set the debug level [$debuglevel] --disable-optimizations disable compiler optimizations @@ -1560,7 +1559,6 @@ CMDLINE_SELECT=" $HAVE_LIST_CMDLINE $THREADS_LIST asm - coverage cross_compile debug extra_warnings @@ -2481,6 +2479,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" ;; @@ -4117,7 +4119,6 @@ enabled vdpau && disabled iconv || check_func_headers iconv.h iconv || check_lib2 iconv.h iconv -liconv || disable iconv enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel" -enabled coverage && add_cflags "-fprofile-arcs -ftest-coverage" && add_ldflags "-fprofile-arcs -ftest-coverage" test -n "$valgrind" && target_exec="$valgrind --error-exitcode=1 --malloc-fill=0x2a --track-origins=yes --leak-check=full --gen-suppressions=all --suppressions=$source_path/tests/fate-valgrind.supp" # add some useful compiler flags if supported diff --git a/doc/developer.texi b/doc/developer.texi index baf7d20675..d5580d1543 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -580,6 +580,30 @@ message or introductionary message for the patch series that you post to the ffmpeg-devel mailing list, a direct link to download the sample media. +@subsection Visualizing Test Coverage + +The FFmpeg 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 FFmpeg, 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 diff --git a/tests/Makefile b/tests/Makefile index 802f350d2c..9dfd343ef2 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -160,6 +160,19 @@ $(FATE) $(FATE_TESTS-no): $(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 | sed -e 's#/./#/#g' > $@ + +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: @@ -169,4 +182,5 @@ testclean: -include $(wildcard tests/*.d) -.PHONY: fate* +.PHONY: fate* lcov lcov-reset +.INTERMEDIATE: coverage.info