]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Add coverage testing using gcov
authorTheodore Ts'o <tytso@mit.edu>
Sun, 23 Feb 2014 05:17:09 +0000 (00:17 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 23 Feb 2014 05:17:09 +0000 (00:17 -0500)
To check the coverage of e2fsprogs's regression test, do the
following:

configure --enable-gcov
make -j8 ; make -j8 check ; make coverage.txt

The coverage information will be the coverage.txt and *.gcov files in
the build directories.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
15 files changed:
MCONFIG.in
Makefile.in
configure
configure.in
debugfs/Makefile.in
e2fsck/Makefile.in
ext2ed/Makefile.in
intl/Makefile.in
lib/blkid/Makefile.in
lib/ext2fs/Makefile.in
misc/Makefile.in
po/Makefile.in.in
resize/Makefile.in
tests/progs/Makefile.in
util/Makefile.in

index af649ed3173f64633b8cf04b07cc06b6ea513268..5ed4df072052733178258e076a7e4a9516d064b2 100644 (file)
@@ -249,6 +249,14 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/MCONFIG \
 @MAINTAINER_CMT@$(top_srcdir)/configure: $(top_srcdir)/configure.in
 @MAINTAINER_CMT@       cd $(top_srcdir) && autoheader && autoconf
 
+coverage.txt: Makefile $(SRCS)
+       if test -n "$(SRCS)"; then \
+               gcov -s $(top_srcdir) -o . $(SRCS) > coverage.txt 2>&1 ; \
+       fi
+
+clean::
+       $(RM) -f *.gcda *.gcov *.gcno coverage.txt
+
 #
 # Make depend magic...
 #
index f327d19d2a3c312b01caa0a8dab52635f3f018fe..cf129db3f3a29acd8dfb0a45112835facbaddc8f 100644 (file)
@@ -73,10 +73,12 @@ install-libs: install-libs-recursive
 
 uninstall-libs: uninstall-libs-recursive
 
+coverage.txt: coverage.txt-recursive
+
 check-recursive: all
 
 TAGS clean-recursive distclean-recursive depend-recursive check-recursive \
-  mostlyclean-recursive realclean-recursive:
+  mostlyclean-recursive realclean-recursive coverage.txt-recursive:
        @for subdir in $(SUBDIRS); do \
          if test -d $$subdir ; then \
            target=`echo $@|$(SED) 's/-recursive//'`; \
@@ -86,7 +88,7 @@ TAGS clean-recursive distclean-recursive depend-recursive check-recursive \
        done
 
 all-progs-recursive install-progs-recursive install-strip-progs-recursive \
-  uninstall-progs-recursive: all-libs-recursive
+  uninstall-progs-recursive coverage.txt-progs-recursive: all-libs-recursive
        @for subdir in $(PROG_SUBDIRS); do \
          if test -d $$subdir ; then \
            target=`echo $@|$(SED) 's/-progs-recursive//'`; \
@@ -97,7 +99,8 @@ all-progs-recursive install-progs-recursive install-strip-progs-recursive \
 
 all-libs-recursive install-libs-recursive install-strip-libs-recursive \
   uninstall-libs-recursive install-shlibs-libs-recursive \
-  install-shlibs-strip-libs-recursive uninstall-shlibs-libs-recursive:
+  install-shlibs-strip-libs-recursive uninstall-shlibs-libs-recursive \
+  coverage.txt-libs-recursive:
        @for subdir in $(LIB_SUBDIRS); do \
          if test -d $$subdir ; then \
            target=`echo $@|$(SED) 's/-libs-recursive//'`; \
@@ -108,7 +111,7 @@ all-libs-recursive install-libs-recursive install-strip-libs-recursive \
 
 mostlyclean: mostlyclean-recursive mostlyclean-local
 
-clean: clean-recursive clean-local clean-doc
+clean:: clean-recursive clean-local clean-doc
        $(RM) -f $(SUBS) 
 
 distclean: distclean-doc distclean-recursive
index 19e8d82b4dd9c101f424d617512bd6714fa23687..44664c31294174a94a2b6d870df678077cd51c32 100755 (executable)
--- a/configure
+++ b/configure
@@ -836,6 +836,7 @@ enable_htree
 enable_elf_shlibs
 enable_bsd_shlibs
 enable_profile
+enable_gcov
 enable_checker
 enable_jbd_debug
 enable_blkid_debug
@@ -1492,6 +1493,7 @@ Optional Features:
   --enable-elf-shlibs    select ELF shared libraries
   --enable-bsd-shlibs    select BSD shared libraries
   --enable-profile       build profiling libraries
+  --enable-gcov                  build for coverage testing using gcov
   --enable-checker       build checker libraries
   --enable-jbd-debug     enable journal debugging
   --enable-blkid-debug    enable blkid debugging
@@ -4677,6 +4679,18 @@ fi
 
 
 
+# Check whether --enable-gcov was given.
+if test "${enable_gcov+set}" = set; then :
+  enableval=$enable_gcov; if test "$enableval" = "yes"
+then
+       CFLAGS="-g -fprofile-arcs -ftest-coverage"
+       LDFLAGS="-fprofile-arcs -ftest-coverage"
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: Enabling gcov support" >&5
+$as_echo "Enabling gcov support" >&6; }
+fi
+
+fi
+
 # Check whether --enable-checker was given.
 if test "${enable_checker+set}" = set; then :
   enableval=$enable_checker; if test "$enableval" = "no"
