[FFmpeg-devel] [PATCH] Add coverage support.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Nov 29 20:37:05 CET 2011


Adds --enable-coverage to configure and a "coverage-html" make target.
The dependency stuff in the Makefile is a bit questionable, but the
best I could think of so far.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 Makefile   |   10 ++++++++++
 common.mak |    2 +-
 configure  |    3 +++
 3 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 94fb830..40f4a00 100644
--- a/Makefile
+++ b/Makefile
@@ -137,6 +137,8 @@ clean::
 	$(RM) $(CLEANSUFFIXES)
 	$(RM) $(TOOLS)
 	$(RM) $(CLEANSUFFIXES:%=tools/%)
+	$(RM) coverage.info
+	$(RM) -r cov-out
 
 distclean::
 	$(RM) $(DISTCLEANSUFFIXES)
@@ -145,6 +147,14 @@ distclean::
 config:
 	$(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
 
+coverage.info: $(wildcard *.gcda *.gcno */*.gcda */*.gcno */*/*.gcda */*/*.gcno)
+	$(Q)lcov -c -d . -b . -o $@
+
+coverage-html: coverage.info
+	$(Q)mkdir -p $@
+	$(Q)genhtml -o $@ $<
+	$(Q)touch $@
+
 include $(SRC_PATH)/doc/Makefile
 include $(SRC_PATH)/tests/Makefile
 
diff --git a/common.mak b/common.mak
index 14c79f0..b7786c5 100644
--- a/common.mak
+++ b/common.mak
@@ -113,7 +113,7 @@ $(TOOLOBJS): | tools
 
 OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOSTOBJS) $(TESTOBJS))
 
-CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
+CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver *.gcno *.gcda
 DISTCLEANSUFFIXES = *.pc
 LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
 
diff --git a/configure b/configure
index 3c47043..a3b03e6 100755
--- a/configure
+++ b/configure
@@ -260,6 +260,7 @@ Advanced options (experts only):
   --optflags               override optimization-related compiler flags
 
 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
@@ -1242,6 +1243,7 @@ CMDLINE_SELECT="
     $CONFIG_LIST
     $THREADS_LIST
     asm
+    coverage
     cross_compile
     debug
     extra_warnings
@@ -3193,6 +3195,7 @@ check_cpp_condition \
 fi
 
 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
+enabled coverage && add_cflags "-fprofile-arcs -ftest-coverage" && add_ldflags "-fprofile-arcs -ftest-coverage"
 
 # add some useful compiler flags if supported
 check_cflags -Wdeclaration-after-statement
-- 
1.7.7.3



More information about the ffmpeg-devel mailing list