# HG changeset patch # User meillo@marmaro.de # Date 1275228349 -7200 # Node ID 49ca781e1503253591eef7c4c52f32add072f4ba # Parent 610cd4e09b9195acadf136b52eaceabe14458c66 reworked the test cases completely they are split into four independent tests now and each one is tested to work with the current version diff -r 610cd4e09b91 -r 49ca781e1503 tests/Makefile --- a/tests/Makefile Sat May 29 23:48:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -# Makefile by markus schnalke -# heavily based on Makefile.am written by oliver kurth - -all: test.conf local.sh smtpout.sh - mkdir -p ./input ./lock - -test.conf: conf.templ - # fails if the current path contains `^'. - sed "s/SMTP_HOST/`hostname`/; s^PWD^`pwd`^" conf.templ > test.conf - -local.sh: test.templ - sed s/RECV_HOST/localhost/ test.templ > local.sh - chmod ugo+x local.sh - -smtpout.sh: test.templ - sed s/RECV_HOST/`hostname`/ test.templ > smtpout.sh - chmod ugo+x smtpout.sh - -clean: - rm -f test.conf local.sh smtpout.sh - rm -rf ./input ./lock diff -r 610cd4e09b91 -r 49ca781e1503 tests/README --- a/tests/README Sat May 29 23:48:42 2010 +0200 +++ b/tests/README Sun May 30 16:05:49 2010 +0200 @@ -1,37 +1,29 @@ -Here a two test programs: local.sh and smtpout.sh. They both send -three mails, using different options. Run them from within this -directory, preferably NOT as root, but you got to have write -permission for this directory. +This directory contains test cases for masqmail, one in each directory. -local.sh sends mail accepted from stdin and sends them to a fake local -mailbox, using your login name. If it works, there should be a file -named with your login name with the mails. You can look at it with cat -or less, or with an ordinary mail program. +Build the test scripts be running + make +in the directory. You can build all of them by running + make +in the tests directory. -smtpout.sh sends mail accepted from stdin and sends them to your local -MTA, so use it only if you have an MTA running on your box (sendmail, -exim, qmail or whatever, or masqmail when you have it already -installed). If it works, you should get three mails. +Run the test by executing + ./test +in its directory, preferably NOT as root, but you got to have write +permission for the directory. -The scripts assume that your login name corresponds to your mailbox -(quite probable) and that your MTA listens on port 25 with the -interface which corresponds to the hostname as returned by the shell -command "hostname" (without quotes...), also very probable. They are -created with make from test.templ. They use a special configuration -(test.conf) for masqmail, which is also created with make from -conf.templ. -Two log files, masqmail.log and debug.log will also be created within -this directory. They may give some information if anything went wrong. +Usually, two log files, masqmail.log and debug.log, will be created. +They may give some information if anything went wrong. -If the log files reveal that your MTA is not willing to relay, you may -have to qualify the hostname: Say +The README files in the test case directories explain the tests in +more detail. -sed s/RECV_HOST/foo.bar.com/ test.templ > smtpout.sh -where you set your fully qualified host name for foo.bar.com. +FIXME: Currently, the return values of the test scripts don't express + if the test was successful or not. -If they do not work, there could be some problem with either the test + +If tests do not work, there could be some problem with either the test programs, the configuration file or masqmail itself. If you have installed masqmail successfully and these scripts do not work, do not worry too much :-). diff -r 610cd4e09b91 -r 49ca781e1503 tests/conf.templ --- a/tests/conf.templ Sat May 29 23:48:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -# Example configuration for MasqMail -# Copyright (C) 1999 Oliver Kurth -# -# This program 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 2 of the License, or -# (at your option) any later version. - -# This program 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 this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -# this is just for testing. In real life it does not make much sense: -run_as_user=true - -# set debug level (0 = no debugging, 5 = very much, 6 = too much) -# can also be set with the -d option on the cmd line -debug_level = 5 - -do_queue = false - -# The name with which MasqMail identifies itself to others: -host_name="SMTP_HOST" - -# Hosts considered local: -#local_hosts="localhost;blue.patchwork.net;blue" -local_hosts="localhost" - -# Nets considered local, for immediate delivery attempts: -# ALL hosts not included in either local_host or local_nets are -# considered to be 'outside', meaning that messages to them will be queued -local_nets="SMTP_HOST" - -# accept connections on these interfaces: -listen_addresses="localhost:2525" - -# send messages to this port: -# probably this will also be configurable on host basis -#remote_port=25 - -# where MasqMail stores its spool files and other stuff: -#spool_dir="/var/spool/masqmail" -spool_dir="PWD" - -# where local mail will be written to: -#mail_dir="/var/spool/mail" -mail_dir="PWD" - -# use syslogd for logs? -use_syslog=false - -# directory for log files if not using syslogd: -#log_dir="/var/masqmail" -log_dir="PWD" - -# special routes: - -#connect_route.GWDG = "src/gwdg.route" -#connect_route.Argon = "src/argon.route" - diff -r 610cd4e09b91 -r 49ca781e1503 tests/hostname-stdin/README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/hostname-stdin/README Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,11 @@ +Test hostname-stdin +------------------- + +Sends three mails, using different options, to . The +mails are passed on stdin. + +Two log files, masqmail.log and debug.log will also be created within +this directory. They may give some information if anything went wrong. + +Run them from within this directory, preferably NOT as root, but you +got to have write permission for this directory. diff -r 610cd4e09b91 -r 49ca781e1503 tests/hostname-stdin/makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/hostname-stdin/makefile Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,20 @@ +# Makefile by markus schnalke +# heavily based on Makefile.am written by oliver kurth + +all: test test.conf + mkdir -p ./input ./lock + +test.conf: test.conf.tpl + # fails if the current path contains `^'. + sed "s/SMTP_HOST/`hostname`/; s^PWD^`pwd`^" $< >$@ + +test: test.tpl + sed s/RECV_HOST/`hostname`/ $< >$@ + chmod +x $@ + +clean: + rm -f test.conf test + +realclean: clean + rm -rf ./input ./lock + rm -f *.log `logname` diff -r 610cd4e09b91 -r 49ca781e1503 tests/hostname-stdin/test.conf.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/hostname-stdin/test.conf.tpl Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,39 @@ +# Example configuration for MasqMail +# Copyright (C) 1999 Oliver Kurth + + +# this is just for testing. In real life it does not make much sense: +run_as_user=true + +# set debug level (0 = no debugging, 5 = very much, 6 = too much) +# can also be set with the -d option on the cmd line +debug_level = 5 + +do_queue = false + +# The name with which MasqMail identifies itself to others: +host_name="SMTP_HOST" + +# Hosts considered local: +local_hosts="SMTP_HOST" + +# Nets considered local, for immediate delivery attempts: +# ALL hosts not included in either local_host or local_nets are +# considered to be 'outside', meaning that messages to them will be queued +#local_nets="SMTP_HOST" + +# accept connections on these interfaces: +#listen_addresses="localhost:2525" + +# where MasqMail stores its spool files and other stuff: +#spool_dir="/var/spool/masqmail" +spool_dir="PWD" + +# where local mail will be written to: +mail_dir="PWD" + +# use syslogd for logs? +use_syslog=false + +# directory for log files if not using syslogd: +log_dir="PWD" diff -r 610cd4e09b91 -r 49ca781e1503 tests/hostname-stdin/test.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/hostname-stdin/test.tpl Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,78 @@ +#! /bin/bash + +# should be run from within tests dir set if you move this: +mm_bin=../../src/masqmail + +hfrom="\"Fritz Meier\" <`logname`@RECV_HOST>" +hto="$hfrom" +to=`logname`@RECV_HOST +hsubject="MasqMail stdin Test" + + +# Testing with rcpt on cmd line +# (dot does end) +# +# the command to be run: +cmd="$mm_bin -C ./test.conf $to" + +$cmd <. +local.sh sends mail accepted from stdin and sends them to a fake local +mailbox, using your login name. If it works, there should be a file +named with your login name with the mails. You can look at it with cat +or less, or with an ordinary mail program. + +Two log files, masqmail.log and debug.log will also be created within +this directory. They may give some information if anything went wrong. + +Run them from within this directory, preferably NOT as root, but you +got to have write permission for this directory. diff -r 610cd4e09b91 -r 49ca781e1503 tests/localhost-stdin/makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/localhost-stdin/makefile Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,16 @@ +# Makefile by markus schnalke +# heavily based on Makefile.am written by oliver kurth + +all: test.conf + mkdir -p ./input ./lock + +test.conf: test.conf.tpl + # fails if the current path contains `^'. + sed "s^PWD^`pwd`^" $< >$@ + +clean: + rm -f test.conf + +realclean: clean + rm -rf ./input ./lock + rm -f *.log `logname` diff -r 610cd4e09b91 -r 49ca781e1503 tests/localhost-stdin/test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/localhost-stdin/test Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,79 @@ +#! /bin/bash + +# should be run from within tests dir set if you move this: +mm_bin=../../src/masqmail + +# +hfrom="\"Fritz Meier\" <`logname`@localhost>" +hto=$hfrom +to=`logname`@localhost +hsubject="MasqMail stdin Test" + +# +# Testing with rcpt on cmd line +# (dot does end) +# +# the command to be run: +cmd="$mm_bin -C ./test.conf $to" + +$cmd <test diff -r 610cd4e09b91 -r 49ca781e1503 tests/relay-to-hostname-mta/makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/relay-to-hostname-mta/makefile Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,23 @@ +# Makefile by markus schnalke +# heavily based on Makefile.am written by oliver kurth + +all: test test.conf test.route + mkdir -p ./input ./lock + +test.conf: test.conf.tpl + # fails if the current path contains `^'. + sed "s^PWD^`pwd`^" $< >$@ + +test: test.tpl + sed s/RECV_HOST/`hostname`/ $< >$@ + chmod +x $@ + +test.route: + echo mail_host=\"`hostname`\" >$@ + +clean: + rm -f test.conf test test.route + +realclean: clean + rm -rf ./input ./lock + rm -f *.log diff -r 610cd4e09b91 -r 49ca781e1503 tests/relay-to-hostname-mta/online --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/relay-to-hostname-mta/online Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,1 @@ +test diff -r 610cd4e09b91 -r 49ca781e1503 tests/relay-to-hostname-mta/test.conf.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/relay-to-hostname-mta/test.conf.tpl Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,33 @@ + +# this is just for testing. In real life it does not make much sense: +run_as_user=true + +# set debug level (0 = no debugging, 5 = very much, 6 = too much) +# can also be set with the -d option on the cmd line +debug_level = 5 + +do_queue = false + +# The name with which MasqMail identifies itself to others: +host_name="MASQMAIL-TEST" + +# where MasqMail stores its spool files and other stuff: +spool_dir="PWD" + +# where local mail will be written to: +mail_dir="PWD" + +# use syslogd for logs? +use_syslog=false + +# directory for log files if not using syslogd: +log_dir="PWD" + +online_routes.test = "PWD/test.route" + +errmsg_file="PWD/../../tpl/failmsg.tpl" +warnmsg_file="PWD/../../tpl/warnmsg.tpl" + +online_detect = "file" +online_file = "PWD/online" + diff -r 610cd4e09b91 -r 49ca781e1503 tests/relay-to-hostname-mta/test.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/relay-to-hostname-mta/test.tpl Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,78 @@ +#! /bin/bash + +# should be run from within tests dir set if you move this: +mm_bin=../../src/masqmail + +hfrom="\"Fritz Meier\" <`logname`@RECV_HOST>" +hto="$hfrom" +to=`logname`@RECV_HOST +hsubject="MasqMail stdin Test" + + +# Testing with rcpt on cmd line +# (dot does end) +# +# the command to be run: +cmd="$mm_bin -C ./test.conf $to" + +$cmd <test diff -r 610cd4e09b91 -r 49ca781e1503 tests/relay-to-localhost-mta/makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/relay-to-localhost-mta/makefile Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,20 @@ +# Makefile by markus schnalke +# heavily based on Makefile.am written by oliver kurth + +all: test test.conf + mkdir -p ./input ./lock + +test.conf: test.conf.tpl + # fails if the current path contains `^'. + sed "s^PWD^`pwd`^" $< >$@ + +test: test.tpl + sed s/RECV_HOST/`hostname`/ $< >$@ + chmod +x $@ + +clean: + rm -f test.conf test + +realclean: clean + rm -rf ./input ./lock + rm -f *.log diff -r 610cd4e09b91 -r 49ca781e1503 tests/relay-to-localhost-mta/online --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/relay-to-localhost-mta/online Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,1 @@ +test diff -r 610cd4e09b91 -r 49ca781e1503 tests/relay-to-localhost-mta/test.conf.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/relay-to-localhost-mta/test.conf.tpl Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,33 @@ + +# this is just for testing. In real life it does not make much sense: +run_as_user=true + +# set debug level (0 = no debugging, 5 = very much, 6 = too much) +# can also be set with the -d option on the cmd line +debug_level = 5 + +do_queue = false + +# The name with which MasqMail identifies itself to others: +host_name="MASQMAIL-TEST" + +# where MasqMail stores its spool files and other stuff: +spool_dir="PWD" + +# where local mail will be written to: +mail_dir="PWD" + +# use syslogd for logs? +use_syslog=false + +# directory for log files if not using syslogd: +log_dir="PWD" + +online_routes.test = "PWD/test.route" + +errmsg_file="PWD/../../tpl/failmsg.tpl" +warnmsg_file="PWD/../../tpl/warnmsg.tpl" + +online_detect = "file" +online_file = "PWD/online" + diff -r 610cd4e09b91 -r 49ca781e1503 tests/relay-to-localhost-mta/test.route --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/relay-to-localhost-mta/test.route Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,1 @@ +mail_host = "localhost" diff -r 610cd4e09b91 -r 49ca781e1503 tests/relay-to-localhost-mta/test.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/relay-to-localhost-mta/test.tpl Sun May 30 16:05:49 2010 +0200 @@ -0,0 +1,78 @@ +#! /bin/bash + +# should be run from within tests dir set if you move this: +mm_bin=../../src/masqmail + +hfrom="\"Fritz Meier\" <`logname`@RECV_HOST>" +hto="$hfrom" +to=`logname`@RECV_HOST +hsubject="MasqMail stdin Test" + + +# Testing with rcpt on cmd line +# (dot does end) +# +# the command to be run: +cmd="$mm_bin -C ./test.conf $to" + +$cmd <" -hto=$hfrom -to=`logname`@RECV_HOST -hsubject="MasqMail stdin Test" - -# -# Testing with rcpt on cmd line -# (dot does end) -# -# the command to be run: -cmd="$mm_bin -C ./test.conf $to" - -$cmd <