Framework for testing mail.remote
Showing
6 changed files
with
459 additions
and
0 deletions
mail.remote/testsuite/Data
0 → 100644
1 | # This file is part of Mailutils testsuite. | ||
2 | # Copyright (C) 2002, Free Software Foundation | ||
3 | # | ||
4 | # This program is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 2 of the License, or | ||
7 | # (at your option) any later version. | ||
8 | # | ||
9 | # This program is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with this program; if not, write to the Free Software Foundation, | ||
16 | # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | # | ||
18 | |||
19 | MESSAGE Simple mail | ||
20 | BODY BEGIN | ||
21 | From: gray@gnu.org | ||
22 | To: bug-mailutils@gnu.org | ||
23 | Subject: Simple mail | ||
24 | |||
25 | This is a simple mail. | ||
26 | Data goes here. | ||
27 | BODY END | ||
28 | |||
29 | PATTERN BEGIN | ||
30 | ENVELOPE FROM: gray@gnu.org | ||
31 | ENVELOPE TO: <bug-mailutils@gnu.org> | ||
32 | 0: From: gray@gnu.org | ||
33 | 1: To: bug-mailutils@gnu.org | ||
34 | 2: Subject: Simple mail | ||
35 | 3: | ||
36 | 4: This is a simple mail. | ||
37 | 5: Data goes here. | ||
38 | 6: | ||
39 | END OF MESSAGE | ||
40 | PATTERN END | ||
41 | MESSAGE END | ||
42 | |||
43 | MESSAGE Explicit from | ||
44 | FROM gray@localhost | ||
45 | BODY BEGIN | ||
46 | From: gray@gnu.org | ||
47 | To: bug-mailutils@gnu.org | ||
48 | Subject: Explicit from test. | ||
49 | |||
50 | This is a simple mail. | ||
51 | Data goes here. | ||
52 | BODY END | ||
53 | |||
54 | PATTERN BEGIN | ||
55 | ENVELOPE FROM: gray@localhost | ||
56 | ENVELOPE TO: <bug-mailutils@gnu.org> | ||
57 | 0: From: gray@gnu.org | ||
58 | 1: To: bug-mailutils@gnu.org | ||
59 | 2: Subject: Explicit from test. | ||
60 | 3: | ||
61 | 4: This is a simple mail. | ||
62 | 5: Data goes here. | ||
63 | 6: | ||
64 | END OF MESSAGE | ||
65 | PATTERN END | ||
66 | MESSAGE END | ||
67 | |||
68 | MESSAGE Explicit To | ||
69 | TO alainm@gnu.org jbailey@gnu.org | ||
70 | BODY BEGIN | ||
71 | From: gray@gnu.org | ||
72 | Subject: Expicit destinations | ||
73 | |||
74 | This is a test for working explicit destinations. | ||
75 | BODY END | ||
76 | PATTERN BEGIN | ||
77 | ENVELOPE FROM: gray@gnu.org | ||
78 | ENVELOPE TO: <alainm@gnu.org>,<jbailey@gnu.org> | ||
79 | 0: To: <alainm@gnu.org>,<jbailey@gnu.org> | ||
80 | 1: From: gray@gnu.org | ||
81 | 2: Subject: Expicit destinations | ||
82 | 3: | ||
83 | 4: This is a test for working explicit destinations. | ||
84 | 5: | ||
85 | END OF MESSAGE | ||
86 | PATTERN END | ||
87 | MESSAGE END | ||
88 | |||
89 | MESSAGE CC | ||
90 | BODY BEGIN | ||
91 | From: gray@gnu.org | ||
92 | To: bug-mailutils@gnu.org | ||
93 | Cc: alainm@gnu.org | ||
94 | Subject: Carbon copy test | ||
95 | |||
96 | CC works. | ||
97 | BODY END | ||
98 | PATTERN BEGIN | ||
99 | ENVELOPE FROM: gray@gnu.org | ||
100 | ENVELOPE TO: <bug-mailutils@gnu.org>,<alainm@gnu.org> | ||
101 | 0: From: gray@gnu.org | ||
102 | 1: To: bug-mailutils@gnu.org | ||
103 | 2: Cc: alainm@gnu.org | ||
104 | 3: Subject: Carbon copy test | ||
105 | 4: | ||
106 | 5: CC works. | ||
107 | 6: | ||
108 | END OF MESSAGE | ||
109 | PATTERN END | ||
110 | MESSAGE END | ||
111 | |||
112 | MESSAGE BCC | ||
113 | BODY BEGIN | ||
114 | From: gray@gnu.org | ||
115 | To: alainm@gnu.org | ||
116 | Bcc: bug-mailutils@gnu.org | ||
117 | Subject: Blind carbon copy test. | ||
118 | |||
119 | Bcc works too. | ||
120 | BODY END | ||
121 | PATTERN BEGIN | ||
122 | ENVELOPE FROM: gray@gnu.org | ||
123 | ENVELOPE TO: <alainm@gnu.org> | ||
124 | 0: From: gray@gnu.org | ||
125 | 1: To: alainm@gnu.org | ||
126 | 2: Subject: Blind carbon copy test. | ||
127 | 3: | ||
128 | 4: Bcc works too. | ||
129 | 5: | ||
130 | END OF MESSAGE | ||
131 | ENVELOPE FROM: gray@gnu.org | ||
132 | ENVELOPE TO: <bug-mailutils@gnu.org> | ||
133 | 0: Bcc: bug-mailutils@gnu.org | ||
134 | 1: From: gray@gnu.org | ||
135 | 2: To: alainm@gnu.org | ||
136 | 3: Subject: Blind carbon copy test. | ||
137 | 4: | ||
138 | 5: Bcc works too. | ||
139 | 6: | ||
140 | END OF MESSAGE | ||
141 | PATTERN END | ||
142 | MESSAGE END | ||
143 | |||
144 | MESSAGE Complex | ||
145 | TO root@localhost | ||
146 | BODY BEGIN | ||
147 | From: gray@gnu.org | ||
148 | Cc: "Alain Magloire" <alainm@gnu.org>, "Jeff Bailey" <jbailey@gnu.org> | ||
149 | Bcc: bug-mailutils@gnu.org | ||
150 | Subject: A complex test | ||
151 | |||
152 | It works? | ||
153 | BODY END | ||
154 | PATTERN BEGIN | ||
155 | ENVELOPE FROM: gray@gnu.org | ||
156 | ENVELOPE TO: <root@localhost>,<alainm@gnu.org>,<jbailey@gnu.org> | ||
157 | 0: To: <root@localhost>,<alainm@gnu.org>,<jbailey@gnu.org> | ||
158 | 1: From: gray@gnu.org | ||
159 | 2: Cc: "Alain Magloire" <alainm@gnu.org>, "Jeff Bailey" <jbailey@gnu.org> | ||
160 | 3: Subject: A complex test | ||
161 | 4: | ||
162 | 5: It works? | ||
163 | 6: | ||
164 | END OF MESSAGE | ||
165 | ENVELOPE FROM: gray@gnu.org | ||
166 | ENVELOPE TO: <bug-mailutils@gnu.org> | ||
167 | 0: To: <bug-mailutils@gnu.org> | ||
168 | 1: Bcc: bug-mailutils@gnu.org | ||
169 | 2: From: gray@gnu.org | ||
170 | 3: Cc: "Alain Magloire" <alainm@gnu.org>, "Jeff Bailey" <jbailey@gnu.org> | ||
171 | 4: Subject: A complex test | ||
172 | 5: | ||
173 | 6: It works? | ||
174 | 7: | ||
175 | END OF MESSAGE | ||
176 | PATTERN END | ||
177 | MESSAGE END | ||
178 | |||
179 | # End of data |
mail.remote/testsuite/Makefile.am
0 → 100644
1 | # This file is part of GNU Mailutils | ||
2 | # Copyright (C) 2000,2001,2002 Free Software Foundation | ||
3 | # See file COPYING in the distribution root directory for copying conditions. | ||
4 | |||
5 | AUTOMAKE_OPTIONS = dejagnu | ||
6 | SMTP_DEJATOOL = mail.remote | ||
7 | DEJATOOL = @RUN_SMTP_DEJATOOL@ | ||
8 | RUNTESTFLAGS = | ||
9 | CLEANFILES = *.log | ||
10 | test_dirs = lib mail.remote | ||
11 | EXTRA_DIST = Data | ||
12 | |||
13 | dist-hook: | ||
14 | here=`cd $(top_builddir)/$(subdir) && pwd`; \ | ||
15 | srcdir=`cd $(srcdir) && pwd`; \ | ||
16 | distdir=`cd $(distdir) && pwd`; \ | ||
17 | for dir in $(test_dirs); \ | ||
18 | do \ | ||
19 | cd $$srcdir;\ | ||
20 | mkdir $$distdir/$$dir;\ | ||
21 | cd $$dir;\ | ||
22 | for file in DISTFILES `cat DISTFILES`; do \ | ||
23 | d=$$srcdir/$$dir; \ | ||
24 | if test -d $$d/$$file; then \ | ||
25 | cp -pr $$d/$$file $$distdir/$$dir/$$file; \ | ||
26 | else \ | ||
27 | test -f $$distdir/$$dir/$$file \ | ||
28 | || cp -p $$d/$$file $$distdir/$$dir/$$file || exit; \ | ||
29 | fi; \ | ||
30 | done;\ | ||
31 | done;\ | ||
32 | cd $$here | ||
33 | |||
34 | site.exp: Makefile remote.exp | ||
35 | @echo 'Making a new site.exp file...' | ||
36 | @test ! -f site.bak || rm -f site.bak | ||
37 | @echo '## these variables are automatically generated by make ##' > $@-t | ||
38 | @echo '# Do not edit here. If you wish to override these values' >> $@-t | ||
39 | @echo '# edit the last section' >> $@-t | ||
40 | @echo 'set tool $(DEJATOOL)' >> $@-t | ||
41 | @echo "set top_srcdir `cd $(top_srcdir); pwd`" >> $@-t | ||
42 | @echo "set top_builddir `cd $(top_builddir); pwd`" >> $@-t | ||
43 | @echo "set srcdir `cd $(srcdir); pwd`" >> $@-t | ||
44 | @echo 'set objdir' `pwd` >> $@-t | ||
45 | @echo 'set host_alias "$(host_alias)"' >> $@-t | ||
46 | @echo 'set host_triplet $(host_triplet)' >> $@-t | ||
47 | @echo 'set target_alias "$(target_alias)"' >> $@-t | ||
48 | @echo 'set target_triplet $(target_triplet)' >> $@-t | ||
49 | @echo 'set build_alias "$(build_alias)"' >> $@-t | ||
50 | @echo 'set build_triplet $(build_triplet)' >> $@-t | ||
51 | @echo '## All variables above are generated by configure. Do Not Edit ##' >> $@-t | ||
52 | @test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> $@-t | ||
53 | @test ! -f site.exp || mv site.exp site.bak | ||
54 | @mv $@-t site.exp | ||
55 | |||
56 | remote.exp:; | ||
57 | @echo 'Making a new remote.exp file...' | ||
58 | @test ! -f remote.bak || rm -f remote.bak | ||
59 | @echo '## These variables are used to set up for the remote testing.' >> $@-t | ||
60 | @echo '## Please, read file README in this directory for instructions' >> $@-t | ||
61 | @echo '## on how to use this file' >> $@-t | ||
62 | @echo "set host_board `hostname`" >> $@-t | ||
63 | @echo 'set board_info($$host_board,connect) rlogin' >> $@-t | ||
64 | @echo 'set board_info($$host_board,shell_prompt) "\\$$ "' >> $@-t | ||
65 | @echo "set board_info(\$$host_board,srcdir) `cd $(srcdir); pwd`" >> $@-t | ||
66 | @echo "set board_info(\$$host_board,objdir) `pwd`" >> $@-t | ||
67 | @echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t | ||
68 | @echo "set board_info(\$$host_board,top_builddir) `cd $(top_builddir); pwd`" >> $@-t | ||
69 | @test ! -f remote.exp || mv remote.exp remote.bak | ||
70 | @mv $@-t remote.exp | ||
71 | |||
72 | |||
73 | DISTCLEANFILES=*.exp *.log *.sum | ||
74 | |||
75 | distclean-local: | ||
76 | -rm -rf data |
mail.remote/testsuite/lib/DISTFILES
0 → 100644
1 | mail.remote.exp |
mail.remote/testsuite/lib/mail.remote.exp
0 → 100644
1 | # -*- tcl -*- | ||
2 | # This file is part of Mailutils testsuite. | ||
3 | # Copyright (C) 2002, Free Software Foundation | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License as published by | ||
7 | # the Free Software Foundation; either version 2 of the License, or | ||
8 | # (at your option) any later version. | ||
9 | # | ||
10 | # This program is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | # GNU General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with this program; if not, write to the Free Software Foundation, | ||
17 | # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | source $top_srcdir/testsuite/lib/mailutils.exp | ||
20 | |||
21 | mu_init | ||
22 | mu_prepare_spools | ||
23 | set mu_filename "$MU_FOLDER_DIR/mta.diag" | ||
24 | set env(MTA_DIAG) "$mu_filename" | ||
25 | |||
26 | # mailer_remote_test [-message MESSAGE][-default (FAIL|XFAIL)] | ||
27 | # [-from FROM][-to TO][-pattern PATTERN-LIST][PATTERN...] | ||
28 | # PATTERN - Sequence to expect in return. | ||
29 | # MESSAGE - [optional] message to output | ||
30 | proc mailer_remote_test { args } { | ||
31 | global MU_TOOL | ||
32 | global top_builddir | ||
33 | global verbose | ||
34 | global suppress_flag; | ||
35 | global mu_filename | ||
36 | upvar timeout timeout | ||
37 | |||
38 | set default "" | ||
39 | set message "" | ||
40 | set invocation "" | ||
41 | set input "" | ||
42 | set pattern "" | ||
43 | for {set i 0} {$i < [llength $args]} {incr i} { | ||
44 | set a [lindex $args $i] | ||
45 | if {"$a" == "-default"} { | ||
46 | incr i | ||
47 | set default [lindex $args $i] | ||
48 | } elseif {"$a" == "-message"} { | ||
49 | incr i | ||
50 | set message [lindex $args $i] | ||
51 | } elseif {"$a" == "-pattern"} { | ||
52 | incr i | ||
53 | set pattern [lindex $args $i] | ||
54 | } elseif {"$a" == "-input"} { | ||
55 | incr i | ||
56 | set input [lindex $args $i] | ||
57 | } elseif {"$a" == "-args"} { | ||
58 | incr i | ||
59 | set a [lindex $args $i] | ||
60 | if {[llength $a] > 0} { | ||
61 | append invocation $a | ||
62 | } | ||
63 | } else { | ||
64 | set args [lrange $args $i end] | ||
65 | break | ||
66 | } | ||
67 | } | ||
68 | |||
69 | set res [remote_spawn host "${top_builddir}/examples/mta -bd"] | ||
70 | if { $res < 0 || $res == "" } { | ||
71 | perror "Spawning mta failed." | ||
72 | return 1 | ||
73 | } | ||
74 | |||
75 | remote_expect host 60 { | ||
76 | -re "\[0-9\]\[0-9\]*" { | ||
77 | set port $expect_out(buffer) | ||
78 | set url "smtp://127.0.0.1:$port" | ||
79 | verbose "URL: $url" 1 | ||
80 | } | ||
81 | default { | ||
82 | perror "Spawning mta failed." | ||
83 | return 1 | ||
84 | } | ||
85 | } | ||
86 | |||
87 | verbose "Spawning $MU_TOOL --mailer $url $invocation" 1 | ||
88 | |||
89 | set res [remote_spawn host "$MU_TOOL --mailer $url $invocation"] | ||
90 | if { $res < 0 || $res == "" } { | ||
91 | perror "Spawning $MU_TOOL $invocation failed." | ||
92 | return 1; | ||
93 | } | ||
94 | |||
95 | if {"$message" == ""} { | ||
96 | set message [lindex $args 0] | ||
97 | } | ||
98 | |||
99 | if $verbose>2 then { | ||
100 | send_user "Message is \"$message\"\n" | ||
101 | } | ||
102 | |||
103 | set result "" | ||
104 | verbose "INPUT: $input" 1 | ||
105 | for {set i 0} {$result == "" && $i < [llength $input]} {incr i} { | ||
106 | set s [lindex $input $i] | ||
107 | verbose "SEND: $s" 1 | ||
108 | set result [mu_send "[lindex $input $i]\n"] | ||
109 | verbose "RESULT: $result" | ||
110 | } | ||
111 | |||
112 | mu_send "" | ||
113 | |||
114 | remote_wait host 60 | ||
115 | |||
116 | return [mu_test_file -default $default -message $message -pattern $pattern $mu_filename] | ||
117 | } | ||
118 | |||
119 |
mail.remote/testsuite/mail.remote/DISTFILES
0 → 100644
1 | send.exp |
mail.remote/testsuite/mail.remote/send.exp
0 → 100644
1 | # -*- tcl -*- | ||
2 | # This file is part of Mailutils testsuite. | ||
3 | # Copyright (C) 2002, Free Software Foundation | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License as published by | ||
7 | # the Free Software Foundation; either version 2 of the License, or | ||
8 | # (at your option) any later version. | ||
9 | # | ||
10 | # This program is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | # GNU General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with this program; if not, write to the Free Software Foundation, | ||
17 | # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | set chan [open ${srcdir}/Data r] | ||
20 | |||
21 | set state 0 | ||
22 | set command "" | ||
23 | for {gets $chan line} {![eof $chan]} {gets $chan line} { | ||
24 | verbose "LINE $line" 1 | ||
25 | switch -regexp -- "$line" { | ||
26 | "^#.*" { } | ||
27 | "^MESSAGE END" { | ||
28 | verbose "MAIL FROM $from" 1 | ||
29 | verbose "MAIL TO $to" 1 | ||
30 | verbose "INPUT $input" 1 | ||
31 | verbose "PATTERN $pattern" 1 | ||
32 | set args "" | ||
33 | if {$from != ""} { | ||
34 | append args " --from $from" | ||
35 | } | ||
36 | if {$to != ""} { | ||
37 | append args " $to" | ||
38 | } | ||
39 | mailer_remote_test -message $message -input $input -pattern $pattern -args $args | ||
40 | set state 0 | ||
41 | } | ||
42 | "^MESSAGE" { | ||
43 | regexp "^MESSAGE (.*)" $line dummy message | ||
44 | set from "" | ||
45 | set to "" | ||
46 | set input [list] | ||
47 | set pattern [list] | ||
48 | set state 1 | ||
49 | } | ||
50 | "^FROM" { | ||
51 | regexp "^FROM (.*)" $line dummy from | ||
52 | } | ||
53 | "^TO" { | ||
54 | regexp "^TO (.*)" $line dummy to | ||
55 | } | ||
56 | "^BODY BEGIN" { | ||
57 | set state 2 | ||
58 | } | ||
59 | "^BODY END" { | ||
60 | set state 1 | ||
61 | } | ||
62 | "^PATTERN BEGIN" { | ||
63 | set state 3 | ||
64 | } | ||
65 | "^PATTERN END" { | ||
66 | set state 1 | ||
67 | } | ||
68 | "^STOP" { | ||
69 | break | ||
70 | } | ||
71 | default { | ||
72 | if {$state == 2} { | ||
73 | lappend input $line | ||
74 | } elseif {$state == 3} { | ||
75 | lappend pattern $line | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | close $chan | ||
82 | |||
83 | # End of send.exp | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment