From 0e5d9ac1bb8fe0d3c87bdcacc47a54101e315dcd Mon Sep 17 00:00:00 2001 From: maroy Date: Mon, 2 Aug 2004 05:25:24 +0000 Subject: [PATCH] added code coverage reporting --- .../modules/db/bin/gen_coverage_data.sh | 79 +++++++++++++++++++ livesupport/modules/db/etc/Makefile.in | 28 ++++--- livesupport/modules/db/etc/configure.ac | 21 ++++- 3 files changed, 114 insertions(+), 14 deletions(-) create mode 100755 livesupport/modules/db/bin/gen_coverage_data.sh diff --git a/livesupport/modules/db/bin/gen_coverage_data.sh b/livesupport/modules/db/bin/gen_coverage_data.sh new file mode 100755 index 000000000..b9b2c5675 --- /dev/null +++ b/livesupport/modules/db/bin/gen_coverage_data.sh @@ -0,0 +1,79 @@ +#!/bin/sh +#------------------------------------------------------------------------------- +# Copyright (c) 2004 Media Development Loan Fund +# +# This file is part of the LiveSupport project. +# http://livesupport.campware.org/ +# To report bugs, send an e-mail to bugs@campware.org +# +# LiveSupport is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LiveSupport is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LiveSupport; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# Author : $Author: maroy $ +# Version : $Revision: 1.1 $ +# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/db/bin/gen_coverage_data.sh,v $ +#------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- +# This script generates code coverage data for the module +#------------------------------------------------------------------------------- +module="LiveSupport Core" + +reldir=`dirname $0`/.. +basedir=`cd $reldir; pwd; cd -` +bindir=$basedir/bin +docdir=$basedir/doc +tmpdir=$basedir/tmp + +usrdir=`cd $basedir/../../usr; pwd; cd -` + +coverage_report_dir=$docdir/coverage + +raw_coverage_file=$tmpdir/raw_coverage.info +coverage_file=$tmpdir/coverage.info + +lcov=$usrdir/bin/lcov +genhtml=$usrdir/bin/genhtml + + +#------------------------------------------------------------------------------- +# Re-configure with covarege collection enabled, compile and run the tests +#------------------------------------------------------------------------------- +$bindir/autogen.sh --enable-coverage +make clean +make check + +#------------------------------------------------------------------------------- +# Generate some symlinks so that the sources are visible from tmpdir +#------------------------------------------------------------------------------- +ln -s $basedir/include $tmpdir/include +ln -s $basedir/src $tmpdir/src + + +#------------------------------------------------------------------------------- +# Use lcov to generate an HTML report on the coverage data +#------------------------------------------------------------------------------- +$lcov -d $tmpdir -c > $raw_coverage_file +$lcov -e $raw_coverage_file "$tmpdir/*" > $coverage_file +rm -rf $coverage_report_dir +mkdir -p $coverage_report_dir +$genhtml -t "$module" -o $coverage_report_dir $coverage_file + + +#------------------------------------------------------------------------------- +# Clean up +#------------------------------------------------------------------------------- +rm -f $tmpdir/include +rm -f $tmpdir/src +rm -f $raw_coverage_file $coverage_file diff --git a/livesupport/modules/db/etc/Makefile.in b/livesupport/modules/db/etc/Makefile.in index 2c2a55659..d97db14f9 100644 --- a/livesupport/modules/db/etc/Makefile.in +++ b/livesupport/modules/db/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: maroy $ -# Version : $Revision: 1.2 $ +# Version : $Revision: 1.3 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/db/etc/Makefile.in,v $ # # @configure_input@ @@ -39,14 +39,15 @@ DOXYGEN = doxygen #------------------------------------------------------------------------------- # Basic directory and file definitions #------------------------------------------------------------------------------- -BASE_DIR = @builddir@ -DOC_DIR = ${BASE_DIR}/doc -DOXYGEN_DIR = ${DOC_DIR}/doxygen -ETC_DIR = ${BASE_DIR}/etc -INCLUDE_DIR = ${BASE_DIR}/include -LIB_DIR = ${BASE_DIR}/lib -SRC_DIR = ${BASE_DIR}/src -TMP_DIR = ${BASE_DIR}/tmp +BASE_DIR = @builddir@ +DOC_DIR = ${BASE_DIR}/doc +DOXYGEN_DIR = ${DOC_DIR}/doxygen +COVERAGE_DIR = ${DOC_DIR}/coverage +ETC_DIR = ${BASE_DIR}/etc +INCLUDE_DIR = ${BASE_DIR}/include +LIB_DIR = ${BASE_DIR}/lib +SRC_DIR = ${BASE_DIR}/src +TMP_DIR = ${BASE_DIR}/tmp USR_DIR = ${BASE_DIR}/../../usr USR_INCLUDE_DIR = ${USR_DIR}/include @@ -79,12 +80,13 @@ DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config # Configuration parameters #------------------------------------------------------------------------------- CPPFLAGS = @CPPFLAGS@ -CXXFLAGS = @CXXFLAGS@ @DEFS@ -I${USR_INCLUDE_DIR} \ +CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ \ + -pedantic -Wall -Wno-long-long \ + -I${USR_INCLUDE_DIR} \ -I${BOOST_INCLUDE_DIR} \ -I${LIBXMLPP_INCLUDE_DIR} \ -I${CORE_INCLUDE_DIR} \ - -I${INCLUDE_DIR} -I${TMP_DIR} \ - -pedantic -Wall -Wno-long-long + -I${INCLUDE_DIR} -I${TMP_DIR} LDFLAGS = @LDFLAGS@ -L${USR_LIB_DIR} -L${CORE_LIB_DIR} -L${LIB_DIR} @@ -115,9 +117,11 @@ doc: clean: ${RM} ${DB_LIB_OBJS} ${DB_LIB_FILE} ${RM} ${TEST_RUNNER_OBJS} ${TEST_RUNNER} + ${RM} ${TMP_DIR}/*.bb ${TMP_DIR}/*.bbg ${TMP_DIR}/*.da docclean: ${RMDIR} ${DOXYGEN_DIR}/html + ${RMDIR} ${COVERAGE_DIR}/* ${RM} ${TEST_RESULTS} depclean: clean diff --git a/livesupport/modules/db/etc/configure.ac b/livesupport/modules/db/etc/configure.ac index 09c3cce3a..ef4ca8020 100644 --- a/livesupport/modules/db/etc/configure.ac +++ b/livesupport/modules/db/etc/configure.ac @@ -21,7 +21,7 @@ dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA dnl dnl dnl Author : $Author: maroy $ -dnl Version : $Revision: 1.3 $ +dnl Version : $Revision: 1.4 $ dnl Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/db/etc/configure.ac,v $ dnl----------------------------------------------------------------------------- @@ -35,7 +35,7 @@ dnl----------------------------------------------------------------------------- AC_INIT(Db, 1.0, bugs@campware.org) AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2004 Media Development Loan Fund under the GNU GPL]) -AC_REVISION($Revision: 1.3 $) +AC_REVISION($Revision: 1.4 $) AC_CONFIG_SRCDIR(../include/LiveSupport/Db/ConnectionManagerInterface.h) @@ -44,6 +44,23 @@ AC_PROG_CXX() AC_CHECK_HEADERS(getopt.h) +dnl----------------------------------------------------------------------------- +dnl enable compilaton for code coverage data +dnl----------------------------------------------------------------------------- +AC_SUBST(COVERAGE_CXXFLAGS) + +AC_ARG_ENABLE( coverage, +[ --enable-coverage enable code coverage data generaton (no) ], + ENABLE_COVERAGE=${enableval}, ENABLE_COVERAGE="no" ) + +if test "x${ENABLE_COVERAGE}" == "xyes" ; then + COVERAGE_CXXFLAGS="-fprofile-arcs -ftest-coverage" + AC_MSG_RESULT([compiling in code coverage mode]) +else + AC_MSG_RESULT([not compiling in code coverage mode]) +fi + + AC_CONFIG_FILES(../Makefile:../etc/Makefile.in) AC_OUTPUT()