#! /bin/sh # # show uncovered lines as errors # # # Copyright (C) 2007 Nokia Corporation # Contact: Pekka Pessi # Licensed under LGPL. See file COPYING. # usage() { test X$1 = X0 || exec >&2 cat < ${info} test -e ${info} || exit 1 { # remove system includes with with inlined functions lcov -q -l ${info} | grep -v "`cd ${srcdir:-.} && pwd`" # remove test programs lcov -q -l ${info} | grep "/test\|/torture\|_test[.]c$" } | cut -d: -f1 | xargs lcov -q -r ${info} > ${geninfo} && cd ${tdir} && genhtml -q --prefix=$cwd/ --output-directory . ${geninfo} && find . -name '*.gcov.html' | xargs perl -e ' while (<>) { if (m:]*>:) { $pre=1; } if ($pre && m:]*>:) { $pre=0; if ($uncovered) { print $uncovered; $uncovered = ""; } } if ($pre) { s/<[^>]+>//g; s/<//g; s/"/\"/g; s/&/&/g; if (m/^ *\d+ *[1-9]\d* :/) { if ($uncovered) { print $uncovered; $uncovered = ""; } } else { if ($uncovered) { if (m/^[^:]+: [{]/) { # Hack: show line number if line starts with { s/^ +(\d+)[^:]+:/$1:/; } else { s/^ +(\d+)[^:]+:/sprintf("%*s", 1 + length($1), " ")/e; } $uncovered .= $f . ":" . $_; } elsif (m/^ *\d+ *0 :/) { for ($f = $ARGV) { s:^[.]'$cwd/'::o; s:[.]gcov[.]html$::; } s/^ +(\d+)[^:]+:/$1:/; $uncovered = $f . ":" . $_; } } } } ' /dev/null rc=$? cd / rm -rf $tdir exit $rc