Bump to 0.4.3.7-dev
[tor.git] / scripts / test / coverage
blobf61c83bc72eaf87626f57053ea8066a3ba33b5ed
1 #!/bin/sh
2 # Copyright 2013 The Tor Project, Inc.
3 # See LICENSE for licensing information.
5 # coverage -- run gcov on the appropriate set of object files to extract
6 # coverage information.
8 dst=$1
10 for fn in src/core/*/*.c src/feature/*/*.c src/app/*/*.c src/lib/*/*.c; do
11 BN=$(basename "$fn")
12 DN=$(dirname "$fn")
13 F=$(echo "$BN" | sed -e 's/\.c$//;')
14 GC="${BN}.gcov"
15 # Figure out the object file names
16 ONS=$(echo "${DN}"/*testing_a-"${F}".o)
17 ONS_WILDCARD_LITERAL="${DN}/*testing_a-${F}.o"
18 # If the wildcard didn't expand, no files
19 if [ "$ONS" != "${ONS_WILDCARD_LITERAL}" ]
20 then
21 for on in $ONS; do
22 # We should have a gcno file
23 GCNO=$(echo "$on" | sed -e 's/\.o$/\.gcno/;')
24 if [ -e "$GCNO" ]
25 then
26 # No need to test for gcda, since gcov assumes no execution
27 # if it's absent
28 rm -f "$GC"
29 gcov -o "$on" "$fn"
30 if [ -e "$GC" ]
31 then
32 if [ -d "$dst" ]
33 then
34 mv "$GC" "$dst"/"$GC"
36 else
37 echo "gcov -o $on $fn didn't make a .gcov file"
39 else
40 echo "Couldn't find gcno file for $on"
42 done
43 else
44 echo "No object file found matching source file $fn"
46 done