#!/bin/bash if [ ! -d coverage ]; then mkdir coverage fi cd coverage # It would be really nice to find a better way to do this than copying the # HTML into this script. But, I am being lazy right now. cat > index.html << EOF Test Coverage

The Apache Portable Runtime Project

ApacheCon

Get Involved

  • CVS
  • Mailing Lists
  • Snapshots
  • Build on Win32
  • Build on Unix
  • Download!

  • from a mirror
  • Docs

  • APR
  • APR-util
  • APR-iconv
  • Guidelines

  • Project Guidelines
  • Contributing
  • Version Numbers
  • Miscellaneous

  • License
  • Projects using APR
  • APR Test Coverage

    This should give us some idea of how well our tests actually stress our code. To generate this data, do the following:

  • ./buildconf
  • CFLAGS="-fprofile-arcs -ftest-coverage ./configure
  • make
  • cd test
  • make
  • ./testall
  • cd ..
  • make gcov
  • Note that this will only generate test coverage data for the testall script, but all tests should be moving to the unified framework, so this is correct.

    EOF # Remind current dir, so that we can easily navigate in directories pwd=`pwd` # gcno files are created at compile time and gcna files at run-time for i in `find ../.. -name "*.gcno" | sort`; do # Skip test files if [[ "$i" =~ "test" ]]; then continue fi # We are only intested in gcno files in .libs directories, because it there # that we'll also find some gcna files if ! [[ "$i" =~ "libs" ]]; then continue fi # Find the directory and base name of this gcno file dir=`dirname -- "$i"` basename=`basename "$i"` filename="${basename%.*}" # Go to this directory cd $dir # Get the % of test coverage for each of this file percent=`gcov $filename.gcda | grep "%" | awk -F'%' {'print $1'} | awk -F':' {'print $2'}` # Come back to our base directory cd $pwd # Process the data we have collected if [ "x$percent" = "x" ]; then echo "" >> index.html echo "" >> index.html echo "" >> index.html continue; fi intpercent=`echo "$percent/1" | bc` if [[ $intpercent -lt 33 ]]; then color="#ffaaaa" else if [[ $intpercent -lt 66 ]]; then color="#ffff77" else color="#aaffaa" fi fi echo "" >> index.html echo "" >> index.html echo "" >> index.html echo "" >> index.html done echo "
    Error generating data for $filename
    $filename$percent% tested

    Last generated `date`

    " >> index.html cat >> index.html << EOF

    Copyright © 1999-2004, The Apache Software Foundation
    EOF