[git] KSBA - branch, master, updated. libksba-1.3.5-9-g3e029a4

by Kai Michaelis cvs at cvs.gnupg.org
Thu Aug 10 15:59:45 CEST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "KSBA is a library to access X.509 certificates and CMS data.".

The branch, master has been updated
       via  3e029a4ed0059116febe05924a14009ca622e3c5 (commit)
      from  ad36a28e3a0580c1a9547843c03e1af172681efc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3e029a4ed0059116febe05924a14009ca622e3c5
Author: Kai Michaelis <kai at gnupg.org>
Date:   Wed Aug 9 18:02:06 2017 +0200

    Generate coverage information.
    
    * autogen.sh: add options --coverage and --report to help w/ coverage
    info collection and reporting.
    * m4/gcov.m4: new file. Boilerplate for locating gcov et.al.
    * Makefile.am: add coverage-report target
    
    GnuPG-Bud-Id: 3050
    --
    To measure test coverage gcov and lcov needs to be installed and
    ./configure called w/ --enable-gcov. The coverage-html make target will
    then create a HTML report.

diff --git a/Makefile.am b/Makefile.am
index a19c382..f188cda 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -79,3 +79,25 @@ gen-ChangeLog:
 
 stowinstall:
 	$(MAKE) $(AM_MAKEFLAGS) install prefix=/usr/local/stow/libksba
+
+# Coverage targets
+if HAVE_GCOV
+
+.PHONY: clean-coverage
+clean-coverage:
+	@echo Removing old coverage results
+	-find -name '*.gcda' -print | xargs -r rm
+	-find -name '*.gcno' -print | xargs -r rm
+	-rm -rf coverage.info coveragereport
+
+.PHONY: coverage-html clean-coverage
+coverage-html: check
+	@echo Collecting coverage data with lcov
+	$(top_srcdir)/autogen.sh --coverage $(LCOV) $(GCOV) $(abs_builddir) \
+		tests src
+	$(top_srcdir)/autogen.sh --report $(LCOV) $(GENHTML) $(abs_builddir) \
+		'*/tests/*' '*/asn1-parse.c' '*/asn1-parse.y'
+
+clean-local: clean-coverage
+
+endif # HAVE_GCOV
diff --git a/autogen.sh b/autogen.sh
index 7effd56..3771c58 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -171,6 +171,14 @@ case "$1" in
         fatal "**Error**: invalid build option $1"
         shift
         ;;
+    --coverage)
+        myhost="coverage"
+        shift
+        ;;
+    --report)
+        myhost="report"
+        shift
+        ;;
     *)
         ;;
 esac
@@ -239,6 +247,62 @@ if [ "$myhost" = "find-version" ]; then
 fi
 # **** end FIND VERSION ****
 
+# **** COVERAGE ****
+# This is a helper for the code coverage collection
+# Called
+#   ./autogen.sh --coverage lcov gcov [dirs...]
+if [ "$myhost" = "coverage" ]; then
+  LCOV="$1"
+  GCOV="$2"
+  BASE=`realpath "$3"`
+  COVINFO=""
+
+  shift 3
+
+  while [ x"$1" != "x" ]; do
+    P="$1"
+    $LCOV --gcov-tool $GCOV \
+          --base-directory "$BASE"/"$P" \
+          --directory "$P" \
+          --output-file coverage.info.`basename "$P"` \
+          --capture --no-checksum --compat-libtool \
+          --rc lcov_branch_coverage=1
+    COVINFO="$COVINFO -a coverage.info."`basename "$P"`
+    shift
+  done
+
+  $LCOV $COVINFO --base-directory "$BASE" --output-file coverage.info \
+          --no-checksum \
+          --rc lcov_branch_coverage=1
+
+  exit 0
+fi
+# **** end COVERAGE ****
+
+# **** COVERAGE_REPORT ****
+# This is a helper for the code coverage report
+# Called
+#   ./autogen.sh --report lcov genhtml [exclude...]
+if [ "$myhost" = "report" ]; then
+  LCOV="$1"
+  GENHTML="$2"
+
+  shift 2
+
+  while [ x"$1" != "x" ]; do
+    P="$1"
+    $LCOV --remove coverage.info "$P" -o coverage.info \
+          --rc lcov_branch_coverage=1
+    shift
+  done
+
+  LANG=C $GENHTML --output-directory coveragereport --title "Code Coverage" \
+                  --legend --show-details coverage.info \
+                  --rc lcov_branch_coverage=1
+
+  exit 0
+fi
+# **** end COVERAGE_REPORT ****
 
 if [ ! -f "$tsdir/build-aux/config.guess" ]; then
     fatal "$tsdir/build-aux/config.guess not found"
