Hyrum K Wright wrote: > On Sun, Nov 25, 2012 at 5:17 PM, Stefan Fuhrmann wrote: >> I was wondering whether we could have one or two of >> our UNIX build bots create a code coverage profile >> and make the results available online. >> >> Here is what I use in my test runner script: >> >> [[[ >> env CFLAGS='-fprofile-arcs -ftest-coverage' ./configure --disable-shared >> --enable-maintainer-mode $moreopts >> >> make -sj 2> /dev/null > /dev/null >> make svnserveautocheck PARALLEL=1 >> >> lcov -d . -b . -c -o tests.lcov > lcov.log >> genhtml tests.lcov -o html > genhtml.log >> ]]] > > > +1 to test coverage stats. > > > We have an ancient patch [...] in tools/dev/gcov.patch. [...]
I attach an updated patch. It uses 'lcov' instead of 'gcov' as Stefan suggests, which makes the Makefile target much simpler; and I modeled the 'configure' handling on the existing --enable-gprof switch. The existing --enable-gprof option requires --disable-shared and recommends --enable-all-static, and I have just copied that without understanding why or whether the same applies to gcov. I'll probably commit it soon if there are no objections, even though my testing has been rather limited, as it seems unlikely to cause problems for anyone except those who use it. - Julian
This patch can be used to generate a report showing what C source lines are executed when the testsuite is run. Requires: GCC, gcov, lcov. After applying this patch, do: $ ./configure --enable-gcov $ make check $ make gcov Now look at gcov-report/index.html and the annotated source files it links to. See also gcov(1), gcc(1). Index: Makefile.in =================================================================== --- Makefile.in (revision 1414844) +++ Makefile.in (working copy) @@ -572,7 +572,23 @@ svnsshcheck: bin $(TEST_DEPS) @BDB_TEST_ bdbcheck: bin $(TEST_DEPS) @BDB_TEST_DEPS@ @$(MAKE) check FS_TYPE=bdb +# Create an execution coverage report from the data collected during +# all execution since the last reset. +gcov: + lcov --capture -d . -b . -o gcov-lcov.dat > gcov-lcov.log + genhtml gcov-lcov.dat -o gcov-report > gcov-genhtml.log + +# Reset all execution coverage counters to zero. +gcov-reset: + lcov --zerocounters -d . + +# Remove the execution coverage data and the report. +gcov-clean: + rm -f gcov-lcov.dat gcov-lcov.log gcov-genhtml.log + rm -rf gcov-report + find . -name "*.gcda" -o -name "*.gcno" -print0 | xargs -0 rm -f + +check-clean: gcov-clean -check-clean: rm -rf subversion/tests/cmdline/svn-test-work \ subversion/tests/libsvn_fs/test-repo-* \ subversion/tests/libsvn_fs_base/test-repo-* \ Index: configure.ac =================================================================== --- configure.ac (revision 1414844) +++ configure.ac (working copy) @@ -1112,6 +1112,30 @@ AC_SUBST(MOD_ACTIVATION) +AC_ARG_ENABLE(gcov, +AC_HELP_STRING([--enable-gcov], + [Turn on gcov coverage testing (GCC only).]), +[ + if test "$enableval" = "yes" ; then + dnl Probably other compilers support something similar; + dnl feel free to extend this to include them. + if test "$GCC" = "yes"; then + if test "$svn_enable_shared" = "yes" ; then + AC_MSG_ERROR([Can't have --enable-gcov without --disable-shared (we + recommend also using --enable-all-static).]) + fi + if test ! "$enable_all_static" = "yes" ; then + AC_MSG_WARN(We recommend --enable-all-static with --enable-gcov.) + fi + AC_MSG_NOTICE([Enabling gcov coverage testing.]) + CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage" + CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage" + else + AC_MSG_ERROR([We only support --enable-gcov with GCC right now.]) + fi + fi +]) + AC_ARG_ENABLE(gprof, AS_HELP_STRING([--enable-gprof], [Produce gprof profiling data in 'gmon.out' (GCC only).]),