Skip to content

Commit

Permalink
Add coverage to the unit test framework.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-kristjansson committed Feb 21, 2013
1 parent f35ce4f commit a3db0dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Expand Up @@ -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
Expand All @@ -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
14 changes: 12 additions & 2 deletions mythtv/programs/scripts/unittests.sh
Expand Up @@ -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."
Expand Down

0 comments on commit a3db0dc

Please sign in to comment.