[PATCH] Rewrite test-coverage rules to accommodate multiple .o files per .c.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This makes the "make -C src cov" rule work with the addition of the
libvirt_test.la convenience library.  The trouble is that since there
are now two .o files per .c (one for the "real" libvirt library, and
another for the convenience library, libvirt_test.la, with no access
restrictions, for testing), when you generate test-coverage stats,
you have stats for each .c file in two different places, one for each
.o file.  This solves the problem by running gcov on each pair of .o files.

A minor twist: when profiling with --disable-shared, the .o files are in
".", rather than in ".libs/", so configure.in now records the dirname
in a new AC_SUBST'd variable, LV_LIBTOOL_OBJDIR, and src/Makefile.am
uses that.  Thus, profiling works with shared as well as static
libraries.


	Rewrite test-coverage rules to accommodate multiple .o files per .c.
	* src/Makefile.am (cov): Rewrite rule to merge gcov results corresponding
	to two .o files: the libvirt_la- one, and the libvirt_test_la- one.
	(tst): Remove unused rule.
	* configure.in (LV_LIBTOOL_OBJDIR): Define and AC_SUBST.

Signed-off-by: Jim Meyering <meyering@xxxxxxxxxx>
---
 configure.in    |    7 +++++++
 src/Makefile.am |   24 ++++++++++++------------
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/configure.in b/configure.in
index c2030c7..6367990 100644
--- a/configure.in
+++ b/configure.in
@@ -913,6 +913,13 @@ AC_SUBST(MINGW_EXTRA_LDFLAGS)

 AC_SYS_LARGEFILE

+# Set LV_LIBTOOL_OBJDIR to "." or $lt_cv_objdir, depending on whether
+# we're building shared libraries.  This is the name of the directory
+# in which .o files will be created.
+test "$enable_shared" = no && lt_cv_objdir=.
+LV_LIBTOOL_OBJDIR=${lt_cv_objdir-.}
+AC_SUBST(LV_LIBTOOL_OBJDIR)
+
 # very annoying
 rm -f COPYING
 cp COPYING.LIB COPYING
diff --git a/src/Makefile.am b/src/Makefile.am
index c15de77..f8f2c4b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -137,20 +137,20 @@ else
 EXTRA_DIST += parthelper.c
 endif

-#
-# target to ease building test programs
-#
-tst: tst.c
-	$(CC) $(CFLAGS) $(INCLUDES) -I../include -o tst tst.c .libs/libvirt.a $(LIBXML_LIBS) $(VIRSH_LIBS) $(GNUTLS_LIBS) $(LIBS)
-
-COVERAGE_FILES = $(CLIENT_SOURCES:%.c=libvirt_la-%.cov)
-
-cov: clean-cov $(COVERAGE_FILES)
+cov: clean-cov
+	for i in $(CLIENT_SOURCES); do			\
+	  case $$i in *.c) ;; *) continue;; esac;	\
+	  b=$$(basename $$i .c);			\
+	  o_files=;					\
+	  for i in '' _test; do				\
+	    o="$(LV_LIBTOOL_OBJDIR)/libvirt$${i}_la-$$b.o";	\
+	    test -f "$$o"				\
+	      && o_files="$$o_files $$o";		\
+	  done;						\
+	  gcov -b -f $$o_files > $$b.cov;		\
+	done

 clean-cov:
 	rm -f *.cov *.gcov

-%.cov: .libs/%.o
-	gcov -b -f -o .libs $< > $@
-
 CLEANFILES = *.cov *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda
--
1.5.4.3.231.gc0a6

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]