1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#!/bin/sh
set -e
COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
test_coverage()
{
TESTING_COVERAGE=false make clean
mkdir -p $covdir
lcov --directory . --zerocounters -q
make check CFLAGS="$COVERAGE_CFLAGS"
lcov --compat-libtool --directory . --capture --output-file $covdir/app.info
TESTING_COVERAGE=true make clean
genhtml -o $covdir/ $covdir/app.info
set -x
firefox $covdir/index.html &
{ set +x; } 2> /dev/null
}
print_usage()
{
echo "Usage:"
echo "\t$0 run [outdir]" 2>&1
echo "\t$0 clean [outdir]" 2>&1
}
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
echo "Illegal number of parameters" 2>&1
print_usage
exit 1
fi
action=$1
covdir=${2:-coverage-results}
case $action in
"run")
test_coverage
;;
"clean")
test "x$TESTING_COVERAGE" = "xtrue" || rm -rf $covdir
;;
*)
echo "Illegal action: $action" 2>&1
print_usage
exit 1
esac
|