Commit 1b79a069 1b79a06940889a1ed57ae086016fa873289dd666 by Sergey Poznyakoff

(imap4d_test): Added new options: -long to emit long IMAP4D literal after

the command, -silent to be silent about the results of the testcase.
1 parent 8f3e3ba6
...@@ -65,7 +65,7 @@ proc default_imap4d_start {args} { ...@@ -65,7 +65,7 @@ proc default_imap4d_start {args} {
65 65
66 set args [lindex $args 0] 66 set args [lindex $args 0]
67 if [info exists MU_TOOL_FLAGS] { 67 if [info exists MU_TOOL_FLAGS] {
68 set sw $MU_TOOL_FLAGS 68 set sw "$MU_TOOL_FLAGS "
69 } else { 69 } else {
70 set sw "" 70 set sw ""
71 } 71 }
...@@ -110,7 +110,7 @@ proc default_imap4d_stop {} { ...@@ -110,7 +110,7 @@ proc default_imap4d_stop {} {
110 proc imap4d_start {args} { 110 proc imap4d_start {args} {
111 global MU_SPOOL_DIR 111 global MU_SPOOL_DIR
112 112
113 verbose "Starting pop3d" 113 verbose "Starting imap4d"
114 114
115 set reuse_spool 0 115 set reuse_spool 0
116 for {set i 0} {$i < [llength $args]} {incr i} { 116 for {set i 0} {$i < [llength $args]} {incr i} {
...@@ -179,20 +179,20 @@ proc imap4d_auth {args} { ...@@ -179,20 +179,20 @@ proc imap4d_auth {args} {
179 } 179 }
180 } 180 }
181 181
182 # imap4d_test [-message MESSAGE][-default (FAIL|XFAIL)] 182 # imap4d_test [-message MESSAGE][-default (FAIL|XFAIL)][-long][-silent]
183 # COMMAND [UNTAGGED...][TAGGED] 183 # COMMAND [UNTAGGED...][TAGGED]
184 # COMMAND - Command to send. 184 # COMMAND - Command to send.
185 # UNTAGGED - A list of untagged responses to expect in return. 185 # UNTAGGED - A list of untagged responses to expect in return.
186 # TAGGED - A tagged response to expect in return. Defaults to "OK" 186 # TAGGED - A tagged response to expect in return. Defaults to "OK"
187 # MESSAGE - [optional] message to output 187 # MESSAGE - [optional] message to output
188 proc imap4d_test { args } { 188 proc imap4d_test {args} {
189 global verbose
190 global suppress_flag;
191 global IMAP4D_TAG 189 global IMAP4D_TAG
192 upvar timeout timeout 190 global verbose
193 191
194 set default "" 192 set default ""
195 set message "" 193 set message ""
194 set long 0
195 set silent 0
196 for {set i 0} {$i < [llength $args]} {incr i} { 196 for {set i 0} {$i < [llength $args]} {incr i} {
197 set a [lindex $args $i] 197 set a [lindex $args $i]
198 if {"$a" == "-default"} { 198 if {"$a" == "-default"} {
...@@ -201,6 +201,10 @@ proc imap4d_test { args } { ...@@ -201,6 +201,10 @@ proc imap4d_test { args } {
201 } elseif {"$a" == "-message"} { 201 } elseif {"$a" == "-message"} {
202 set message [lindex $args [expr $i + 1]] 202 set message [lindex $args [expr $i + 1]]
203 incr i 203 incr i
204 } elseif {"$a" == "-long"} {
205 set long 1
206 } elseif {"$a" == "-silent"} {
207 set silent 1
204 } else { 208 } else {
205 set args [lrange $args $i end] 209 set args [lrange $args $i end]
206 break 210 break
...@@ -215,8 +219,12 @@ proc imap4d_test { args } { ...@@ -215,8 +219,12 @@ proc imap4d_test { args } {
215 send_user "Message is \"$message\"\n" 219 send_user "Message is \"$message\"\n"
216 } 220 }
217 221
218 set command [imap4d_make_command [lindex $args 0]] 222 set command [lindex $args 0]
219 223 if {$long} {
224 set command_data [lindex $args 1]
225 set args [lrange $args 1 end]
226 }
227
220 set pattern [list] 228 set pattern [list]
221 set len [expr [llength $args] - 1] 229 set len [expr [llength $args] - 1]
222 230
...@@ -251,26 +259,50 @@ proc imap4d_test { args } { ...@@ -251,26 +259,50 @@ proc imap4d_test { args } {
251 set tagged "OK" 259 set tagged "OK"
252 } 260 }
253 261
254 set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]] 262 if {$long} {
255 set result [mu_test $command $pattern] 263 set command "$command {[string length $command_data]}"
264 imap4d_command $command
265 set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]]
256 266
257 if {$result == 0} { 267 mu_expect 360 {
258 pass "$message" 268 -re "^\\+ GO AHEAD.*$" { }
259 } elseif {$result == 1} { 269 default {
260 if { "$default" == "" || "$default" != "FAIL" } { 270 perror "imap4d_long_test failed"
261 fail "$message" 271 return 1
262 } else { 272 }
263 xfail "$message"
264 set result 0
265 } 273 }
266 } elseif {$result == -2} { 274
267 fail "$message (timeout)" 275 verbose "Sending $command_data" 3
268 } elseif {$result == -3} { 276 mu_send $command_data
269 fail "$message (eof)" 277
278 set s [split $command_data "\n"]
279 set s [lrange $s 0 [expr [llength $s] - 2]]
280 set result [mu_expect_list 360 [concat $s $pattern]]
270 } else { 281 } else {
271 fail "$message" 282 set command [imap4d_make_command $command]
283 set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]]
284 set result [mu_test $command $pattern]
285 }
286
287 if {!$silent} {
288 if {$result == 0} {
289 pass "$message"
290 } elseif {$result == 1} {
291 if { "$default" == "" || "$default" != "FAIL" } {
292 fail "$message"
293 } else {
294 xfail "$message"
295 set result 0
296 }
297 } elseif {$result == -2} {
298 fail "$message (timeout)"
299 } elseif {$result == -3} {
300 fail "$message (eof)"
301 } else {
302 fail "$message"
303 }
272 } 304 }
273 return $result 305 return $result
274 } 306 }
275 307
276 308
......