coverage 1.2 KB

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