tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

coverage (1313B)


      1 #!/bin/sh
      2 # Copyright 2013  The Tor Project, Inc.
      3 # See LICENSE for licensing information.
      4 
      5 # coverage -- run gcov on the appropriate set of object files to extract
      6 # coverage information.
      7 
      8 dst=$1
      9 
     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"
     35             fi
     36           else
     37             echo "gcov -o $on $fn didn't make a .gcov file"
     38           fi
     39         else
     40           echo "Couldn't find gcno file for $on"
     41         fi
     42       done
     43     else
     44       echo "No object file found matching source file $fn"
     45     fi
     46 done