index fffab7aedaa327cb6aee254856c28a635d3acade..e0e6d4890a724b2f05ba69b78a7620da609fefdd 100644 (file)
@@ -381,6 +381,18 @@ AC_MSG_RESULT([Disabling profiling libraries by default])
 AC_SUBST(PROFILE_CMT)
 AC_SUBST_FILE(MAKEFILE_PROFILE)
 dnl
+dnl handle --enable-gcov
+dnl
+AC_ARG_ENABLE([gcov],
+[  --enable-gcov                 build for coverage testing using gcov],
+if test "$enableval" = "yes"
+then
+       CFLAGS="-g -fprofile-arcs -ftest-coverage"
+       LDFLAGS="-fprofile-arcs -ftest-coverage"
+       AC_MSG_RESULT([Enabling gcov support])
+fi
+)
+dnl
 dnl handle --enable-checker
 dnl
 AC_ARG_ENABLE([checker],
index 80fba5d43064742d4f6691018e5b5261cb83bd8c..5ddeab768ed33faa718f3ebb36a272a3b49b4505 100644 (file)
@@ -117,7 +117,7 @@ uninstall:
                $(RM) -f $(DESTDIR)$(man8dir)/$$i; \
        done
 
-clean:
+clean::
        $(RM) -f $(PROGS) debugfs.8 \#* *.s *.o *.a *~ debug_cmds.c \
                extent_cmds.c ro_debug_cmds.c core rdebugfs debugfs.static
 
index 897bc2bd7d73819cf4ef47c224fe218f9aa9454d..77017efa4a78b3730a559141cf73fe31a33a2622 100644 (file)
@@ -273,7 +273,7 @@ uninstall:
                        $(DESTDIR)$(root_sbindir)/fsck.ext4 \
                        $(DESTDIR)$(root_sbindir)/fsck.ext4dev
 
-clean:
+clean::
        $(RM) -f $(PROGS) \#* *\# *.s *.o *.a *~ core e2fsck.static \
                e2fsck.shared e2fsck.profiled flushb e2fsck.8 \
                tst_problem tst_crc32 tst_region tst_refcount gen_crc32table \
index 290f06e85fa685c33615b71c800933619acdddc6..5f4cc69a5c63eadea281731ea12e56b0112ea899 100644 (file)
@@ -65,7 +65,7 @@ ext2ed.8: $(DEP_SUBSTITUTE) $(srcdir)/ext2ed.8.in
 ext2ed.conf: $(DEP_SUBSTITUTE) $(srcdir)/ext2ed.conf.in
        $(SUBSTITUTE_UPTIME) $(srcdir)/ext2ed.conf.in ext2ed.conf
 
-clean:
+clean::
        $(RM) -f ext2ed $(OBJS) $(DOCS) ext2ed.conf ext2ed.8
        -rmdir doc
 
index 49989e89fa7ce25718d39f7dc744853fa16032cc..87d081f847a0c1c2827f603e4c5233a3f7b4d869 100644 (file)
@@ -488,13 +488,14 @@ id: ID
 ID: $(HEADERS) $(SOURCES)
        here=`pwd`; cd $(srcdir) && mkid -f$$here/ID $(HEADERS) $(SOURCES)
 
+coverage.txt::
 
 mostlyclean:
        rm -f *.a *.la *.o *.obj *.lo core core.*
        rm -f libgnuintl.h libintl.h charset.alias ref-add.sed ref-del.sed
        rm -f -r .libs _libs
 
-clean: mostlyclean
+clean:: mostlyclean
 
 distclean: clean
        rm -f Makefile ID TAGS
index 3f15c6779ef6548176591930184b371e09634a0c..faed6f1ae5430b916d258cdcdaf3d5c6ad6f5b4b 100644 (file)
@@ -118,7 +118,7 @@ tst_tag: $(srcdir)/tag.c $(DEPLIBS_BLKID)
 
 tst_types: tst_types.o blkid_types.h 
        $(E) "  LD $@"
-       $(Q) $(CC) -o tst_types tst_types.o 
+       $(Q) $(CC) -o tst_types $(ALL_LDFLAGS) tst_types.o
 
 ../../misc/blkid.o: $(top_srcdir)/misc/blkid.c blkid.h
        $(E) "  CC $@"
index 1063e625f69c6ab4f48281ca6e429820c00635c4..ad6525a5047d927fd28a4c6268b60de372f4f817 100644 (file)
@@ -224,8 +224,8 @@ ext2fs.pc: $(srcdir)/ext2fs.pc.in $(top_builddir)/config.status
 
 tst_badblocks: tst_badblocks.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
        $(E) "  LD $@"
-       $(Q) $(CC) -o tst_badblocks tst_badblocks.o $(STATIC_LIBEXT2FS) \
-               $(STATIC_LIBCOM_ERR) $(SYSLIBS)
+       $(Q) $(CC) -o tst_badblocks tst_badblocks.o $(ALL_LDFLAGS) \
+               $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) $(SYSLIBS)
 
 tst_icount: $(srcdir)/icount.c $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
        $(E) "  LD $@"
