From dcf58c57acf3f817d9a0d17fae5052f39390fb90 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Mon, 14 Oct 2019 17:21:35 +0300 Subject: 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. --- mda/mda.c | 19 ++++++++++- mda/tests/.gitignore | 1 + mda/tests/Makefile.am | 35 ++++++++++++++++++++ mda/tests/forward.at | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++ mda/tests/mda.at | 59 +++++++++++++++++++++++++++++++++ mda/tests/testsuite.at | 6 ++++ 6 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 mda/tests/forward.at create mode 100644 mda/tests/mda.at 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 . + +AT_SETUP([forwarding support]) +AT_KEYWORDS([maidag forward]) + +m4_pushdef([TESTMDA_CONF],[cat > testmda.conf < my.forward < experr < expout.0 +cat $INPUT_MSG >> expout.0 +echo "" >> expout.0 + +echo "ENVELOPE FROM: gulliver@example.net" > expout.1 +echo "ENVELOPE TO: " >> 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 . + +m4_pushdef([TESTMDA_CONF],[cat > testmda.conf < 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]) + + -- cgit v1.2.1