Permalink
Browse files

Add coverage to the unit test framework.

  • Loading branch information...
daniel-kristjansson authored and jyavenard committed Feb 21, 2013
1 parent e5389b2 commit d87fbce60ce8297e74ac61718e6e839d4893c61a
@@ -6,6 +6,11 @@ TARGET = test_mythtimer
DEPENDPATH += . ../..
INCLUDEPATH += . ../..
eval(QMAKE_CXX = g++) {
QMAKE_CXXFLAGS += -O0 -fprofile-arcs -ftest-coverage
QMAKE_LFLAGS += -fprofile-arcs
}
# Input
HEADERS += test_mythtimer.h
SOURCES += test_mythtimer.cpp
@@ -14,3 +19,4 @@ HEADERS += mythtimer.h
SOURCES += mythtimer.cpp
QMAKE_CLEAN += $(TARGET) $(TARGETA) $(TARGETD) $(TARGET0) $(TARGET1) $(TARGET2)
QMAKE_CLEAN += ; rm -f *.gcov *.gcda *.gcno
@@ -5,18 +5,28 @@
DIRNAME=`which dirname`
BASENAME=`which basename`
SED=`which sed`
GCOV=`which gcov`
GREP=`which grep`
TEST_FAILED=0
TESTS=`find -name "test_*.pro"`
for TEST in $TESTS
do
PATH=`$DIRNAME $TEST`
FPATH=`$DIRNAME $TEST`
EXEC=`$BASENAME $TEST | $SED -e 's/.pro//'`
RUNNABLE=$PATH/$EXEC
COV=`$BASENAME $TEST | $SED -e 's/test_//' | $SED -e 's/.pro/.cpp/'`
COVGCNO=`$BASENAME $TEST | $SED -e 's/test_//' | $SED -e 's/.pro/.gcno/'`
RUNNABLE=$FPATH/$EXEC
if test -x $RUNNABLE -a -f $RUNNABLE ; then
if ./$RUNNABLE ; then
if test -x $GCOV -a -f $FPATH/$COVGCNO ; then
P=`pwd` ; cd $FPATH # pushd==
LINES=`$GCOV $COV | $GREP Lines | $SED -e 's/Lines//'`
echo Coverage: $COV $LINES. See $FPATH/$COV.gcov for details
cd $P # popd==
fi
echo
else
echo "error: A unit test failed."

0 comments on commit d87fbce

Please sign in to comment.