@@ -234,7 +234,7 @@ tst_icount: $(srcdir)/icount.c $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
 
 tst_iscan: tst_iscan.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
        $(E) "  LD $@"
-       $(Q) $(CC) -o tst_iscan tst_iscan.o $(STATIC_LIBEXT2FS) \
+       $(Q) $(CC) -o tst_iscan tst_iscan.o $(ALL_LDFLAGS) $(STATIC_LIBEXT2FS) \
                $(STATIC_LIBCOM_ERR) $(SYSLIBS)
 
 tst_getsize: tst_getsize.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
@@ -268,13 +268,13 @@ tst_types.o: $(srcdir)/tst_types.c ext2_types.h
 
 tst_types: tst_types.o ext2_types.h 
        $(E) "  LD $@"
-       $(Q) $(CC) -o tst_types tst_types.o $(SYSLIBS)
+       $(Q) $(CC) -o tst_types tst_types.o $(ALL_LDFLAGS) $(SYSLIBS)
 
 tst_super_size.o: $(srcdir)/tst_super_size.c $(srcdir)/ext2_fs.h
 
 tst_super_size: tst_super_size.o
        $(E) "  LD $@"
-       $(Q) $(CC) -o tst_super_size tst_super_size.o $(SYSLIBS)
+       $(Q) $(CC) -o tst_super_size tst_super_size.o $(ALL_LDFLAGS) $(SYSLIBS)
 
 tst_fs_struct.o: $(srcdir)/tst_fs_struct.c $(srcdir)/ext2fs.h
 
