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
This commit is contained in:
Daniel Veillard 2008-08-27 15:33:28 +00:00
parent a8f09ce8d3
commit bfa5cf1ce7
4 changed files with 56 additions and 10 deletions

View File

@ -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

View File

@ -1129,6 +1129,7 @@ ModuleTests: testModule$(EXEEXT) testdso.la
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 @@ xml2Conf.sh: xml2Conf.sh.in Makefile
< $(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 @@ tst: tst.c
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

View File

@ -163,6 +163,8 @@ AC_ARG_WITH(zlib,
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(WIN32_EXTRA_LDFLAGS)
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)

View File

@ -1847,22 +1847,22 @@ xmlTextReaderNextTree(xmlTextReaderPtr reader)
}
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 @@ xmlTextReaderNextTree(xmlTextReaderPtr reader)
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;