AC_CONFIG_FILES([contrib/receivestrip/Makefile])
AC_CONFIG_FILES([tests/Makefile])
AC_CONFIG_FILES([tests/Kyuafile])
+AC_CONFIG_FILES([tests/test_env.sh])
AC_OUTPUT
#include "wrappers.h"
#include "statctrl.h"
#include "ctrlvalue.h"
+#include "stdbool.h"
#include "getaddrsfromfd.h"
static int addtohdr = 0;
{
size_t len = 0, hdrslen, bodylen;
int sockfd = -1, mailfd = 0, opt, mindex = 0, subfd = 0, tmpfd, i;
- int deletewhensent = 1, sendres = 0, archive = 1, digest = 0;
+ int deletewhensent = 1, sendres = 0, digest = 0;
+ bool archive = true;
int ctrlarchive, res;
char *listaddr = NULL, *listdelim = NULL;
char *mailfilename = NULL, *subfilename = NULL, *omit = NULL;
while ((opt = getopt(argc, argv, "aVDhm:l:L:R:F:T:r:s:o:")) != -1){
switch(opt) {
case 'a':
- archive = 0;
+ archive = false;
break;
case 'D':
deletewhensent = 0;
print_help(argv[0]);
break;
case 'l':
+ if (*optarg <= '0' || *optarg > '7')
+ errx(EXIT_FAILURE, "-l only accept the "
+ "following arguments: 1, 2, 3, 4, 5, 6 or"
+ " 7");
listctrl = optarg;
+ archive = false;
break;
case 'L':
listdir = optarg;
stl.strs = NULL;
stl.count = 0;
- switch(listctrl[0]) {
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- archive = 0;
- default:
- break;
- }
-
if(listdir && listctrl[0] != '5')
listaddr = getlistaddr(listdir);
}
break;
case '6':
- archive = 0;
+ archive = false;
deletewhensent = 0;
archivefilename = xstrdup(mailfilename);
bounceaddr = bounce_from_adr(to_addr, listaddr, listdelim,
--- /dev/null
+syntax(2)
+
+test_suite('mlmmj')
+
+atf_test_program{name='mlmmj'}
+atf_test_program{name='mlmmj-send'}
AM_CFLAGS = -g -Wall -pedantic -Wsign-compare -DDEFAULTTEXTDIR='"@textlibdir@"' -I$(srcdir)/../include @ATF_CFLAGS@
mlmmj_LDADD = $(top_builddir)/src/libmlmmj.a @ATF_LIBS@
+test_scripts = mlmmj-send.sh
+check_SCRIPTS= $(test_scripts:.sh=)
+SUFFIXES= .sh
+
all: $(check_PROGRAMS) $(check_SCRIPTS)
check: $(check_SCRIPTS) $(check_PROGRAMS)
kyua --config=none test --kyuafile='$(builddir)/Kyuafile' \
--build-root='$(builddir)'
+
+.sh:
+ install -m 755 $< $@
--- /dev/null
+#!/usr/bin/env atf-sh
+
+. $(atf_get_srcdir)/test_env.sh
+
+tests_init \
+ basics
+
+basics_body()
+{
+
+ mlmmjsend=$(command -v mlmmj-send)
+ helptxt="Usage: $mlmmjsend [-L /path/to/list -m /path/to/mail | -l listctrl]
+ [-a] [-D] [-F sender@example.org] [-h] [-o address@example.org]
+ [-r 127.0.0.1] [-R reply@example.org] [-s /path/to/subscribers]
+ [-T recipient@example.org] [-V]
+ -a: Don't archive the mail
+ -D: Don't delete the mail after it's sent
+ -F: What to use as MAIL FROM:
+ -h: This help
+ -l: List control variable:
+ '1' means 'send a single mail'
+ '2' means 'mail to moderators'
+ '3' means 'resend failed list mail'
+ '4' means 'send to file with recipients'
+ '5' means 'bounceprobe'
+ '6' means 'single listmail to single recipient'
+ '7' means 'digest'
+ -L: Full path to list directory
+ -m: Full path to mail file
+ -o: Address to omit from distribution (normal mail only)
+ -r: Relayhost IP address (defaults to 127.0.0.1)
+ -R: What to use as Reply-To: header
+ -s: Subscribers file name
+ -T: What to use as RCPT TO:
+ -V: Print version
+"
+ init_ml ml
+
+ atf_check -s exit:1 -e "inline:mlmmj-send: You have to specify -m and -L or -l\n$mlmmjsend -h for help\n" $mlmmjsend
+ atf_check -s exit:0 -o "inline:mlmmj-send version 1.3.0\n" $mlmmjsend -V
+ atf_check -s exit:0 -o "inline:$helptxt" $mlmmjsend -h
+ atf_check -s exit:1 -e "inline:mlmmj-send: -l only accept the following arguments: 1, 2, 3, 4, 5, 6 or 7\n" $mlmmjsend -l 8
+ atf_check -s exit:1 -e "inline:mlmmj-send: -l only accept the following arguments: 1, 2, 3, 4, 5, 6 or 7\n" $mlmmjsend -l 0
+}
--- /dev/null
+srcdir="$(atf_get_srcdir)"
+export PATH="$srcdir/../src:${PATH}"
+
+selfdir="@abs_top_srcdir@/tests"
+LIBRARY_PATH_ENV="LIBRARY_PATH"
+SYSROOT_DIR="${selfdir}"
+
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
+datarootdir="@datarootdir@"
+pcpath="@PKG_DEFAULT_PATH@"
+
+tests_init()
+{
+ TESTS="$@"
+ export TESTS
+ for t ; do
+ atf_test_case $t
+ done
+}
+
+atf_init_test_cases() {
+ for t in ${TESTS}; do
+ atf_add_test_case $t
+ done
+}
+
+init_ml()
+{
+ local ml="$1"
+ mkdir "$ml"
+ for d in incoming queue queue/discarded archive text subconf unsubconf \
+ bounce control moderation subscribers.d digesters.d requeue \
+ nomailsubs.d; do
+ mkdir $ml/$d
+ done
+}