aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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
12bkupname 12bkupname
13nullmail
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)
82 82
83check_PROGRAMS = wstest wsbatch pushck bkupname 83check_PROGRAMS = wstest wsbatch pushck bkupname
84AM_CPPFLAGS = \ 84AM_CPPFLAGS = \
@@ -92 +92,5 @@ bkupname_LDADD=../src/backup.o @GRECS_LDADD@
92 92
93if COND_MAILUTILS
94 check_PROGRAMS += nullmail
95 nullmail_LDADD = @MAILUTILS_LIBS@
96endif
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
14WY_DST=@abs_top_builddir@/tests/dest 14WY_DST=@abs_top_builddir@/tests/dest
15WY_TESTDIR=@abs_top_builddir@/tests
15WY_MAILUTILS=@WY_MAILUTILS@ 16WY_MAILUTILS=@WY_MAILUTILS@
@@ -37,2 +38,3 @@ wydawca_expandmeta() {
37 s,@WY_CONFSRC@,$WY_CONFSRC,g; 38 s,@WY_CONFSRC@,$WY_CONFSRC,g;
39 s,@WY_TESTDIR@,$WY_TESTDIR,g;
38 s,@WY_MODDIR@,@abs_top_builddir@/modules/mailutils,g" $1 > $2 40 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
45AT_DATA([outtmpl], 45AT_DATA([outtmpl],
46[-F wydawca-noreply@localhost @USER@@localhost 46[From wydawca-noreply@localhost
47=========
48From: wydawca-noreply@localhost 47From: wydawca-noreply@localhost
@@ -50,3 +49,2 @@ To: "Wydawca Test User" <@USER@@localhost>
50Subject: file rejected 49Subject: file rejected
51X-Mailer: AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
52 50
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 = \
24 notify.rcin\ 24 notify.rcin\
25 nullmail\
26 mailstats.rcin 25 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 {
22 22
23 mailer "| @WY_CONFSRC@/nullmail @WY_DST@/mail.out -F ${sender} ${rcpt}"; 23 mailer "| @WY_TESTDIR@/nullmail -o @WY_DST@/mail.out -F ${sender} ${rcpt}";
24 24
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 {
22 22
23 mailer "| @WY_CONFSRC@/nullmail @WY_DST@/mail.out -F ${sender} ${rcpt}"; 23 mailer "| @WY_TESTDIR@/nullmail -o @WY_DST@/mail.out -F ${sender} ${rcpt}";
24} 24}
diff --git a/tests/etc/nullmail b/tests/etc/nullmail
deleted file mode 100755
index 55220a6..0000000
--- a/tests/etc/nullmail
+++ /dev/null
@@ -1,11 +0,0 @@
1#! /bin/sh
2
3out=${1:-/dev/null}
4shift
5
6echo $* >> $out
7echo "=========" >> $out
8cat - >> $out
9echo "========="
10echo ""
11exit 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
40AT_DATA([expout], 40AT_DATA([expout],
41[-F wydawca-noreply@localhost root@localhost 41[From wydawca-noreply@localhost
42=========
43From: wydawca-noreply@localhost 42From: wydawca-noreply@localhost
@@ -45,3 +44,2 @@ To: root@localhost
45Subject: Wydawca stats 44Subject: Wydawca stats
46X-Mailer: AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
47 45
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
41AT_DATA([outtmpl], 41AT_DATA([outtmpl],
42[-F wydawca-noreply@localhost proj-owner@localhost 42[From wydawca-noreply@localhost
43=========
44From: wydawca-noreply@localhost 43From: wydawca-noreply@localhost
@@ -46,3 +45,2 @@ To: "Project Admin" <proj-owner@localhost>
46Subject: Upload of proj successful 45Subject: Upload of proj successful
47X-Mailer: AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
48 46
@@ -57,4 +55,3 @@ Wydawca
57The Project Submission Robot 55The Project Submission Robot
58-F wydawca-noreply@localhost @USER@@localhost 56From wydawca-noreply@localhost
59=========
60From: wydawca-noreply@localhost 57From: wydawca-noreply@localhost
@@ -62,3 +59,2 @@ To: "Wydawca Test User" <@USER@@localhost>
62Subject: Upload of proj successful 59Subject: Upload of proj successful
63X-Mailer: AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION)
64 60
diff --git a/tests/nullmail.c b/tests/nullmail.c
new file mode 100644
index 0000000..4c5bb9d
--- /dev/null
+++ b/tests/nullmail.c
@@ -0,0 +1,84 @@
1#include <mailutils/mailutils.h>
2
3char const *headers[] = {
4 MU_HEADER_FROM,
5 MU_HEADER_TO,
6 MU_HEADER_SUBJECT,
7 NULL
8};
9
10char *output_name;
11char *sender_email;
12
13static struct mu_option nullmail_options[] = {
14 { "output", 'o', "FILE", MU_OPTION_DEFAULT,
15 "dump mail to file",
16 mu_c_string, &output_name },
17 { "from", 'F', "EMAIL", MU_OPTION_DEFAULT,
18 "sender email address",
19 mu_c_string, &sender_email },
20 MU_OPTION_END
21}, *options[] = { nullmail_options, NULL };
22
23struct mu_cli_setup cli = {
24 options,
25 NULL,
26 "null mailer",
27 NULL
28};
29
30char *capa[] = {
31 "debug",
32 NULL
33};
34
35int
36main (int argc, char **argv)
37{
38 int i, rc;
39 mu_message_t msg;
40 mu_stream_t input, output, str;
41 mu_header_t hdr;
42 mu_body_t body;
43
44 mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv);
45 /* FIXME: non-option arguments are silently ignored */
46 if (output_name)
47 MU_ASSERT (mu_file_stream_create (&output, output_name,
48 MU_STREAM_CREAT|MU_STREAM_APPEND));
49 else
50 {
51 output = mu_strout;
52 mu_stream_ref (output);
53 }
54
55 if (sender_email)
56 mu_stream_printf (output, "From %s\n", sender_email);
57
58 MU_ASSERT (mu_temp_file_stream_create (&input, NULL, 0));
59 MU_ASSERT (mu_stream_copy (input, mu_strin, 0, NULL));
60 MU_ASSERT (mu_stream_to_message (input, &msg));
61 MU_ASSERT (mu_message_get_header (msg, &hdr));
62 for (i = 0; headers[i]; i++)
63 {
64 char *val;
65 rc = mu_header_aget_value_unfold (hdr, headers[i], &val);
66 if (rc == 0)
67 {
68 mu_stream_printf (output, "%s: %s\n", headers[i], val);
69 free (val);
70 }
71 else if (rc != MU_ERR_NOENT)
72 mu_diag_funcall (MU_DIAG_ERROR, "mu_header_get_value_unfold",
73 headers[i], rc);
74 }
75 mu_stream_printf (output, "\n");
76 MU_ASSERT (mu_message_get_body (msg, &body));
77 MU_ASSERT (mu_body_get_streamref (body, &str));
78 MU_ASSERT (mu_stream_copy (output, str, 0, NULL));
79
80 mu_stream_close (output);
81
82 return 0;
83}
84

Return to:

Send suggestions and report system problems to the System administrator.