summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authordeva <deva>2011-02-14 14:09:04 +0000
committerdeva <deva>2011-02-14 14:09:04 +0000
commit04f275fea9186a75836b589022a9fa410aea7b02 (patch)
tree70d5e61af8e2e8319326d3ca8a9f3ea805fe06e8 /tools
parent95cfffa53760942c3ccf6abc18b81f48d03a3ff6 (diff)
Added gcov (coverage measurement) in unittests.
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am.test6
-rwxr-xr-xtools/test19
-rw-r--r--tools/test.h16
-rwxr-xr-xtools/testlist2
4 files changed, 33 insertions, 10 deletions
diff --git a/tools/Makefile.am.test b/tools/Makefile.am.test
index 5c5e8c7..77ca17e 100644
--- a/tools/Makefile.am.test
+++ b/tools/Makefile.am.test
@@ -8,6 +8,12 @@ test: Makefile.am.test $(TESTFILES)
test_clean:
rm -f $(TESTFILES) $(TESTLOGS)
+test_report:
+ lcov --directory . --capture --output-file app.info
+ genhtml -o lcov app.info
+
+test_all: test_clean test test_report
+
TESTLOGS = `for F in ${TESTFILES}; do echo $$F.log; done`
CLEANFILES = $(TESTFILES) $(TESTLOGS) Makefile.am.test *~
diff --git a/tools/test b/tools/test
index a52609d..1ebf87d 100755
--- a/tools/test
+++ b/tools/test
@@ -7,13 +7,30 @@ DEFINE=TEST_$UPPER
SCRIPTDIR=`dirname $0`
-COMPILE="g++ -DHAVE_CONFIG_H -I$SCRIPTDIR -g -Wall -Werror -D$DEFINE -o $OUTPUT $*"
+INFILE=$1
+shift
+OBJFILES=""
+for f in $TEST_DEPS
+do
+ of=`echo -n $f | cut -d'.' -f1`.o;
+ OBJFILES="$OBJFILES $of"
+done
+
+COMMON_FLAGS="-DHAVE_CONFIG_H -I$SCRIPTDIR -g -D$DEFINE $TEST_LIBS $TEST_CFLAGS"
+CLEAN="rm -f $OBJFILES"
+PRECOMPILE="g++ -c $TEST_DEPS $COMMON_FLAGS"
+COMPILE="g++ -fprofile-arcs -ftest-coverage -Wall -Werror $COMMON_FLAGS -o $OUTPUT $INFILE $OBJFILES"
echo -e "\033[0;2mTesting $TEST:"
echo Testing $TEST: > $OUTPUT.log
echo -n "* Compiling $TEST test"
echo Compiling $TEST test: > $OUTPUT.log
+
+echo ${CLEAN} >> $OUTPUT.log
+${CLEAN} >> ${OUTPUT}.log 2>&1
+echo ${PRECOMPILE} >> $OUTPUT.log
+${PRECOMPILE} >> ${OUTPUT}.log 2>&1
echo ${COMPILE} >> $OUTPUT.log
if ${COMPILE} >> ${OUTPUT}.log 2>&1; then
diff --git a/tools/test.h b/tools/test.h
index f470162..4770a1e 100644
--- a/tools/test.h
+++ b/tools/test.h
@@ -109,11 +109,11 @@
#define TEST_EQUAL_STR(x, y, fmt...) { \
TEST_BASE(fmt); \
- std::string s1 = x; \
- std::string s2 = y; \
+ std::string __s1 = x; \
+ std::string __s2 = y; \
fprintf(stderr, "Comparing: \"%s\" == \"%s\"\n", \
- s1.c_str(), s2.c_str()); \
- if(s1 == s2) { \
+ __s1.c_str(), __s2.c_str()); \
+ if(__s1 == __s2) { \
TEST_OK(#x" and "#y" are equal."); \
} else { \
TEST_FAIL(#x" and "#y" are not equal."); \
@@ -122,11 +122,11 @@
#define TEST_NOTEQUAL_STR(x, y, fmt...) { \
TEST_BASE(fmt); \
- std::string s1 = x; \
- std::string s2 = y; \
+ std::string __s1 = x; \
+ std::string __s2 = y; \
fprintf(stderr, "Comparing: \"%s\" != \"%s\"\n", \
- s1.c_str(), s2.c_str()); \
- if(s1 != s2) { \
+ __s1.c_str(), __s2.c_str()); \
+ if(__s1 != __s2) { \
TEST_OK(#x" and "#y" not are equal."); \
} else { \
TEST_FAIL(#x" and "#y" are equal."); \
diff --git a/tools/testlist b/tools/testlist
index c42824f..01a48e2 100755
--- a/tools/testlist
+++ b/tools/testlist
@@ -24,7 +24,7 @@ do
CFLAGS=`cat $FILE | grep "cflags:" | cut -d':' -f2`
TEST=test_$NAME
echo "$TEST: $FILE $DEPS"
- echo -e "\t@${SCRIPTDIR}/test $FILE $DEPS $CFLAGS $LIBS"
+ echo -e "\t@TEST_DEPS=\"$DEPS\" TEST_CFLAGS=\"$CFLAGS\" TEST_LIBS=\"$LIBS\" ${SCRIPTDIR}/test $FILE"
echo ""
done < tmp