@@ -286,11 +286,11 @@ tst_inode_size.o: $(srcdir)/tst_inode_size.c $(srcdir)/ext2_fs.h
 
 tst_inode_size: tst_inode_size.o
        $(E) "  LD $@"
-       $(Q) $(CC) -o tst_inode_size tst_inode_size.o $(SYSLIBS)
+       $(Q) $(CC) -o tst_inode_size tst_inode_size.o $(ALL_LDFLAGS) $(SYSLIBS)
 
 ext2_tdbtool: tdbtool.o
        $(E) "  LD $@"
-       $(Q) $(CC) -o ext2_tdbtool tdbtool.o tdb.o $(SYSLIBS)
+       $(Q) $(CC) -o ext2_tdbtool tdbtool.o tdb.o $(ALL_LDFLAGS) $(SYSLIBS)
 
 extent_dbg.c: $(srcdir)/extent_dbg.ct
        $(E) "  MK_CMDS $<"
index e8cfdb5bf9004194d637ab1cb2ab2788dca6de24..29b6aab493d9c467a9e86648754ff6ec8b35cbcf 100644 (file)
@@ -599,7 +599,7 @@ uninstall:
                $(RM) $(DESTDIR)/$(root_sysconfdir)/mke2fs.conf; \
        fi
 
-clean:
+clean::
        $(RM) -f $(SPROGS) $(USPROGS) $(UPROGS) $(UMANPAGES) $(SMANPAGES) \
                $(FMANPAGES) profile.h \
                base_device base_device.out mke2fs.static filefrag e2freefrag \
index 8dbd0c5271b286df4229e2bb5f2b605403972126..2ae2f2a214d9efe2d5bba6a13be00194b2338895 100644 (file)
@@ -281,7 +281,9 @@ mostlyclean:
        rm -f $(DOMAIN).po.bak
        rm -fr *.o
 
-clean: mostlyclean
+coverage.txt::
+
+clean:: mostlyclean
 
 distclean: clean
        rm -f Makefile Makefile.in POTFILES *.mo
index eb6f8901b547a5b4d148ceb292ec9438137fe830..f7b80ef719dba140f6f7c80245b9be40be1ddfbc 100644 (file)
@@ -104,7 +104,7 @@ check:: test_extent.out
                exit 1 ; \
        fi
 
-clean:
+clean::
        $(RM) -f $(PROGS) $(TEST_PROGS) $(MANPAGES) \#* *.s *.o *.a *~ core \
                resize2fs.static test_extent.out
 
index 4c63991c191ba558f8dee37e596f436c5bd2d555..44d04b5106e27683c7a39f991a8adafce488389f 100644 (file)
@@ -51,7 +51,7 @@ test_icount_cmds.c: test_icount_cmds.ct
        $(E) "  MK_CMDS $@"
        $(Q) $(MK_CMDS) $(srcdir)/test_icount_cmds.ct
 
-clean:
+clean::
        $(RM) -f $(PROGS) test_rel_cmds.c test_icount_cmds.c \
                \#* *.s *.o *.a *~ core
 
index 69683b01edae115631ba44535bcd4192fe21cdb9..d235fffc5db5e2e15eb8900283966c881bf2490c 100644 (file)
@@ -50,7 +50,7 @@ tarballs: gen-tarball
        sh gen-tarball all
        sh gen-tarball subset
 
-clean:
+clean::
        $(RM) -f $(PROGS) \#* *.s *.o *.a *~ core *.tar.gz gen-tarball \
                copy-sparse dirpaths.h