2013-07-09 18:37:11 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright 2013 The Tor Project, Inc.
|
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
|
|
|
# coverage -- run gcov on the appropriate set of object files to extract
|
|
|
|
# coverage information.
|
|
|
|
|
2013-07-16 07:33:39 +02:00
|
|
|
dst=$1
|
|
|
|
|
2018-07-05 23:05:54 +02:00
|
|
|
for fn in src/core/*/*.c src/feature/*/*.c src/app/*/*.c src/lib/*/*.c; do
|
2018-11-11 16:50:43 +01:00
|
|
|
BN=$(basename "$fn")
|
|
|
|
DN=$(dirname "$fn")
|
|
|
|
F=$(echo "$BN" | sed -e 's/\.c$//;')
|
2013-07-16 07:33:39 +02:00
|
|
|
GC="${BN}.gcov"
|
2013-07-16 15:40:08 +02:00
|
|
|
# Figure out the object file names
|
2019-02-08 16:43:38 +01:00
|
|
|
ONS=$(echo "${DN}"/*testing_a-"${F}".o)
|
|
|
|
ONS_WILDCARD_LITERAL="${DN}/*testing_a-${F}.o"
|
2013-07-16 15:40:08 +02:00
|
|
|
# If the wildcard didn't expand, no files
|
|
|
|
if [ "$ONS" != "${ONS_WILDCARD_LITERAL}" ]
|
2013-07-16 07:33:39 +02:00
|
|
|
then
|
2013-07-16 15:40:08 +02:00
|
|
|
for on in $ONS; do
|
|
|
|
# We should have a gcno file
|
2018-11-11 16:50:43 +01:00
|
|
|
GCNO=$(echo "$on" | sed -e 's/\.o$/\.gcno/;')
|
|
|
|
if [ -e "$GCNO" ]
|
2013-07-16 15:40:08 +02:00
|
|
|
then
|
|
|
|
# No need to test for gcda, since gcov assumes no execution
|
|
|
|
# if it's absent
|
2018-11-11 16:50:43 +01:00
|
|
|
rm -f "$GC"
|
|
|
|
gcov -o "$on" "$fn"
|
|
|
|
if [ -e "$GC" ]
|
2013-07-16 15:40:08 +02:00
|
|
|
then
|
2017-10-02 23:09:28 +02:00
|
|
|
if [ -d "$dst" ]
|
2013-07-16 15:40:08 +02:00
|
|
|
then
|
2018-11-11 16:50:43 +01:00
|
|
|
mv "$GC" "$dst"/"$GC"
|
2013-07-16 15:40:08 +02:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "gcov -o $on $fn didn't make a .gcov file"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Couldn't find gcno file for $on"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "No object file found matching source file $fn"
|
2013-07-16 07:33:39 +02:00
|
|
|
fi
|
2013-07-09 18:37:11 +02:00
|
|
|
done
|