[libdmapsharing] Wire coverage testing into make check
- From: W. Michael Petullo <wmpetullo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdmapsharing] Wire coverage testing into make check
- Date: Sat, 21 Jul 2018 17:00:15 +0000 (UTC)
commit 38fc523265ff68f519ce6d8d49316d2a23b438eb
Author: W. Michael Petullo <mike flyn org>
Date: Sat Jul 21 12:59:55 2018 -0400
Wire coverage testing into make check
Signed-off-by: W. Michael Petullo <mike flyn org>
configure.ac | 4 ++--
libdmapsharing/Makefile.am | 5 +++++
tests/summarize-coverage | 47 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0b35343..27365d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,9 +34,9 @@ AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug],[enable debugging build])])
AC_ARG_ENABLE(coverage, [AC_HELP_STRING([--enable-coverage],[enable code-coverage build])])
if test "x$enable_debug" = "xyes"; then
- CFLAGS="$CFLAGS -g"
+ CFLAGS="$CFLAGS -O0 -g"
elif test "x$enable_coverage" = "xyes"; then
- CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
+ CFLAGS="$CFLAGS -O0 -g -fprofile-arcs -ftest-coverage"
else
CFLAGS="$CFLAGS -O2"
fi
diff --git a/libdmapsharing/Makefile.am b/libdmapsharing/Makefile.am
index 28db6f7..e5995f6 100644
--- a/libdmapsharing/Makefile.am
+++ b/libdmapsharing/Makefile.am
@@ -202,6 +202,11 @@ CLEANFILES += $(gir_DATA) $(typelib_DATA)
endif
check:
+ ../tests/unit-test
+ set -e; for i in $(libdmapsharing_4_0_la_SOURCES); do \
+ gcov -r -o $(patsubst %.c,%.o,.libs/libdmapsharing_4_0_la-$$i) $$i > /dev/null; \
+ done
+ ../tests/summarize-coverage $(patsubst %,%.gcov,$(libdmapsharing_4_0_la_SOURCES))
if HAVE_PEDANSEE
echo "[flags]" > pedansee.conf
echo " skip-unit-test-present = true" >> pedansee.conf
diff --git a/tests/summarize-coverage b/tests/summarize-coverage
new file mode 100755
index 0000000..e6a12bd
--- /dev/null
+++ b/tests/summarize-coverage
@@ -0,0 +1,47 @@
+#!/usr/bin/awk -f
+
+BEGIN {
+ checked = 0
+ totalchecked = 0
+ unchecked = 0
+ totalunchecked = 0
+ irrelevant = 0
+ totalirrelevant = 0
+ argprev = 0
+ filenameprev = FILENAME
+}
+
+function printstats(name, checked, unchecked, irrelevant) {
+ total = checked + unchecked
+ if (total == 0) {
+ return
+ }
+ printf "%s: %d checked (%.2f%) %d unchecked (%.2f%) %d irrelevant\n",
+ name,
+ checked,
+ checked / total * 100,
+ unchecked,
+ unchecked / total * 100,
+ irrelevant
+}
+
+# Print and reset when file changes.
+# (Note that FILENAME already changed; hence filenameprev).
+{
+ if (ARGIND != argprev) {
+ printstats(filenameprev, checked, unchecked, irrelevant)
+ checked = unchecked = irrelevant = 0
+ argprev = ARGIND
+ filenameprev = FILENAME
+ }
+}
+
+/^ *[0-9]*:/ { checked++; totalchecked++ }
+/^ *#####:/ { unchecked++; totalunchecked++ }
+/^ *-:/ { irrelevant++; totalirrelevant++ }
+
+# Print statistics for last file and totals.
+END {
+ printstats(FILENAME, checked, unchecked, irrelevant)
+ printstats("total", totalchecked, totalunchecked, totalirrelevant)
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]