summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rw-r--r--test/Makefile.am18
-rw-r--r--test/functions.in22
-rwxr-xr-x[-rw-r--r--]test/runtests (renamed from test/runtests.in)9
-rw-r--r--test/tests/dsn2
-rw-r--r--test/tests/mailq4
-rw-r--r--test/tests/send2
-rw-r--r--test/tests/smtpd1
8 files changed, 33 insertions, 28 deletions
diff --git a/Makefile.am b/Makefile.am
index b952ee0..52cd654 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -29,6 +29,3 @@ install-root:
dist-hook:
sed -e s/@VERSION\@/@VERSION@/ \
<$(srcdir)/spec >$(distdir)/nullmailer-@VERSION@.spec
-
-tests: all
- $(MAKE) -C test test
diff --git a/test/Makefile.am b/test/Makefile.am
index a0f999b..6a062cb 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,7 +1,8 @@
noinst_PROGRAMS = address-test argparse-test clitest0 clitest1
-EXTRA_DIST = address-trace.cc clitest.cc clitest.sh runtests.in
-noinst_SCRIPTS = runtests
-CLEANFILES = runtests
+EXTRA_DIST = address-trace.cc clitest.cc clitest.sh functions.in runtests \
+ accept-qmqp.sh accept-smtp.sh
+noinst_SCRIPTS = functions
+CLEANFILES = functions
AM_CPPFLAGS = -I$(top_srcdir)/lib
@@ -19,17 +20,16 @@ clitest1_CPPFLAGS = $(AM_CPPFLAGS) -DCLI_ONLY_LONG=true
clitest1_SOURCES = clitest.cc
clitest1_LDADD = ../lib/libnullmailer.a ../lib/cli++/libcli++.a
-runtests: runtests.in Makefile
- sed -e 's,[@]SRCDIR[@],$(abs_top_srcdir),g;' < $< > $@
- chmod +x $@
+functions: functions.in Makefile
+ sed -e 's,[@]SRCDIR[@],$(abs_top_srcdir),g; s,[@]BUILDDIR[@],$(abs_top_builddir),g;' < $< > $@
# The following makes sure that we can't produce a package without the
# tests executing properly
dist-hook:
cp -r $(srcdir)/tests $(distdir)
-test: all
+check: all
./address-test
./argparse-test
- sh clitest.sh
- ./runtests `find tests -type f -not -name '.*'`
+ sh $(srcdir)/clitest.sh
+ $(srcdir)/runtests `find $(abs_srcdir)/tests -type f -not -name '.*'`
diff --git a/test/functions.in b/test/functions.in
index 2e2240e..0ce02bd 100644
--- a/test/functions.in
+++ b/test/functions.in
@@ -1,16 +1,29 @@
+#!/bin/bash
srcdir=@SRCDIR@
-tmpdir=$srcdir/test-tmp
+builddir=@BUILDDIR@
+tmpdir=$builddir/test-tmp
export NULLMAILER_TEST_PREFIX=$tmpdir
SYSCONFDIR=$tmpdir/conf
QUEUEDIR=$tmpdir/queue
rm -rf $tmpdir
mkdir -p \
+ $tmpdir/protocols \
$QUEUEDIR/{failed,queue,tmp} \
$SYSCONFDIR
mknod $QUEUEDIR/trigger p
-ln -s $srcdir/src $tmpdir/sbin
-ln -s $srcdir/src $tmpdir/bin
-ln -s $srcdir/src $tmpdir/protocols
+ln -s $builddir/src $tmpdir/sbin
+ln -s $builddir/src $tmpdir/bin
+ln -s $builddir/protocols/* $tmpdir/protocols/
+
+exit_cleanup() {
+ svc -dx $tmpdir/service/* > /dev/null 2>&1 || :
+ # Remove all temporary files on success
+ if [ $? -eq 0 ]
+ then
+ rm -rf $tmpdir
+ fi
+}
+trap exit_cleanup EXIT
fail() {
echo "$*"
@@ -26,7 +39,6 @@ start() {
} >$tmpdir/service/$name/run
chmod +x $tmpdir/service/$name/run
supervise $tmpdir/service/$name </dev/null >$tmpdir/service/${name}-log 2>&1 &
- trap 'svc -dx $tmpdir/service/* >/dev/null 2>&1' EXIT
}
stop() {
for name in $*; do
diff --git a/test/runtests.in b/test/runtests
index 14e7251..dcf9c31 100644..100755
--- a/test/runtests.in
+++ b/test/runtests
@@ -1,9 +1,5 @@
#!/bin/sh
-SRCDIR="@SRCDIR@"
-
-cd "$(dirname "$0")" || exit 1
-
-sed -e "s,[@]SRCDIR[@],$SRCDIR,g;" < functions.in > functions
+set -e
failed=0
for test in $*
@@ -14,7 +10,8 @@ do
echo 'Done.'
else
echo '******************************Failed!******************************'
- failed=1
+ failed=$(( $failed + 1 ))
fi
done 2>&1
+echo "$# tests run, $failed failed"
exit $failed
diff --git a/test/tests/dsn b/test/tests/dsn
index e615eb3..5007351 100644
--- a/test/tests/dsn
+++ b/test/tests/dsn
@@ -2,7 +2,7 @@
msgid=message.id.$$.$RANDOM@f.q.d.n
dsn() {
- $srcdir/src/nullmailer-dsn "$@" << EOF
+ $builddir/src/nullmailer-dsn "$@" << EOF
sender@example.com
recip1@example.net
recip2@example.org
diff --git a/test/tests/mailq b/test/tests/mailq
index eb9cc8f..0c50ba6 100644
--- a/test/tests/mailq
+++ b/test/tests/mailq
@@ -3,8 +3,8 @@
echo "Testing the output of the mailq command"
echo To: nobody@nowhere | inject
-$srcdir/src/mailq | head -n 1 | egrep -q '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [0-9]+ bytes from <.*>$' \
+$builddir/src/mailq | head -n 1 | egrep -q '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [0-9]+ bytes from <.*>$' \
|| { echo "Header is misformatted."; exit 1; }
-$srcdir/src/mailq | tail -n 1 | egrep -q '^ to <nobody@nowhere.q.d.n>$' \
+$builddir/src/mailq | tail -n 1 | egrep -q '^ to <nobody@nowhere.q.d.n>$' \
|| { echo "Recipient is misformatted."; exit 1; }
diff --git a/test/tests/send b/test/tests/send
index fd68156..38496a5 100644
--- a/test/tests/send
+++ b/test/tests/send
@@ -14,7 +14,7 @@ chmod +x $tmpdir/protocols/dummy
echo 127.0.0.1 smtp >$SYSCONFDIR/remotes
# Start up the servers
-start send $srcdir/src/nullmailer-send
+start send $builddir/src/nullmailer-send
make_message() {
msgid=$(date +%s).$$.me
diff --git a/test/tests/smtpd b/test/tests/smtpd
index 59ca303..ff326e1 100644
--- a/test/tests/smtpd
+++ b/test/tests/smtpd
@@ -3,7 +3,6 @@
echo "Testing the nullmailer-smtpd program"
out=$tmpdir/smtpd.out.$$
-trap 'rm -f $out' EXIT
smtpd <<EOF 2>&1 | cat -v >$out
HELO