add an --with-coverage configure option and a 'make cov' target based on
* configure.in Makefile.am: add an --with-coverage configure option
and a 'make cov' target based on gcc profiling and the lcov
tool. Currently at 68.9% coverage out of 'make check' and
runsuite executions.
* xmlreader.c: remove warnings due to C++ comments
Daniel
svn path=/trunk/; revision=3780
diff --git a/ChangeLog b/ChangeLog
index 984819e..8f8f8e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Aug 27 17:30:48 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * configure.in Makefile.am: add an --with-coverage configure option
+ and a 'make cov' target based on gcc profiling and the lcov
+ tool. Currently at 68.9% coverage out of 'make check' and
+ runsuite executions.
+ * xmlreader.c: remove warnings due to C++ comments
+
Wed Aug 27 15:00:54 CEST 2008 Daniel Veillard <daniel@veillard.com>
* include/libxml/parserInternals.h parser.c: cleanup entity
diff --git a/Makefile.am b/Makefile.am
index f1e2863..49bd6f7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1129,6 +1129,7 @@
cleanup:
-@(find . -name .\#\* -exec rm {} \;)
+ -@(find . -name \*.gcda -o *.gcno -exec rm {} \;)
-@(find . -name \*.orig -o -name \*.rej -o -name \*.old -exec rm {} \;)
dist-hook: cleanup libxml2.spec
@@ -1164,7 +1165,7 @@
< $(srcdir)/xml2Conf.sh.in > xml2Conf.tmp \
&& mv xml2Conf.tmp xml2Conf.sh
-CLEANFILES=xml2Conf.sh
+CLEANFILES=xml2Conf.sh *.gcda *.gcno
confexecdir=$(libdir)
confexec_DATA = xml2Conf.sh
@@ -1216,3 +1217,28 @@
sparse: clean
$(MAKE) CC=cgcc
+
+#
+# Coverage support, largely borrowed from libvirt
+# Both binaries comes from the lcov package in Fedora
+#
+LCOV = /usr/bin/lcov
+GENHTML = /usr/bin/genhtml
+
+cov: clean-cov
+ if [ "`echo $(LDFLAGS) | grep coverage`" = "" ] ; then \
+ echo not configured with coverage; exit 1 ; fi
+ if [ ! -x $(LCOV) -o ! -x $(GENHTML) ] ; then \
+ echo Need $(LCOV) and $(GENHTML) excecutables; exit 1 ; fi
+ -@($(MAKE) check)
+ -@(./runsuite$(EXEEXT))
+ mkdir $(top_builddir)/coverage
+ $(LCOV) -c -o $(top_builddir)/coverage/libxml2.info.tmp -d $(top_srcdir)
+ $(LCOV) -r $(top_builddir)/coverage/libxml2.info.tmp -o $(top_builddir)/coverage/libxml2.info *usr*
+ rm $(top_builddir)/coverage/libxml2.info.tmp
+ $(GENHTML) -s -t "libxml2" -o $(top_builddir)/coverage --legend $(top_builddir)/coverage/libxml2.info
+ echo "Coverage report is in $(top_builddir)/coverage/index.html"
+
+clean-cov:
+ rm -rf $(top_builddir)/coverage
+
diff --git a/configure.in b/configure.in
index 8fc76e5..0ce7153 100644
--- a/configure.in
+++ b/configure.in
@@ -163,6 +163,8 @@
LDFLAGS="${LDFLAGS} -L$withval/lib"
fi
])
+AC_ARG_WITH(coverage,
+[ --with-coverage build for code coverage with GCC (off)])
dnl
dnl hard dependancies on options
@@ -1371,8 +1373,18 @@
AC_SUBST(CYGWIN_EXTRA_LDFLAGS)
AC_SUBST(CYGWIN_EXTRA_PYTHON_LIBADD)
+if test "$with_coverage" = "yes" -a "${GCC}" = "yes"
+then
+ echo Enabling code coverage for GCC
+ CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
+ LDFLAGS="$LDFLAGS -fprofile-arcs -ftest-coverage"
+else
+ echo Disabling code coverage for GCC
+fi
+
AC_SUBST(CPPFLAGS)
AC_SUBST(CFLAGS)
+AC_SUBST(LDFLAGS)
AC_SUBST(XML_CFLAGS)
AC_SUBST(XML_LIBDIR)
diff --git a/xmlreader.c b/xmlreader.c
index 737fdbc..bd47ea5 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -1847,22 +1847,22 @@
}
if (reader->state != XML_TEXTREADER_BACKTRACK) {
- /* Here removed traversal to child, because we want to skip the subtree,
+ /* Here removed traversal to child, because we want to skip the subtree,
replace with traversal to sibling to skip subtree */
if (reader->node->next != 0) {
- reader->node = reader->node->next;// Move to sibling if present,skipping sub-tree
- //reader->depth++;
+ /* Move to sibling if present,skipping sub-tree */
+ reader->node = reader->node->next;
reader->state = XML_TEXTREADER_START;
return(1);
}
-
- /* if reader->node->next is NULL mean no subtree for current node,
+
+ /* if reader->node->next is NULL mean no subtree for current node,
so need to move to sibling of parent node if present */
if ((reader->node->type == XML_ELEMENT_NODE) ||
(reader->node->type == XML_ATTRIBUTE_NODE)) {
reader->state = XML_TEXTREADER_BACKTRACK;
- xmlTextReaderRead(reader);// This will move to parent if present
- //return(xmlTextReaderReadTree(reader));
+ /* This will move to parent if present */
+ xmlTextReaderRead(reader);
}
}
@@ -1881,8 +1881,8 @@
reader->node = reader->node->parent;
reader->depth--;
reader->state = XML_TEXTREADER_BACKTRACK;
- xmlTextReaderNextTree(reader); //Repeat process to move to sibling of parent node if present
- //return(1);
+ /* Repeat process to move to sibling of parent node if present */
+ xmlTextReaderNextTree(reader);
}
reader->state = XML_TEXTREADER_END;