aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2022-08-22 17:28:37 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2023-02-17 17:59:50 +0100
commit2a83232e195af5434bfd8aaa7ec163b806405305 (patch)
tree5f55785691e933e53adbc7a879e24cf8657eb17d
parent779a4a63f94279eae6cb09475d777990fd9ceae6 (diff)
downloadhardware_replicant_libsamsung-ipc-2a83232e195af5434bfd8aaa7ec163b806405305.tar.gz
hardware_replicant_libsamsung-ipc-2a83232e195af5434bfd8aaa7ec163b806405305.tar.bz2
hardware_replicant_libsamsung-ipc-2a83232e195af5434bfd8aaa7ec163b806405305.zip
Add code coverage support
Usage: $ ./configure --enable-code-coverage-tests --enable-debug \ --enable-samsung-ipc-device=fifo [...] $ make check $ sudo make install [...] Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r--Makefile.am54
-rw-r--r--configure.ac33
-rw-r--r--scripts/manifest.scm2
3 files changed, 86 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am
index f5dcb1d..17c4ab2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,7 @@
NULL =
+EXTRA_DIST = $(NULL)
+
SUBDIRS = \
samsung-ipc \
samsung-ipc/tests \
@@ -11,7 +13,7 @@ SUBDIRS = \
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = samsung-ipc.pc
-EXTRA_DIST = \
+EXTRA_DIST += \
Android.mk \
android_versions.mk \
CONTRIBUTING \
@@ -29,6 +31,18 @@ MAINTAINERCLEANFILES = \
mkinstalldirs *~ \
$(NULL)
+################################################################################
+# Extra checks #
+################################################################################
+
+if WANT_CODE_COVERAGE
+check-local: build-code-coverage check-tarball-builds
+install-data-local: install-code-coverage
+clean-local: clean-code-coverage
+else # WANT_CODE_COVERAGE
+check-local: check-tarball-builds
+endif # WANT_CODE_COVERAGE
+
# With the next release of libsamsung-ipc, we will also release
# tarballs.
#
@@ -46,7 +60,7 @@ MAINTAINERCLEANFILES = \
# infinite recursion as a given test from a tarball would then spawn
# another build and test from a tarball which would then spawn again
# another build and test.
-check-local: dist
+check-tarball-builds: dist
if [ -d $(srcdir)/.git ] ; then \
BUILD_TMPDIR=`mktemp -d` && \
echo $$BUILD_TMPDIR && \
@@ -59,3 +73,39 @@ check-local: dist
make install DESTDIR=`realpath $$BUILD_TMPDIR/destdir` && \
rm -rf $$BUILD_TMPDIR ; \
fi
+
+#################
+# Code coverage #
+#################
+if WANT_CODE_COVERAGE
+
+CODE_COVERAGE_DIR = lcov
+
+EXTRA_DIST += $(CODE_COVERAGE_DIR)
+
+build-code-coverage:
+ lcov --compat-libtool --directory . --capture --output-file libsamsung-ipc.info
+ genhtml -o $(CODE_COVERAGE_DIR) libsamsung-ipc.info
+
+ BUILD_TMPDIR=$(mktemp -d) && \
+ cd ${BUILD_TMPDIR} && \
+ mkdir build destdir && \
+ tar xf $(srcdir)/libsamsung-ipc-$(VERSION).tar.xz && \
+ cd build && \
+ ../libsamsung-ipc-$(VERSION)/configure \
+ --enable-code-coverage-tests \
+ --enable-debug \
+ --enable-samsung-ipc-device=fifo \
+ make -j3 check \
+ make install DESTDIR=$(realpath ../destdir)
+
+install-code-coverage: check
+ install -d $(DESTDIR)/$(datadir)/libsamsung-ipc/$(CODE_COVERAGE_DIR)/
+ find $(srcdir)/$(CODE_COVERAGE_DIR) -type f | \
+ xargs -I src install -D src \
+ $(DESTDIR)/$(datadir)/libsamsung-ipc/$(CODE_COVERAGE_DIR)/
+
+clean-code-coverage:
+ rm -rf $(CODE_COVERAGE_DIR)
+
+endif # WANT_CODE_COVERAGE
diff --git a/configure.ac b/configure.ac
index f53a55d..8d84140 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,9 @@ AC_SUBST(STRICT_CFLAGS)
# python
AC_SUBST(PYTHON3)
AC_CHECK_PROG([PYTHON3], [python3], [python3])
-
+#------------------------------------------------------------------------------
+# code coverage
+AC_SUBST(CODE_COVERAGE)
#------------------------------------------------------------------------------
# valgrind
AC_SUBST(VALGRIND)
@@ -68,6 +70,27 @@ AM_CONDITIONAL( [WANT_STRICT_CFLAGS], [test x"$strict_cflags" = x"yes"])
# available values is valgrind, so it would be a good idea to convert to
# it for consistency across free software projects.
AC_ARG_ENABLE(
+ [code-coverage-tests],
+ [AS_HELP_STRING([--enable-code-coverage-tests],
+ [Build with --coverage, -O0 and use lcov from PATH during
+ tests (default=disabled)])],
+ [code_coverage_tests=$enableval],
+ [code_coverage="no"])
+
+AM_CONDITIONAL( [WANT_CODE_COVERAGE], [test x"$code_coverage_tests" = x"yes"])
+
+AS_IF([test x"code_coverage_tests" = x"yes"],
+ [AC_CHECK_PROG([CODE_COVERAGE], [lcov], [lcov])
+ AS_IF(
+ [test x"$VALGRIND" = x""],
+ [AC_MSG_ERROR(
+ [code coverage tests are enabled but lcov was not found in PATH ($PATH)])])])
+
+#------------------------------------------------------------------------------
+# TODO: GCC has --enable-checking= for extensive runtime checks and one of the
+# available values is valgrind, so it would be a good idea to convert to
+# it for consistency across free software projects.
+AC_ARG_ENABLE(
[valgrind-tests],
[AS_HELP_STRING([--enable-valgrind-tests],
[Build with -ggdb3, -O0 and use valgrind from PATH during
@@ -115,6 +138,12 @@ AS_IF([test x"$strict_cflags" = x"yes"],
AS_IF([test x"$valgrind_tests" = x"yes"], [: ${CFLAGS="-ggdb3 -O0"}],
[test x"$debug" = x"yes"], [: ${CFLAGS="-ggdb -O0"}], [])
+AS_IF([test x"$code_coverage_tests" = x"yes"],
+ [: ${LDFLAGS=" --coverage"}], [])
+
+AS_IF([test x"$code_coverage_tests" = x"yes"],
+ [ CFLAGS+=" --coverage"], [])
+
AC_PROG_CC
AM_PROG_CC_C_O
AC_GNU_SOURCE
@@ -136,6 +165,7 @@ echo
echo "Compiler flags:"
echo
echo " CFLAGS..................: $CFLAGS $STRICT_CFLAGS"
+echo " LDFLAGS.................: $LDFLAGS"
echo
echo
echo "Interpreters paths:"
@@ -153,6 +183,7 @@ echo " prefix..................: $prefix"
echo
echo " valgrind tests..........: $valgrind_tests"
echo
+echo " code coverage tests.....: $code_coverage_tests"
echo "------------------------------------------------------------------------"
echo
echo "Now type 'make' to compile and 'make install' to install this package."
diff --git a/scripts/manifest.scm b/scripts/manifest.scm
index afe4ca5..dfc82c7 100644
--- a/scripts/manifest.scm
+++ b/scripts/manifest.scm
@@ -23,6 +23,7 @@
(use-modules
(gnu packages autotools)
(gnu packages base)
+ (gnu packages code)
(gnu packages commencement)
(gnu packages compression)
(gnu packages curl)
@@ -46,6 +47,7 @@
gzip
gcc-toolchain
grep
+ lcov
libtool
gnu-make
openssl