summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2017-04-12 14:35:25 +0100
committerReuben Thomas <rrt@sc3d.org>2017-04-15 13:43:56 +0100
commit8049c870d19f436e3fda927886e1fb2287081bfe (patch)
tree7d12d20dd5569548985869e77547b68e456ae8a7
parentc867eba2423fd1d89c57cc2ca3324bf444650ef3 (diff)
downloadenchant-8049c870d19f436e3fda927886e1fb2287081bfe.tar.gz
Use valgrind-tests module to run tests under Valgrind
Had to patch valgrind-tests.m4 to work around false positive in bash. See https://lists.gnu.org/archive/html/bug-bash/2017-04/msg00038.html Also add a suppressions file for relocatable.c.
-rw-r--r--.travis.yml1
-rw-r--r--bootstrap.conf1
-rw-r--r--gl/build-aux/relocatable.supp8
-rw-r--r--gl/m4/valgrind-tests.m437
-rw-r--r--gl/modules/relocatable-lib-lgpl31
-rw-r--r--m4/.gitignore1
-rw-r--r--m4/gnulib-cache.m43
-rw-r--r--tests/.gitignore6
-rw-r--r--tests/Makefile.am5
-rwxr-xr-xtests/run-test3
10 files changed, 94 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml
index 2b8dcdd..8780b45 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,6 +15,7 @@ addons:
- libvoikko-dev
- aspell-en
- libunittest++-dev
+ - valgrind
- g++-5
env:
diff --git a/bootstrap.conf b/bootstrap.conf
index fc296ad..5d327b0 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -52,6 +52,7 @@ gnulib_modules='
snippet/unused-parameter
strdup-posix
ssize_t
+ valgrind-tests
'
diff --git a/gl/build-aux/relocatable.supp b/gl/build-aux/relocatable.supp
new file mode 100644
index 0000000..c3dfeff
--- /dev/null
+++ b/gl/build-aux/relocatable.supp
@@ -0,0 +1,8 @@
+# set_this_relocation_prefix leaks intentionally
+{
+ relocatable/set_this_relocation_prefix
+ Memcheck:Leak
+ fun:malloc
+ fun:set_this_relocation_prefix
+ fun:set_relocation_prefix
+}
diff --git a/gl/m4/valgrind-tests.m4 b/gl/m4/valgrind-tests.m4
new file mode 100644
index 0000000..5ccf9dc
--- /dev/null
+++ b/gl/m4/valgrind-tests.m4
@@ -0,0 +1,37 @@
+# valgrind-tests.m4 serial 3
+dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Simon Josefsson
+
+# gl_VALGRIND_TESTS()
+# -------------------
+# Check if valgrind is available, and set VALGRIND to it if available.
+AC_DEFUN([gl_VALGRIND_TESTS],
+[
+ AC_ARG_ENABLE(valgrind-tests,
+ AS_HELP_STRING([--disable-valgrind-tests],
+ [don't try to run self tests under valgrind]),
+ [opt_valgrind_tests=$enableval], [opt_valgrind_tests=yes])
+
+ # Run self-tests under valgrind?
+ if test "$opt_valgrind_tests" = "yes" && test "$cross_compiling" = no; then
+ AC_CHECK_PROGS(VALGRIND, valgrind)
+ fi
+
+ OPTS="-q --error-exitcode=1 --leak-check=full"
+
+ if test -n "$VALGRIND" \
+ && $VALGRIND $OPTS ls > /dev/null 2>&1; then
+ opt_valgrind_tests=yes
+ VALGRIND="$VALGRIND $OPTS"
+ else
+ opt_valgrind_tests=no
+ VALGRIND=
+ fi
+
+ AC_MSG_CHECKING([whether self tests are run under valgrind])
+ AC_MSG_RESULT($opt_valgrind_tests)
+])
diff --git a/gl/modules/relocatable-lib-lgpl b/gl/modules/relocatable-lib-lgpl
new file mode 100644
index 0000000..0783864
--- /dev/null
+++ b/gl/modules/relocatable-lib-lgpl
@@ -0,0 +1,31 @@
+Description:
+Help make libraries relocatable, that is, to allow them to function
+properly when copied to an arbitrary directory.
+
+Files:
+build-aux/relocatable.supp
+doc/relocatable.texi
+lib/relocatable.h
+lib/relocatable.c
+m4/relocatable-lib.m4
+
+Depends-on:
+strdup
+
+configure.ac:
+gl_RELOCATABLE_LIBRARY
+if test $RELOCATABLE = yes; then
+ AC_LIBOBJ([relocatable])
+fi
+
+Makefile.am:
+DEFS += -DNO_XMALLOC
+
+Include:
+"relocatable.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+Ben Pfaff
diff --git a/m4/.gitignore b/m4/.gitignore
index 484f97f..d8e1c17 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -51,3 +51,4 @@
/strerror.m4
/sys_socket_h.m4
/configmake.m4
+/valgrind-tests.m4
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index bb8b0b3..13f1e7c 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -27,7 +27,7 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --local-dir=gl --local-dir=gl-mod/bootstrap --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --libtool --macro-prefix=gl alloca bootstrap configmake flock manywarnings relocatable-lib-lgpl snippet/unused-parameter ssize_t strdup-posix
+# gnulib-tool --import --local-dir=gl --local-dir=gl-mod/bootstrap --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --libtool --macro-prefix=gl alloca bootstrap configmake flock manywarnings relocatable-lib-lgpl snippet/unused-parameter ssize_t strdup-posix valgrind-tests
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([gl:gl-mod/bootstrap])
@@ -41,6 +41,7 @@ gl_MODULES([
snippet/unused-parameter
ssize_t
strdup-posix
+ valgrind-tests
])
gl_AVOID([])
gl_SOURCE_BASE([lib])
diff --git a/tests/.gitignore b/tests/.gitignore
index f1ba630..4339167 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -8,3 +8,9 @@
libenchant_*.so
libenchant_*.dylib
*enchant*.dll
+/_Noreturn.h
+/arg-nonnull.h
+/c++defs.h
+/dummy.c
+/unused-parameter.h
+/warn-on-use.h
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 723dc2a..101e23f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -7,6 +7,8 @@ ENCHANT_CONFIG_DIR = config
# FIXME: Duplication of LIBENCHANT_COPY actions
AM_TESTS_ENVIRONMENT = \
export ENCHANT_CONFIG_DIR=$(ENCHANT_CONFIG_DIR); \
+ if test -n "$(VALGRIND)"; then export VALGRIND='$(VALGRIND) --suppressions=$(top_srcdir)/build-aux/relocatable.supp'; fi; \
+ export LIBTOOL=$(top_builddir)/libtool; \
rm -rf test.pwl $(libdir_subdir); \
mkdir -p $(libdir_subdir)/enchant; \
cp -r $(top_builddir)/src/@objdir@ $(libdir_subdir)/; \
@@ -23,7 +25,7 @@ DISTCLEANFILES = test.pwl *@shlibext@
distclean-local:
rm -rf $(libdir_subdir) $(ENCHANT_CONFIG_DIR)
-EXTRA_DIST = test.pwl.orig mock_provider.h
+EXTRA_DIST = test.pwl.orig mock_provider.h run-test
LIBENCHANT_COPY = $(builddir)/$(libdir_subdir)/libenchant.la
$(LIBENCHANT_COPY): $(top_builddir)/src/libenchant.la
@@ -68,6 +70,7 @@ libenchant_null_describe_la_LDFLAGS = $(libenchant_mock_provider_la_LDFLAGS)
libenchant_null_describe_la_SOURCES = $(libenchant_mock_provider_la_SOURCES)
check_PROGRAMS = enchant.test enchantxx.test main
+LOG_COMPILER = $(srcdir)/run-test
enchant_test_SOURCES = enchant.test.c
enchantxx_test_SOURCES = enchantxx.test.cpp
diff --git a/tests/run-test b/tests/run-test
new file mode 100755
index 0000000..2e26f3f
--- /dev/null
+++ b/tests/run-test
@@ -0,0 +1,3 @@
+#!/bin/sh
+# Run the given binary via a libtool wrapper script
+$LIBTOOL --mode=execute $VALGRIND "$@"