diff --git a/configure.ac b/configure.ac
index d3a0fd6..d66e270 100644
--- a/configure.ac
+++ b/configure.ac
@@ -127,6 +127,14 @@ gl_EARLY
 AC_PROG_YACC
 AX_PROG_BISON([have_bison=yes],[have_bison=no])
 
+if test "$USE_MAINTAINER_MODE" = "yes"; then
+	# gcov coverage reporting
+	AC_CHECK_PROGS(GCOV, [gcov], gcov)
+	AC_TDD_GCOV
+	AC_SUBST(COVERAGE_CFLAGS)
+	AC_SUBST(COVERAGE_LDFLAGS)
+fi
+
 AC_C_INLINE
 
 # We need to compile and run a program on the build machine.
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 6078d25..fdbffdd 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -1,5 +1,5 @@
 
 EXTRA_DIST = autobuild.m4  gnupg-typedef.m4  gpg-error.m4  libgcrypt.m4 \
-             libtool.m4 ax_prog_bison.m4
+             libtool.m4 ax_prog_bison.m4 gcov.m4
 
 
diff --git a/m4/gcov.m4 b/m4/gcov.m4
new file mode 100644
index 0000000..ad1d3ec
--- /dev/null
+++ b/m4/gcov.m4
@@ -0,0 +1,93 @@
+# Copyright 2012 Canonical Ltd.
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 3, as published
+# by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranties of
+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+# PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Checks for existence of coverage tools:
+#  * gcov
+#  * lcov
+#  * genhtml
+#  * gcovr
+#
+# Sets ac_cv_check_gcov to yes if tooling is present
+# and reports the executables to the variables LCOV, GCOVR and GENHTML.
+AC_DEFUN([AC_TDD_GCOV],
+[
+  AC_ARG_ENABLE(gcov,
+  AS_HELP_STRING([--enable-gcov],
+		 [enable coverage testing with gcov]),
+  [use_gcov=yes], [use_gcov=no])
+
+  AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes")
+
+  if test "x$use_gcov" = "xyes"; then
+  # we need gcc:
+  if test "$GCC" != "yes"; then
+    AC_MSG_ERROR([GCC is required for --enable-gcov])
+  fi
+
+  # Check if ccache is being used
+  AC_CHECK_PROG(SHTOOL, shtool, shtool)
+  if test "$SHTOOL"; then
+    AS_CASE([`$SHTOOL path $CC`],
+                [*ccache*], [gcc_ccache=yes],
+                [gcc_ccache=no])
+  fi
+
+  if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
+    AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
+  fi
+
+  lcov_version_list="1.6 1.7 1.8 1.9 1.10 1.11 1.12 1.13"
+  AC_CHECK_PROG(LCOV, lcov, lcov)
+  AC_CHECK_PROG(GENHTML, genhtml, genhtml)
+
+  if test "$LCOV"; then
+    AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
+      glib_cv_lcov_version=invalid
+      lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
+      for lcov_check_version in $lcov_version_list; do
+        if test "$lcov_version" = "$lcov_check_version"; then
+          glib_cv_lcov_version="$lcov_check_version (ok)"
+        fi
+      done
+    ])
+  else
+    lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
+    AC_MSG_ERROR([$lcov_msg])
+  fi
+
+  case $glib_cv_lcov_version in
+    ""|invalid[)]
+      lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
+      AC_MSG_ERROR([$lcov_msg])
+      LCOV="exit 0;"
+      ;;
+  esac
+
+  if test -z "$GENHTML"; then
+    AC_MSG_ERROR([Could not find genhtml from the lcov package])
+  fi
+
+  # Remove all optimization flags from CFLAGS
+  changequote({,})
+  CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
+  CPPFLAGS=`echo "$CPPFLAGS" | $SED -e 's/-O[0-9]*//g'`
+  changequote([,])
+
+  # Add the special gcc flags
+  COVERAGE_CFLAGS="--coverage -DDEBUG"
+  COVERAGE_CXXFLAGS="--coverage -DDEBUG"
+  COVERAGE_LDFLAGS="--coverage -lgcov"
+
+fi
+]) # AC_TDD_GCOV
diff --git a/src/Makefile.am b/src/Makefile.am
index 7e3f06b..e8a5692 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,7 +36,7 @@ CLEANFILES = asn1-gentables
 DISTCLEANFILES = asn1-tables.c
 
 AM_CPPFLAGS =  -I$(top_builddir)/gl -I$(top_srcdir)/gl
