Menu

[r79]: / tcov.sh  Maximize  Restore  History

Download this file

155 lines (129 with data), 4.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/sh
#
# compile p5c * compile all tests
# generate coverage data
#
if [ -z $P5CDIR ] ; then
echo "\$P5CDIR is not set, bailing out"
exit 1
fi
PASFILE=pcom
if [ -f $PASFILE ] && [ "`basename $PASFILE .PAS`.PAS" = "`basename $PASFILE`" ] ; then
TPROG=`dirname $PASFILE`/`basename $PASFILE .PAS`
EXT=PAS
elif [ -f $PASFILE ] && [ "`basename $PASFILE .pas`.pas" = "`basename $PASFILE`" ] ; then
TPROG=`dirname $PASFILE`/`basename $PASFILE .pas`
EXT=pas
elif [ -f $PASFILE ] && [ `basename $PASFILE .p`.p = "`basename $PASFILE`" ] ; then
TPROG=`dirname $PASFILE`/`basename $PASFILE .p`
EXT=p
elif [ -f $PASFILE ] && [ `basename $PASFILE .pp`.pp = "`basename $PASFILE`" ] ; then
TPROG=`dirname $PASFILE`/`basename $PASFILE .pp`
EXT=pp
elif [ -f $PASFILE.pas ] ; then
TPROG=$PASFILE
EXT=pas
elif [ -f $PASFILE.p ] ; then
TPROG=$PASFILE
EXT=p
elif [ -f $PASFILE.pp ] ; then
TPROG=$PASFILE
EXT=pp
else
echo "can't find $PASFILE or $PASFILE.pas or $PASFILE.p or $PASFILE.pp" > /dev/stderr
exit 1
fi
echo "coverage test for $TPROG.$EXT"
####################################################
#
## step 1 - clear existing coverage counters
#
which lcov 1>/dev/null 2>&1
if [ $? -ne 0 ]
then
rm -f t.$TPROG.*
else
#lcov --base-directory . --directory . --zerocounters -q
lcov --base-directory . --directory . --zerocounters
fi
####################################################
#
## step 2 - instrument program under test for coverage analysis
# (instrumented program is t.something)
echo '{$n+,d-,v- -- force line numbers, omit debug code }' > t.$TPROG.$EXT
cpp -E -nostdinc -I $P5CDIR $TPROG.$EXT -w | grep -v -e "^# 1 \"<" >> t.$TPROG.$EXT
$P5CDIR/p5c t.$TPROG.pas t.$TPROG.c > t.$TPROG.lst
# The status of the compile is not returned,
# so convert a non-zero error message to fail status
if ! grep -qF "Errors in program: 0" t.$TPROG.lst ; then
awk '{ if( $2=="****" ) {print l0 "\n" l1 "\n" $0 ;} \
else { l0=l1; l1 = $0; }; } \
/^Errors in program/,0; \
' t.$TPROG.lst > /dev/stderr
echo "cannot compile p5c, quitting" > /dev/stderr
exit 1
fi
cc -std=gnu99 --coverage -I $P5CDIR t.$TPROG.c -o t.$TPROG 2> t.$TPROG.err
if [ -s t.$TPROG.err ]; then
if grep -qF ": error: " t.$TPROG.err; then
echo "gcc compile failed, quitting" > /dev/stderr
exit 1
fi
fi
####################################################
#
## step 3 - run the tests with the instrumented program
#
cpp -E -nostdinc tp5c.pas -w | grep -v -e "^# 1 \"<" > tp5c.1.pas
echo tp5c
./t.$TPROG tp5c.1.pas /dev/null > /dev/null
cpp -E -nostdinc tp5cd.pas -w | grep -v -e "^# 1 \"<" > tp5cd.1.pas
echo tp5cd
./t.$TPROG tp5cd.1.pas /dev/null > /dev/null
./t.$TPROG copytext.p /dev/null > /dev/null
cpp -E -nostdinc tclib.pas -w | grep -v -e "^# 1 \"<" > tclib.1.pas
./t.$TPROG tclib.1.pas /dev/null > /dev/null
for dir in *-tests ; do
cd $dir
echo "$dir"
rm -f *.1.p *.1.pas
for f in *.pas; do
../t.$TPROG $f /dev/null > /dev/null
done
cd ..
done
cd rej-tests
rm -f *.1.p *.1.pas
echo isoprt
for f in iso*.pas; do
../t.$TPROG $f /dev/null > /dev/null
done
echo dxxx, exxx, lxxx
for f in [del]???.pas; do
../t.$TPROG $f /dev/null > /dev/null
done
echo error, deviance
for f in [de]6p*.p; do
../t.$TPROG $f /dev/null > /dev/null
done
cd ..
####################################################
#
## step 4 - show the results
#
gcov t.$TPROG.c
which lcov 1>/dev/null 2>&1
if [ $? -ne 0 ]
then
less $TPROG.$EXT.gcov # alternatively try the 'gcovr' utility
else
lcov --base-directory . --directory . -c -o t.$TPROG.info
genhtml --legend \
--output-directory $TPROG.rpt \
--title "test coverage for $TPROG.$EXT" \
--num-spaces 4 t.$TPROG.info
konqueror $TPROG.rpt/index.html
fi
#clean up
rm t.$TPROG.$EXT t.$TPROG.err t.$TPROG.lst
############################ end of tcov ##############################
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.