Commit 1659714c 1659714c7a9ac81b7b1378d82132a6ba81db9024 by Sergey Poznyakoff

Added to repository

1 parent e24d8bb9
1 Makefile
2 Makefile.in
3 *.log
4 *.sum
5 site.exp
6 remote.exp
7 data
1 AUTOMAKE_OPTIONS = dejagnu
2 DEJATOOL = pop3d
3 RUNTESTFLAGS =
4 CLEANFILES = *.log
5 test_dirs = lib pop3d
6
7 dist-hook:
8 here=`cd $(top_builddir)/$(subdir) && pwd`; \
9 srcdir=`cd $(srcdir) && pwd`; \
10 distdir=`cd $(distdir) && pwd`; \
11 for dir in $(test_dirs); \
12 do \
13 cd $$srcdir;\
14 mkdir $$distdir/$$dir;\
15 cd $$dir;\
16 for file in DISTFILES `cat DISTFILES`; do \
17 d=$$srcdir/$$dir; \
18 if test -d $$d/$$file; then \
19 cp -pr $$d/$$file $$distdir/$$dir/$$file; \
20 else \
21 test -f $$distdir/$$dir/$$file \
22 || cp -p $$d/$$file $$distdir/$$dir/$$file || exit; \
23 fi; \
24 done;\
25 done;\
26 cd $$here
27
28 site.exp: Makefile remote.exp
29 @echo 'Making a new site.exp file...'
30 @test ! -f site.bak || rm -f site.bak
31 @echo '## these variables are automatically generated by make ##' > $@-t
32 @echo '# Do not edit here. If you wish to override these values' >> $@-t
33 @echo '# edit the last section' >> $@-t
34 @echo 'set tool $(DEJATOOL)' >> $@-t
35 @echo "set top_srcdir `cd $(top_srcdir); pwd`" >> $@-t
36 @echo "set srcdir `cd $(srcdir); pwd`" >> $@-t
37 @echo 'set objdir' `pwd` >> $@-t
38 @echo 'set host_alias "$(host_alias)"' >> $@-t
39 @echo 'set host_triplet $(host_triplet)' >> $@-t
40 @echo 'set target_alias "$(target_alias)"' >> $@-t
41 @echo 'set target_triplet $(target_triplet)' >> $@-t
42 @echo 'set build_alias "$(build_alias)"' >> $@-t
43 @echo 'set build_triplet $(build_triplet)' >> $@-t
44 @echo '## All variables above are generated by configure. Do Not Edit ##' >> $@-t
45 @test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> $@-t
46 @test ! -f site.exp || mv site.exp site.bak
47 @mv $@-t site.exp
48
49 remote.exp:;
50 @echo 'Making a new remote.exp file...'
51 @test ! -f remote.bak || rm -f remote.bak
52 @echo '## These variables are used to set up for the remote testing.' >> $@-t
53 @echo '## Please, read file README in this directory for instructions' >> $@-t
54 @echo '## on how to use this file' >> $@-t
55 @echo "set host_board `hostname`" >> $@-t
56 @echo 'set board_info($$host_board,connect) rlogin' >> $@-t
57 @echo 'set board_info($$host_board,shell_prompt) "\\$$ "' >> $@-t
58 @echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
59 @echo "set board_info(\$$host_board,srcdir) `cd $(srcdir); pwd`" >> $@-t
60 @echo "set board_info(\$$host_board,objdir) `pwd`" >> $@-t
61 @echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
62 @echo "set board_info(\$$host_board,top_builddir) `cd $(top_builddir); pwd`" >> $@-t
63 @test ! -f remote.exp || mv remote.exp remote.bak
64 @mv $@-t remote.exp
65
66
67 DISTCLEANFILES=*.exp *.log *.sum
68
69 distclean-local:
70 -rm -rf data
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
22 mu_init "--authentication generic --authorization virtdomain"
23 mu_version
24 if ![mu_check_capability USE_VIRTUAL_DOMAINS] {
25 clone_output "WARNING: Support for virtual domains not compiled in"
26 clone_output "WARNING: Skipping tests for pop3d"
27 exit 0
28 }
29
30 set POP3D_ETC_DIR "$MU_DATA_DIR/etc"
31
32 set output [remote_exec host "$MU_MAKESPOOL \
33 -subst \"s,@MU_SPOOL_DIR@,$MU_SPOOL_DIR,\" \
34 $MU_RC_DIR $POP3D_ETC_DIR" ]
35 if [lindex $output 0] {
36 perror "Cannot create $POP3D_ETC_DIR: [lindex $output 1]"
37 exit 1
38 }
39 append MU_TOOL_FLAGS " --virtual-passwd-dir $POP3D_ETC_DIR"
40
41 ### Only procedures should come after this point.
42
43 proc pop3d_version {} {
44 global MU_TOOL
45 global MU_TOOL_FLAGS
46 global MU_TOOL_VERSION
47
48 mu_version
49 if ![is_remote host] {
50 clone_output "[which $MU_TOOL] version $MU_TOOL_VERSION"
51 } else {
52 clone_output "$MU_TOOL on remote host version $MU_TOOL_VERSION"
53 }
54 }
55
56 proc default_pop3d_start {args} {
57 global verbose
58 global MU_TOOL
59 global MU_TOOL_FLAGS
60 global expect_out
61
62 mu_version
63
64 set args [lindex $args 0]
65 if [info exists MU_TOOL_FLAGS] {
66 set sw $MU_TOOL_FLAGS
67 } else {
68 set sw ""
69 }
70
71 if [llength $args] {
72 append sw $args
73 }
74
75 if [info exists host_board] {
76 if [board_info $host_board exists top_srcdir] {
77 append sw " --mail-spool [board_info $host_board top_srcdir]/mail/testsuite/spool"
78 }
79 }
80
81 set pop3d_cmd "$MU_TOOL $sw"
82 verbose "Spawning $pop3d_cmd"
83
84 set res [remote_spawn host $pop3d_cmd]
85 if { $res < 0 || $res == "" } {
86 perror "Spawning $pop3d_cmd failed."
87 return 1;
88 }
89
90 mu_expect 360 {
91 -re "\\+OK.*" {
92 verbose "pop3d initialized."
93 }
94 default {
95 perror "pop3d not initialized"
96 exit 1
97 }
98 }
99 return 0
100 }
101
102 proc default_pop3d_stop {} {
103
104 verbose "Stopping pop3d"
105
106 }
107
108 proc pop3d_start {args} {
109 global MU_SPOOL_DIR
110
111 verbose "Starting pop3d"
112
113 set reuse_spool 0
114 for {set i 0} {$i < [llength $args]} {incr i} {
115 set a [lindex $args $i]
116 if {"$a" == "-reuse-spool"} {
117 set reuse_spool 1
118 } else {
119 break;
120 }
121 }
122
123 if {$reuse_spool == 0} {
124 mu_prepare_spools
125 set output [remote_exec host \
126 "cp $MU_SPOOL_DIR/teaparty.mbox $MU_SPOOL_DIR/INBOX"]
127 if [lindex $output 0] {
128 perror "Cannot create $MU_SPOOL_DIR/INBOX: [lindex $output 1]"
129 exit 1
130 }
131 }
132 return [default_pop3d_start [concat [lrange $args $i end]]]
133 }
134
135 proc pop3d_stop {} {
136 return [default_pop3d_stop];
137 }
138
139 ##
140
141 proc pop3d_send { string } {
142 return [mu_send "$string"]
143 }
144
145 proc pop3d_command { cmd } {
146 return [mu_command $cmd]
147 }
148
149 proc pop3d_exit {} {
150 set res [pop3d_send "quit\n"]
151 mu_expect 360 {
152 -re "\\+OK.*$" { }
153 default {
154 perror "quit failed"
155 exit 1
156 }
157 }
158 return res
159 }
160
161 proc pop3d_auth {args} {
162 set user [lindex $args 0]
163 set pass [lindex $args 1]
164 pop3d_test "USER $user"
165 if [pop3d_test "PASS $pass"] {
166 perror "Failed to authorize."
167 exit 1
168 }
169 }
170
171 # pop3d_test [-message MESSAGE][-default (FAIL|XFAIL)]
172 # COMMAND [PATTERN...]
173 # COMMAND - Command to send.
174 # PATTERN - Sequence to expect in return. Defaults to "+OK"
175 # MESSAGE - [optional] message to output
176 proc pop3d_test { args } {
177 global verbose
178 global suppress_flag;
179 upvar timeout timeout
180
181 set default ""
182 set message ""
183 for {set i 0} {$i < [llength $args]} {incr i} {
184 set a [lindex $args $i]
185 if {"$a" == "-default"} {
186 set default [lindex $args [expr $i + 1]]
187 incr i
188 } elseif {"$a" == "-message"} {
189 set message [lindex $args [expr $i + 1]]
190 incr i
191 } else {
192 set args [lrange $args $i end]
193 break
194 }
195 }
196
197 if {"$message" == ""} {
198 set message [lindex $args 0]
199 }
200
201 if $verbose>2 then {
202 send_user "Message is \"$message\"\n"
203 }
204 set command [lindex $args 0]
205 if {[llength $args] >= 2} {
206 set pattern [lrange $args 1 end]
207 } else {
208 set pattern "+OK"
209 }
210 set result [mu_test $command $pattern]
211
212 if {$result == 0} {
213 pass "$message"
214 } elseif {$result == 1} {
215 if { "$default" == "" || "$default" != "FAIL" } {
216 fail "$message"
217 } else {
218 xfail "$message"
219 set result 0
220 }
221 } elseif {$result == -2} {
222 fail "$message (timeout)"
223 } elseif {$result == -3} {
224 fail "$message (eof)"
225 } else {
226 fail "$message"
227 }
228 return $result
229 }
230
231
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 pop3d_start
20 pop3d_auth "user!passwd" "guessme"
21
22 ## Test STAT command
23 pop3d_test "STAT" "+OK 95 35014"
24
25 ## Test LIST command. This will be used twice.
26 proc test_list {} {
27 pop3d_test "LIST" \
28 "+OK" \
29 "1 317" \
30 "2 327" \
31 "3 322" \
32 "4 351" \
33 "5 368" \
34 "6 384" \
35 "7 331" \
36 "8 374" \
37 "9 360" \
38 "10 329" \
39 "11 364" \
40 "12 313" \
41 "13 354" \
42 "14 385" \
43 "15 427" \
44 "16 403" \
45 "17 460" \
46 "18 346" \
47 "19 326" \
48 "20 313" \
49 "21 363" \
50 "22 327" \
51 "23 403" \
52 "24 338" \
53 "25 421" \
54 "26 364" \
55 "27 396" \
56 "28 340" \
57 "29 336" \
58 "30 343" \
59 "31 381" \
60 "32 335" \
61 "33 339" \
62 "34 331" \
63 "35 308" \
64 "36 423" \
65 "37 389" \
66 "38 338" \
67 "39 373" \
68 "40 375" \
69 "41 668" \
70 "42 347" \
71 "43 394" \
72 "44 396" \
73 "45 339" \
74 "46 554" \
75 "47 340" \
76 "48 430" \
77 "49 365" \
78 "50 443" \
79 "51 334" \
80 "52 389" \
81 "53 382" \
82 "54 395" \
83 "55 342" \
84 "56 342" \
85 "57 358" \
86 "58 444" \
87 "59 343" \
88 "60 389" \
89 "61 399" \
90 "62 341" \
91 "63 337" \
92 "64 392" \
93 "65 489" \
94 "66 330" \
95 "67 329" \
96 "68 368" \
97 "69 331" \
98 "70 354" \
99 "71 317" \
100 "72 347" \
101 "73 375" \
102 "74 333" \
103 "75 346" \
104 "76 351" \
105 "77 330" \
106 "78 330" \
107 "79 375" \
108 "80 381" \
109 "81 395" \
110 "82 327" \
111 "83 316" \
112 "84 368" \
113 "85 371" \
114 "86 419" \
115 "87 333" \
116 "88 338" \
117 "89 407" \
118 "90 322" \
119 "91 316" \
120 "92 506" \
121 "93 347" \
122 "94 327" \
123 "95 396" \
124 "."
125 }
126
127 ## Actually test LIST
128 test_list
129
130 ## Test RETRY on an existing message
131 pop3d_test "RETR 1" \
132 "+OK" \
133 "Received: (from hare@wonder.land)" \
134 " by wonder.land id 3d3b1d91" \
135 " for alice@wonder.land; Sun, 21 Jul 2002 23:46:09 EEST" \
136 "Date: Sun, 21 Jul 2002 23:46:09 EEST" \
137 "From: March Hare <hare@wonder.land>" \
138 "Message-Id: <200207212346.3d3b1d91@wonder.land>" \
139 "To: Alice <alice@wonder.land>" \
140 "Subject: Invitation" \
141 "" \
142 "Have some wine" \
143 "."
144
145 ## Test TOP command
146
147 pop3d_test "TOP 48" \
148 "-ERR Invalid arguments"
149
150 pop3d_test "TOP 48 2" \
151 "+OK" \
152 "Received: (from hatter@wonder.land)" \
153 " by wonder.land id 3d3b1d95" \
154 " for alice@wonder.land; Sun, 21 Jul 2002 23:46:13 EEST" \
155 "Date: Sun, 21 Jul 2002 23:46:13 EEST" \
156 "From: Hatter <hatter@wonder.land>" \
157 "Message-Id: <200207212346.3d3b1d95@wonder.land>" \
158 "To: Alice <alice@wonder.land>" \
159 "Subject: Re: Discussing Time" \
160 "" \
161 "It goes on, you know in this way:--" \
162 "" \
163 "."
164
165 pop3d_test "TOP 48 3" \
166 "+OK" \
167 "Received: (from hatter@wonder.land)" \
168 " by wonder.land id 3d3b1d95" \
169 " for alice@wonder.land; Sun, 21 Jul 2002 23:46:13 EEST" \
170 "Date: Sun, 21 Jul 2002 23:46:13 EEST" \
171 "From: Hatter <hatter@wonder.land>" \
172 "Message-Id: <200207212346.3d3b1d95@wonder.land>" \
173 "To: Alice <alice@wonder.land>" \
174 "Subject: Re: Discussing Time" \
175 "" \
176 "It goes on, you know in this way:--" \
177 "" \
178 "\"Up above the world you fly," \
179 "."
180
181
182 pop3d_test "TOP 48 4" \
183 "+OK" \
184 "Received: (from hatter@wonder.land)" \
185 " by wonder.land id 3d3b1d95" \
186 " for alice@wonder.land; Sun, 21 Jul 2002 23:46:13 EEST" \
187 "Date: Sun, 21 Jul 2002 23:46:13 EEST" \
188 "From: Hatter <hatter@wonder.land>" \
189 "Message-Id: <200207212346.3d3b1d95@wonder.land>" \
190 "To: Alice <alice@wonder.land>" \
191 "Subject: Re: Discussing Time" \
192 "" \
193 "It goes on, you know in this way:--" \
194 "" \
195 "\"Up above the world you fly," \
196 "Like a tea-tray in the sky." \
197 "."
198
199 pop3d_test "TOP 48 1000" \
200 "+OK" \
201 "Received: (from hatter@wonder.land)" \
202 " by wonder.land id 3d3b1d95" \
203 " for alice@wonder.land; Sun, 21 Jul 2002 23:46:13 EEST" \
204 "Date: Sun, 21 Jul 2002 23:46:13 EEST" \
205 "From: Hatter <hatter@wonder.land>" \
206 "Message-Id: <200207212346.3d3b1d95@wonder.land>" \
207 "To: Alice <alice@wonder.land>" \
208 "Subject: Re: Discussing Time" \
209 "" \
210 "It goes on, you know in this way:--" \
211 "" \
212 "\"Up above the world you fly," \
213 "Like a tea-tray in the sky." \
214 "Twinkle, twinkle--\"'" \
215 "."
216
217 ## Test DELE -- RETR -- RSET -- RETR
218 pop3d_test "DELE 2" \
219 "+OK Message 2 marked"
220
221 pop3d_test "RETR 2" \
222 "-ERR Message has been deleted"
223
224 pop3d_test "RSET" "+OK"
225
226 pop3d_test "RETR 2" \
227 "+OK" \
228 "Received: (from alice@wonder.land)" \
229 " by wonder.land id 3d3b1d91" \
230 " for hare@wonder.land; Sun, 21 Jul 2002 23:46:09 EEST" \
231 "Date: Sun, 21 Jul 2002 23:46:09 EEST" \
232 "From: Alice <alice@wonder.land>" \
233 "Message-Id: <200207212346.3d3b1d91@wonder.land>" \
234 "To: March Hare <hare@wonder.land>" \
235 "Subject: Re: Invitation" \
236 ""\
237 "I don't see any wine"\
238 "."
239
240 ## Delete all messages
241 for {set i 1} {$i <= 95} {incr i} {
242 pop3d_test "DELE $i" "+OK Message $i marked"
243 }
244
245 ## This should produce empty output
246 pop3d_test "LIST" \
247 "+OK" \
248 "."
249
250 ## Restore deleted messages
251 pop3d_test "RSET" "+OK"
252
253 ## Test LIST again
254 test_list
255
256 #end of read.exp