/[mailutils]/mailutils/mailbox/testsuite/lib/mailbox.exp
ViewVC logotype

Diff of /mailutils/mailbox/testsuite/lib/mailbox.exp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by gray, Thu Aug 29 14:49:24 2002 UTC revision 1.2 by gray, Wed Jul 16 12:21:42 2003 UTC
# Line 130  proc mailbox_test { args } { Line 130  proc mailbox_test { args } {
130      return $result      return $result
131  }  }
132    
133    proc mailbox_prog_start {cmd} {
134        global verbose
135        global MU_TOOL
136        global MU_TOOL_FLAGS
137        global mailbox_prog_prompt
138        global expect_out
139        global mailbox_spawn_id
140        
141        verbose "Spawning $cmd"
142    
143        set mailbox_spawn_id [remote_spawn host $cmd]
144        if { $mailbox_spawn_id < 0 || $mailbox_spawn_id == "" } {
145            perror "Spawning $cmd failed."
146            return 1;
147        }
148    
149        mu_expect 360 {
150            -re "\[\r\n\]?${mailbox_prog_prompt}$" {
151                verbose "program initialized."
152            }
153            default {
154                perror "program not initialized"
155                return 1
156            }
157        }
158        return 0
159    }
160    
161    proc mailbox_prog_send { string } {
162        return [mu_send "$string"]
163    }
164    
165    proc mailbox_prog_command { cmd } {
166        return [mu_command $cmd]
167    }
168    
169    proc mailbox_prog_stop {} {
170        verbose "Stopping program"
171        remote_close host
172        
173    }
174    
175    # mailbox_prog_test [-message MESSAGE][-default (FAIL|XFAIL)][-noprompt]
176    #                    COMMAND PATTERN [PATTERN...]
177    # COMMAND   - Command to send.
178    # PATTERN   - Sequence to expect in return.
179    # MESSAGE   - [optional] message to output
180    proc mailbox_prog_test { args } {
181        global verbose
182        global mailbox_prog_prompt
183        global suppress_flag;
184        upvar timeout timeout
185    
186        set default ""
187        set message ""
188        set wait_for_prompt 1
189        for {set i 0} {$i < [llength $args]} {incr i} {
190            set a [lindex $args $i]
191            if {"$a" == "-default"} {
192                set default [lindex $args [expr $i + 1]]
193                incr i
194            } elseif {"$a" == "-message"} {
195                set message [lindex $args [expr $i + 1]]
196                incr i
197            } elseif {"$a" == "-noprompt"} {
198                set wait_for_prompt 0
199            } else {
200                set args [lrange $args $i end]
201                break
202            }
203        }
204        
205        if {"$message" == ""}  {
206            set message [lindex $args 0]
207        }
208    
209        if $verbose>2 then {
210            send_user "Message is \"$message\"\n"
211        }
212        set command [lindex $args 0]
213        set pattern [lrange $args 1 end]
214        set result [mu_test $command $pattern]
215        if {$wait_for_prompt} {
216            mu_expect 30 {
217                    -re "\[\r\n\]?${mailbox_prog_prompt}$" {}
218                    default {
219                            perror "prog not initialized"
220                            return 1
221                    }
222            }
223        }
224    
225        if {$result == 0} {
226            pass "$message"
227        } elseif {$result == 1} {
228            if { "$default" == "" || "$default" != "FAIL" } {
229                fail "$message"
230            } else {
231                xfail "$message"
232                set result 0
233            }
234        } elseif {$result == -2} {
235            fail "$message (timeout)"
236        } elseif {$result == -3} {
237            fail "$message (eof)"
238        } else {
239            fail "$message"
240        }
241        return $result
242    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26