-AM_CFLAGS = $(GPG_ERROR_CFLAGS)
+AM_CFLAGS = $(GPG_ERROR_CFLAGS) $(COVERAGE_CFLAGS)
 
 
 if HAVE_LD_VERSION_SCRIPT
@@ -82,7 +82,8 @@ endif !HAVE_W32_SYSTEM
 
 libksba_la_LDFLAGS = $(no_undefined) $(export_symbols) $(extra_ltoptions) \
       $(libksba_version_script_cmd) -version-info \
-      @LIBKSBA_LT_CURRENT@:@LIBKSBA_LT_REVISION@:@LIBKSBA_LT_AGE@
+      @LIBKSBA_LT_CURRENT@:@LIBKSBA_LT_REVISION@:@LIBKSBA_LT_AGE@ \
+      $(COVERAGE_LDFLAGS)
 libksba_la_INCLUDES = -I$(top_srcdir)/lib
 libksba_la_DEPENDENCIES = $(srcdir)/libksba.vers $(ksba_deps)
 libksba_la_LIBADD = $(ksba_res) @LTLIBOBJS@ @GPG_ERROR_LIBS@
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 949a812..9652674 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -41,8 +41,8 @@ CLEANFILES = oidtranstbl.h
 
 TESTS = cert-basic t-crl-parser t-dnparser t-oid t-reader
 
-AM_CFLAGS = $(GPG_ERROR_CFLAGS)
-AM_LDFLAGS = -no-install
+AM_CFLAGS = $(GPG_ERROR_CFLAGS) $(COVERAGE_CFLAGS)
+AM_LDFLAGS = -no-install $(COVERAGE_LDFLAGS)
 
 noinst_HEADERS = t-common.h
 noinst_PROGRAMS = $(TESTS) t-cms-parser t-crl-parser t-dnparser t-ocsp

-----------------------------------------------------------------------

Summary of changes:
 Makefile.am       | 22 +++++++++++++
 autogen.sh        | 64 ++++++++++++++++++++++++++++++++++++++
 configure.ac      |  8 +++++
 m4/Makefile.am    |  2 +-
 m4/gcov.m4        | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am   |  5 +--
 tests/Makefile.am |  4 +--
 7 files changed, 193 insertions(+), 5 deletions(-)
 create mode 100644 m4/gcov.m4


hooks/post-receive
-- 
KSBA is a library to access X.509 certificates and CMS data.
http://git.gnupg.org




More information about the Gnupg-commits mailing list