Commit 250c6a4b authored by Pekka Pessi's avatar Pekka Pessi

Added make target for calculating coverage.

darcs-hash:20051003154958-65a35-a5b676be84c809a58edad963a1fac0438103b626.gz
parent a6aa5151
......@@ -31,8 +31,12 @@ libsofia_sip_ua_la_LIBADD = bnf/bnf_objs.o \
url/url_objs.o \
${tls_objs}
if ENABLE_COVERAGE
COVERAGE_RECURSIVE = coverage-recursive
endif
all-recursive: built-sources-recursive
built-sources: built-sources-recursive
built-sources: built-sources-recursive $(COVERAGE_RECURSIVE)
built-sources-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making build-sources-recursive in $$subdir"; \
......
......@@ -12,3 +12,8 @@ $(srcdir)/*_tag_ref.c: $(TAG_AWK)
$(srcdir)/%_tag_ref.c: $(srcdir)/%_tag.c
$(AWK) -f $(TAG_AWK) NODLL=1 $(TAG_DLL_FLAGS) $<
if ENABLE_COVERAGE
coverage: check
$(srcdir)/../testutils/coverage $(COVERAGE_INPUT)
endif
......@@ -66,6 +66,8 @@ libsu_a_SOURCES = \
su_objs_o_SOURCES = $(libsu_a_SOURCES)
su_objs_o_LDADD =
COVERAGE_INPUT = $(su_objs_o_SOURCES) torture_su_memmem.c
LDADD = libsu.a $(GLIB_LIBS)
if NDEBUG
......
#!/bin/sh
#
# Calculate coverage of source files
#
# $Id: calculate-coverage,v 1.1 2005/08/26 09:58:34 ppessi Exp $
#
{
for f
do
case "$f" in
*.c ) gcov -n "$f" 2>/dev/null ;;
esac
done
} |
awk '
BEGIN { i=1; }
/^File/ {
if (sub(/^File `\/home\/ppessi\/sofia-proxy\/(proxy\/..\/)?/, "")) {
sub(/.$/, "");
file=$0;
if (file ~ /torture/) file = "";
}
else
file = "";
}
file ~ /\.c$/ && /Lines executed/ {
sub(/Lines executed:/, "");
covered = int($3*$1/100 + 0.5);
# printf "%-5u %-5u %-5u %-7s %s\n", $3, covered, $3 - covered, $1, file;
if ($3 == 0) {
/* skip */
}
else if (!lines[file]) {
names[i++] = file; lines[file] = $3; coverage[file] = covered;
coverage[file] = $3*$1/100;
}
else if (coverage[file] < covered) {
lines[file] = $3; coverage[file] = covered;
coverage[file] = $3*$1/100;
}
}
/torture/ { next; } /test/ { next; }
/source lines executed in file [-A-Za-z_0-9]+\.c/ {
file = $9;
sub(/lines executed/, "");
# covered = int($3*$1/100 + 0.5);
# printf "%-5u %-5u %-5u %-7s %s\n", $3, covered, $3 - covered, $1, file;
if ($3 == 0) {
/* skip */
}
else if (!lines[file]) {
names[i++] = file;
lines[file] = $3; coverage[file] = $3*$1/100;
}
else if (coverage[file] < covered) {
lines[file] = $3; coverage[file] = $3*$1/100;
}
}
END {
for (j=1; j < i; j++) {
file = names[j];
l = lines[file]; c = coverage[file];
covered = int(c + 0.5);
total += l; total_coverage += c;
printf "%-5u %-5u %-5u %6.2f%% %s\n",
l, covered, l - covered, 100.0 * c / l, file;
}
if (total) {
printf "%-5u %-5u %-5u %6.2f%% %s\n",
total, total_coverage, total - total_coverage,
100.0 * total_coverage / total, "TOTAL";
}
}
'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment