summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-10-14 17:21:35 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-10-14 17:21:35 +0300
commitdcf58c57acf3f817d9a0d17fae5052f39390fb90 (patch)
tree65f8ec6c6174426a8753c65a1884b1c42fbce7cb
parent19cdb79424d5580720444bf383a4c385f72d4052 (diff)
downloadmailutils-dcf58c57acf3f817d9a0d17fae5052f39390fb90.tar.gz
mailutils-dcf58c57acf3f817d9a0d17fae5052f39390fb90.tar.bz2
Restore mda tests
* mda/mda.c: Instrument for compilation for the testsuite. * mda/tests/.gitignore: Add testmda * mda/tests/Makefile.am: Build testmda. Add new tests. * mda/tests/forward.at: New test. * mda/tests/mda.at: New test. * mda/tests/testsuite.at: Include new tests.
-rw-r--r--mda/mda.c19
-rw-r--r--mda/tests/.gitignore1
-rw-r--r--mda/tests/Makefile.am35
-rw-r--r--mda/tests/forward.at90
-rw-r--r--mda/tests/mda.at59
-rw-r--r--mda/tests/testsuite.at6
6 files changed, 209 insertions, 1 deletions
diff --git a/mda/mda.c b/mda/mda.c
index 89951b8f6..151df644f 100644
--- a/mda/mda.c
+++ b/mda/mda.c
@@ -73,6 +73,17 @@ struct mu_cli_setup cli = {
N_("[recipient...]"),
};
+static void
+version_hook (struct mu_parseopt *po, mu_stream_t stream)
+{
+ mu_version_hook (po, stream);
+#if defined(TESTSUITE_CONFIG_FILE)
+ mu_stream_printf (stream, "%s\n",
+ _("THIS BINARY IS COMPILED ONLY FOR TESTING MAILUTILS."
+ " DON'T USE IT IN PRODUCTION!"));
+#endif
+}
+
int
main (int argc, char **argv)
{
@@ -119,13 +130,19 @@ main (int argc, char **argv)
pohint.po_extra_info = mu_general_help_text;
pohint.po_flags |= MU_PARSEOPT_EXTRA_INFO;
- pohint.po_version_hook = mu_version_hook;
+ pohint.po_version_hook = version_hook;
pohint.po_flags |= MU_PARSEOPT_VERSION_HOOK;
pohint.po_negation = "no-";
pohint.po_flags |= MU_PARSEOPT_NEGATION;
+#if defined(TESTSUITE_CONFIG_FILE)
+ /* This is for test version (see the tests directory) */
+ cfhint.site_file = TESTSUITE_CONFIG_FILE;
+ mu_log_syslog = 0;
+#else
cfhint.site_file = mu_site_config_file ();
+#endif
cfhint.flags = MU_CFHINT_SITE_FILE | MU_CFHINT_NO_CONFIG_OVERRIDE;
mu_cli_ext (argc, argv, &cli, &pohint, &cfhint,
diff --git a/mda/tests/.gitignore b/mda/tests/.gitignore
index 93f8f46ad..ad1a76504 100644
--- a/mda/tests/.gitignore
+++ b/mda/tests/.gitignore
@@ -4,3 +4,4 @@ package.m4
testsuite
testsuite.dir
testsuite.log
+testmda
diff --git a/mda/tests/Makefile.am b/mda/tests/Makefile.am
index 8e6c1052f..bf8b8e58b 100644
--- a/mda/tests/Makefile.am
+++ b/mda/tests/Makefile.am
@@ -40,6 +40,8 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
TESTSUITE_AT = \
lmtpd.at\
+ mda.at\
+ forward.at\
putmail.at\
testsuite.at
@@ -60,6 +62,39 @@ clean-local:
check-local: atconfig atlocal $(TESTSUITE)
@$(SHELL) $(TESTSUITE)
+noinst_PROGRAMS = testmda
+testmda_SOURCES = testmda.c
+testmda.c: ${srcdir}/../mda.c
+ cp ${srcdir}/../mda.c testmda.c
+BUILT_SOURCES = testmda.c
+if MU_COND_DBM
+ LIBMU_DBM=${top_builddir}/libmu_dbm/libmu_dbm.la
+endif
+testmda_LDADD = \
+ ${builddir}/../lib/libmda.a\
+ ${top_builddir}/lib/libmuscript.a\
+ ${MU_APP_LIBRARIES}\
+ ${MU_LIB_SIEVE}\
+ ${MU_LIB_MAILBOX}\
+ ${MU_LIB_AUTH}\
+ ${MU_LIB_MAILER}\
+ @MU_AUTHLIBS@\
+ ${MU_LIB_MAILUTILS} \
+ @MU_COMMON_LIBRARIES@\
+ @LIBMU_SCM@\
+ @LIBMU_SCM_DEPS@\
+ @MU_LIB_PY@\
+ $(LIBMU_DBM)\
+ @GUILE_LIBS@\
+ @PYTHON_LIBS@\
+ @DBMLIBS@
+
+testmda_CPPFLAGS = \
+ -I${top_srcdir}\
+ @MU_APP_COMMON_INCLUDES@\
+ -I${srcdir}/../lib\
+ -DTESTSUITE_CONFIG_FILE=\"testmda.conf\"
+
# Run the test suite on the *installed* tree.
#installcheck-local:
# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
diff --git a/mda/tests/forward.at b/mda/tests/forward.at
new file mode 100644
index 000000000..96170ad6a
--- /dev/null
+++ b/mda/tests/forward.at
@@ -0,0 +1,90 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2010-2019 Free Software Foundation, Inc.
+#
+# GNU Mailutils is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY 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 GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([forwarding support])
+AT_KEYWORDS([maidag forward])
+
+m4_pushdef([TESTMDA_CONF],[cat > testmda.conf <<EOF
+mailbox {
+ mailbox-pattern "$(pwd)/spool/\${user}";
+}
+
+mailer {
+ url "sendmail:$abs_top_builddir/examples/mta";
+}
+
+forward {
+ file "$forward";
+ file-checks none;
+}
+EOF
+])
+
+AT_CHECK([
+test -w / && AT_SKIP_TEST
+forward=`pwd`/my.forward
+namelist=`sed '/^#/d;s/:.*//' /etc/passwd | sed '3,$d'`
+test -n "$namelist" || AT_SKIP_TEST
+
+cat > my.forward <<EOT
+foo@bar.baz
+\\$namelist
+EOT
+
+set -- $namelist
+
+cat > experr <<EOT
+testmda: notice: skipping forward file $forward: already processed
+EOT
+
+echo ENVELOPE > expout.0
+cat $INPUT_MSG >> expout.0
+echo "" >> expout.0
+
+echo "ENVELOPE FROM: gulliver@example.net" > expout.1
+echo "ENVELOPE TO: <foo@bar.baz>" >> expout.1
+awk '{printf("% 4d:",NR-1); if (NF!=0) printf(" %s",$0); print ""}' $INPUT_MSG >> expout.1
+echo "END OF MESSAGE" >> expout.1
+
+MTA_DIAG=mta.diag
+export MTA_DIAG
+mkdir spool
+TESTMDA_CONF
+testmda --from gulliver@example.net $1 < $INPUT_MSG || exit $?
+
+for name in $namelist
+do
+ if test -f spool/$name; then
+ sed '1s/From gulliver@example.net.*/ENVELOPE/' spool/$name | \
+ cmp expout.0 - >/dev/null || echo "$name mailbox mismatch" >&2
+ else
+ echo "$name missed message" >&2
+ fi
+done
+
+if test -f mta.diag; then
+ cmp mta.diag expout.1 >/dev/null || echo "remote copy mismatch" >&2
+else
+ echo "remote delivery failed" >&2
+fi
+],
+[0],
+[],
+[experr])
+
+m4_popdef([TESTMDA_CONF])
+
+AT_CLEANUP
diff --git a/mda/tests/mda.at b/mda/tests/mda.at
new file mode 100644
index 000000000..6623fb623
--- /dev/null
+++ b/mda/tests/mda.at
@@ -0,0 +1,59 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2010-2019 Free Software Foundation, Inc.
+#
+# GNU Mailutils is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY 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 GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
+
+m4_pushdef([TESTMDA_CONF],[cat > testmda.conf <<EOF
+mailbox {
+ mailbox-pattern "$(pwd)/spool/\${user}";
+}
+EOF
+])
+
+AT_SETUP([mda])
+AT_KEYWORDS([mda mda0])
+
+AT_CHECK([
+echo ENVELOPE > expout
+cat $INPUT_MSG >> expout
+echo "" >> expout
+mkdir spool
+TESTMDA_CONF
+testmda --from gulliver@example.net root < $INPUT_MSG || exit $?
+sed '1s/From gulliver@example.net.*/ENVELOPE/' spool/root
+],
+[0],
+[expout])
+
+AT_CLEANUP
+
+#
+AT_SETUP([mda, explicit envelope])
+AT_KEYWORDS([mda mda1])
+
+AT_CHECK([
+echo "From gulliver Thu Oct 7 19:10:57 2010" > expout
+cat $INPUT_MSG >> expout
+mkdir spool
+TESTMDA_CONF
+testmda --from gulliver@example.net root < expout || exit $?
+echo "" >> expout
+cat spool/root
+],
+[0],
+[expout])
+
+AT_CLEANUP
+
+m4_popdef([TESTMDA_CONF]) \ No newline at end of file
diff --git a/mda/tests/testsuite.at b/mda/tests/testsuite.at
index aa7e59759..4135e4c92 100644
--- a/mda/tests/testsuite.at
+++ b/mda/tests/testsuite.at
@@ -30,4 +30,10 @@ AT_TESTED([putmail])
MUT_VERSION(putmail)
m4_include([putmail.at])
+AT_TESTED([mda])
+MUT_VERSION(testmda)
+m4_include([mda.at])
+m4_include([forward.at])
+
+

Return to:

Send suggestions and report system problems to the System administrator.