]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dovecot.m4: External plugins can now more easily run their tests via Valgrind.
authorTimo Sirainen <tss@iki.fi>
Tue, 10 Feb 2015 11:12:42 +0000 (13:12 +0200)
committerTimo Sirainen <tss@iki.fi>
Tue, 10 Feb 2015 11:12:42 +0000 (13:12 +0200)
DC_DOVECOT macro automatically adds RUN_TEST variable to Makefiles, which
can be used to call any test programs. If valgrind exists, the tests are run
through it. This is done by writing run-test.sh to the build directory, so
the original run-test.sh in hg is no longer needed.

.hgignore
configure.ac
dovecot.m4
run-test.sh [deleted file]

index 001e6d326fd64b160442e785dff4f797a711fec0..1f59d96f139802552b601d475e90de4d64c7ff05 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -36,6 +36,7 @@ dovecot-config.in
 ChangeLog
 Makefile
 Makefile.in
+run-test.sh
 
 *.o
 *.lo
index c0be7961633b12c41970528b673ad29a55d627fd..993c3aa47ed79990da2870ae270406cf4bafef26 100644 (file)
@@ -2816,13 +2816,7 @@ if test "$docdir" = ""; then
 fi
 AC_SUBST(docdir)
 
-AC_CHECK_PROG(VALGRIND, valgrind, yes, no)
-if test $VALGRIND = yes; then
-  RUN_TEST='$(SHELL) $(top_srcdir)/run-test.sh'
-else
-  RUN_TEST=''
-fi
-AC_SUBST(RUN_TEST)
+DC_DOVECOT_TEST_WRAPPER
 AC_SUBST(abs_top_builddir)
 
 AC_CONFIG_HEADERS([config.h])
index 0ac1e31266881649497f936f14e2832fd4285a8f..aea348af30d891d57e3d773458a317e8e5a990e7 100644 (file)
@@ -31,6 +31,35 @@ AC_DEFUN([DC_PLUGIN_DEPS],[
        unset _plugin_deps
 ])
 
+AC_DEFUN([DC_DOVECOT_TEST_WRAPPER],[
+  AC_CHECK_PROG(VALGRIND, valgrind, yes, no)
+  if test $VALGRIND = yes; then
+    cat > run-test.sh <<EOF
+#!/bin/sh
+top_srcdir=\$[1]
+shift
+
+trap "rm -f test.out.\$\$" 0 1 2 3 15
+supp_path="\$top_srcdir/run-test-valgrind.supp"
+if test -r "\$supp_path"; then
+  valgrind -q --suppressions="\$supp_path" --log-file=test.out.\$\$ \$[*]
+else
+  valgrind -q --log-file=test.out.\$\$ \$[*]
+fi
+ret=\$?
+if test -s test.out.\$\$; then
+  cat test.out.\$\$
+  exit 1
+fi
+exit \$ret
+EOF
+    RUN_TEST='$(SHELL) $(top_builddir)/run-test.sh $(top_srcdir)'
+  else
+    RUN_TEST=''
+  fi
+  AC_SUBST(RUN_TEST)
+])
+
 # Substitute every var in the given comma seperated list
 AC_DEFUN([AX_SUBST_L],[
        m4_foreach([__var__], [$@], [AC_SUBST(__var__)])
@@ -92,4 +121,5 @@ AC_DEFUN([DC_DOVECOT],[
        AX_SUBST_L([LIBDOVECOT_INCLUDE], [LIBDOVECOT_LDA_INCLUDE], [LIBDOVECOT_DOVEADM_INCLUDE], [LIBDOVECOT_SERVICE_INCLUDE], [LIBDOVECOT_STORAGE_INCLUDE], [LIBDOVECOT_LOGIN_INCLUDE], [LIBDOVECOT_CONFIG_INCLUDE], [LIBDOVECOT_IMAP_INCLUDE], [LIBDOVECOT_DSYNC_INCLUDE])
 
        DC_PLUGIN_DEPS
+       DC_DOVECOT_TEST_WRAPPER
 ])
diff --git a/run-test.sh b/run-test.sh
deleted file mode 100644 (file)
index 79ef56b..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-trap "rm -f test.out.$$" 0 1 2 3 15
-supp_path="`dirname $0`/run-test-valgrind.supp"
-if [ -r "$supp_path" ]; then
-  valgrind -q --suppressions="$supp_path" --log-file=test.out.$$ $*
-else
-  valgrind -q --log-file=test.out.$$ $*
-fi
-ret=$?
-if [ -s test.out.$$ ]; then
-  cat test.out.$$
-  exit 1
-fi
-exit $ret