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,7 +219,11 @@ proc imap4d_test { args } { ...@@ -215,7 +219,11 @@ 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]
223 if {$long} {
224 set command_data [lindex $args 1]
225 set args [lrange $args 1 end]
226 }
219 227
220 set pattern [list] 228 set pattern [list]
221 set len [expr [llength $args] - 1] 229 set len [expr [llength $args] - 1]
...@@ -251,9 +259,32 @@ proc imap4d_test { args } { ...@@ -251,9 +259,32 @@ proc imap4d_test { args } {
251 set tagged "OK" 259 set tagged "OK"
252 } 260 }
253 261
262 if {$long} {
263 set command "$command {[string length $command_data]}"
264 imap4d_command $command
265 set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]]
266
267 mu_expect 360 {
268 -re "^\\+ GO AHEAD.*$" { }
269 default {
270 perror "imap4d_long_test failed"
271 return 1
272 }
273 }
274
275 verbose "Sending $command_data" 3
276 mu_send $command_data
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]]
281 } else {
282 set command [imap4d_make_command $command]
254 set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]] 283 set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]]
255 set result [mu_test $command $pattern] 284 set result [mu_test $command $pattern]
285 }
256 286
287 if {!$silent} {
257 if {$result == 0} { 288 if {$result == 0} {
258 pass "$message" 289 pass "$message"
259 } elseif {$result == 1} { 290 } elseif {$result == 1} {
...@@ -270,6 +301,7 @@ proc imap4d_test { args } { ...@@ -270,6 +301,7 @@ proc imap4d_test { args } {
270 } else { 301 } else {
271 fail "$message" 302 fail "$message"
272 } 303 }
304 }
273 return $result 305 return $result
274 } 306 }
275 307
......