summaryrefslogtreecommitdiffabout
path: root/tests
Side-by-side diff
Diffstat (limited to 'tests') (more/less context) (ignore whitespace changes)
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/atlocal.in2
-rw-r--r--tests/check-notify.at4
-rw-r--r--tests/etc/Makefile.am1
-rw-r--r--tests/etc/mailstats.rcin2
-rw-r--r--tests/etc/notify.rcin2
-rwxr-xr-xtests/etc/nullmail11
-rw-r--r--tests/mailstats.at4
-rw-r--r--tests/notify-upl.at8
-rw-r--r--tests/nullmail.c84
11 files changed, 98 insertions, 27 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index 1df6b71..461469e 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -12 +12,2 @@ pushck
bkupname
+nullmail
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3f7a491..ebd86ff 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -82,3 +82,3 @@ check-local: atconfig atlocal $(TESTSUITE)
-check_PROGRAMS = wstest wsbatch pushck bkupname
+check_PROGRAMS = wstest wsbatch pushck bkupname
AM_CPPFLAGS = \
@@ -92 +92,5 @@ bkupname_LDADD=../src/backup.o @GRECS_LDADD@
+if COND_MAILUTILS
+ check_PROGRAMS += nullmail
+ nullmail_LDADD = @MAILUTILS_LIBS@
+endif
diff --git a/tests/atlocal.in b/tests/atlocal.in
index af69a75..083c968 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -14,2 +14,3 @@ WY_SRC=@abs_top_builddir@/tests/source
WY_DST=@abs_top_builddir@/tests/dest
+WY_TESTDIR=@abs_top_builddir@/tests
WY_MAILUTILS=@WY_MAILUTILS@
@@ -37,2 +38,3 @@ wydawca_expandmeta() {
s,@WY_CONFSRC@,$WY_CONFSRC,g;
+ s,@WY_TESTDIR@,$WY_TESTDIR,g;
s,@WY_MODDIR@,@abs_top_builddir@/modules/mailutils,g" $1 > $2
diff --git a/tests/check-notify.at b/tests/check-notify.at
index 65aa8b7..fa5cbeb 100644
--- a/tests/check-notify.at
+++ b/tests/check-notify.at
@@ -45,4 +45,3 @@ wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) fini
AT_DATA([outtmpl],
-[-F wydawca-noreply@localhost @USER@@localhost
-=========
+[From wydawca-noreply@localhost
From: wydawca-noreply@localhost
@@ -50,3 +49,2 @@ To: "Wydawca Test User" <@USER@@localhost>
Subject: file rejected
-X-Mailer: AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
diff --git a/tests/etc/Makefile.am b/tests/etc/Makefile.am
index ffb8f99..34d6024 100644
--- a/tests/etc/Makefile.am
+++ b/tests/etc/Makefile.am
@@ -24,3 +24,2 @@ EXTRA_DIST = \
notify.rcin\
- nullmail\
mailstats.rcin
diff --git a/tests/etc/mailstats.rcin b/tests/etc/mailstats.rcin
index 995cd65..ebe364c 100644
--- a/tests/etc/mailstats.rcin
+++ b/tests/etc/mailstats.rcin
@@ -22,3 +22,3 @@ module-init mailutils {
- mailer "| @WY_CONFSRC@/nullmail @WY_DST@/mail.out -F ${sender} ${rcpt}";
+ mailer "| @WY_TESTDIR@/nullmail -o @WY_DST@/mail.out -F ${sender} ${rcpt}";
diff --git a/tests/etc/notify.rcin b/tests/etc/notify.rcin
index 3ae3783..b6630b8 100644
--- a/tests/etc/notify.rcin
+++ b/tests/etc/notify.rcin
@@ -22,3 +22,3 @@ module-init mailutils {
- mailer "| @WY_CONFSRC@/nullmail @WY_DST@/mail.out -F ${sender} ${rcpt}";
+ mailer "| @WY_TESTDIR@/nullmail -o @WY_DST@/mail.out -F ${sender} ${rcpt}";
}
diff --git a/tests/etc/nullmail b/tests/etc/nullmail
deleted file mode 100755
index 55220a6..0000000
--- a/tests/etc/nullmail
+++ b/dev/null
@@ -1,11 +0,0 @@
-#! /bin/sh
-
-out=${1:-/dev/null}
-shift
-
-echo $* >> $out
-echo "=========" >> $out
-cat - >> $out
-echo "========="
-echo ""
-exit 0 \ No newline at end of file
diff --git a/tests/mailstats.at b/tests/mailstats.at
index 32fcb0f..c24cb0e 100644
--- a/tests/mailstats.at
+++ b/tests/mailstats.at
@@ -40,4 +40,3 @@ wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) fini
AT_DATA([expout],
-[-F wydawca-noreply@localhost root@localhost
-=========
+[From wydawca-noreply@localhost
From: wydawca-noreply@localhost
@@ -45,3 +44,2 @@ To: root@localhost
Subject: Wydawca stats
-X-Mailer: AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
diff --git a/tests/notify-upl.at b/tests/notify-upl.at
index 3ace508..7af08e0 100644
--- a/tests/notify-upl.at
+++ b/tests/notify-upl.at
@@ -41,4 +41,3 @@ wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) fini
AT_DATA([outtmpl],
-[-F wydawca-noreply@localhost proj-owner@localhost
-=========
+[From wydawca-noreply@localhost
From: wydawca-noreply@localhost
@@ -46,3 +45,2 @@ To: "Project Admin" <proj-owner@localhost>
Subject: Upload of proj successful
-X-Mailer: AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
@@ -57,4 +55,3 @@ Wydawca
The Project Submission Robot
--F wydawca-noreply@localhost @USER@@localhost
-=========
+From wydawca-noreply@localhost
From: wydawca-noreply@localhost
@@ -62,3 +59,2 @@ To: "Wydawca Test User" <@USER@@localhost>
Subject: Upload of proj successful
-X-Mailer: AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
diff --git a/tests/nullmail.c b/tests/nullmail.c
new file mode 100644
index 0000000..4c5bb9d
--- a/dev/null
+++ b/tests/nullmail.c
@@ -0,0 +1,84 @@
+#include <mailutils/mailutils.h>
+
+char const *headers[] = {
+ MU_HEADER_FROM,
+ MU_HEADER_TO,
+ MU_HEADER_SUBJECT,
+ NULL
+};
+
+char *output_name;
+char *sender_email;
+
+static struct mu_option nullmail_options[] = {
+ { "output", 'o', "FILE", MU_OPTION_DEFAULT,
+ "dump mail to file",
+ mu_c_string, &output_name },
+ { "from", 'F', "EMAIL", MU_OPTION_DEFAULT,
+ "sender email address",
+ mu_c_string, &sender_email },
+ MU_OPTION_END
+}, *options[] = { nullmail_options, NULL };
+
+struct mu_cli_setup cli = {
+ options,
+ NULL,
+ "null mailer",
+ NULL
+};
+
+char *capa[] = {
+ "debug",
+ NULL
+};
+
+int
+main (int argc, char **argv)
+{
+ int i, rc;
+ mu_message_t msg;
+ mu_stream_t input, output, str;
+ mu_header_t hdr;
+ mu_body_t body;
+
+ mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv);
+ /* FIXME: non-option arguments are silently ignored */
+ if (output_name)
+ MU_ASSERT (mu_file_stream_create (&output, output_name,
+ MU_STREAM_CREAT|MU_STREAM_APPEND));
+ else
+ {
+ output = mu_strout;
+ mu_stream_ref (output);
+ }
+
+ if (sender_email)
+ mu_stream_printf (output, "From %s\n", sender_email);
+
+ MU_ASSERT (mu_temp_file_stream_create (&input, NULL, 0));
+ MU_ASSERT (mu_stream_copy (input, mu_strin, 0, NULL));
+ MU_ASSERT (mu_stream_to_message (input, &msg));
+ MU_ASSERT (mu_message_get_header (msg, &hdr));
+ for (i = 0; headers[i]; i++)
+ {
+ char *val;
+ rc = mu_header_aget_value_unfold (hdr, headers[i], &val);
+ if (rc == 0)
+ {
+ mu_stream_printf (output, "%s: %s\n", headers[i], val);
+ free (val);
+ }
+ else if (rc != MU_ERR_NOENT)
+ mu_diag_funcall (MU_DIAG_ERROR, "mu_header_get_value_unfold",
+ headers[i], rc);
+ }
+ mu_stream_printf (output, "\n");
+ MU_ASSERT (mu_message_get_body (msg, &body));
+ MU_ASSERT (mu_body_get_streamref (body, &str));
+ MU_ASSERT (mu_stream_copy (output, str, 0, NULL));
+
+ mu_stream_close (output);
+
+ return 0;
+}
+

Return to:

Send suggestions and report system problems to the System administrator.