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/
---
 .gitignore         |    4 ++++
 Makefile           |    1 +
 common.mak         |    2 +-
 configure          |    4 ++++
 doc/developer.texi |   22 ++++++++++++++++++++++
 tests/Makefile     |    9 ++++++++-
 6 files changed, 40 insertions(+), 2 deletions(-)

the IMMEDIATE: "declaration" causes the coverage.info file to be deleted
immediately. Otherwise, the developer would have to delete it by hand
every time he runs another test in order to get updated results with
'make lcov'. I count this as a huge usability gain.

Also, this revision now avoids creating files in the source tree when
working in out-of-source trees.

diff --git a/.gitignore b/.gitignore
index 3ed55b3..42b0a07 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,8 @@
 *.dll
 *.exe
 *.exp
+*.gcda
+*.gcno
 *.h.c
 *.ilk
 *.lib
@@ -22,6 +24,7 @@
 /avprobe
 /avserver
 /config.*
+/coverage.info
 /version.h
 /doc/*.1
 /doc/*.html
@@ -30,6 +33,7 @@
 /doc/avoptions_format.texi
 /doc/doxy/html/
 /doc/print_options
+/lcov
 /libavcodec/*_tablegen
 /libavcodec/*_tables.c
 /libavcodec/*_tables.h
diff --git a/Makefile b/Makefile
index 290cf64..67121c6 100644
--- a/Makefile
+++ b/Makefile
@@ -188,6 +188,7 @@ clean::
        $(RM) $(ALLPROGS)
        $(RM) $(CLEANSUFFIXES)
        $(RM) $(CLEANSUFFIXES:%=tools/%)
+       $(RM) -rf coverage.info lcov
 
 distclean::
        $(RM) $(DISTCLEANSUFFIXES)
diff --git a/common.mak b/common.mak
index b134835..e350215 100644
--- a/common.mak
+++ b/common.mak
@@ -50,7 +50,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
 
diff --git a/configure b/configure
index 111f9fd..4417d66 100755
--- a/configure
+++ b/configure
@@ -2165,6 +2165,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"
     ;;
diff --git a/doc/developer.texi b/doc/developer.texi
index cde87f1..df09587 100644
--- a/doc/developer.texi
+++ b/doc/developer.texi
@@ -550,6 +550,28 @@ why the expected result changed.
 
 Please refer to @url{fate.html}.
 
+@subsection Visualizing Test Coverage
+
+The Libav build system provides means for visualizing the test coverage
+leveraging the coverage tools @code{gcov}/@code{lcov} in an easy manner.
+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.
+@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{lcov --directory . --zerocounters} 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 4e4eb89..07e9605 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -123,6 +123,12 @@ $(FATE): $(FATE_UTILS:%=tests/%$(HOSTEXESUF))
 fate-list:
        @printf '%s\n' $(sort $(FATE))
 
+coverage.info:
+       lcov -d $(CURDIR) -b $(SRC_PATH) --capture -o $@
+
+lcov: coverage.info
+       genhtml -o $(CURDIR)/lcov $<
+
 clean:: testclean
 
 testclean:
@@ -132,4 +138,5 @@ testclean:
 
 -include $(wildcard tests/*.d)
 
-.PHONY: fate*
+.PHONY: fate* lcov
+.INTERMEDIATE: coverage.info
-- 
1.7.9.5

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to