Commit d11e2990 d11e29902e92221b239efffa670a4c346da52f9a by Sergey Poznyakoff

(mailer_test): New procedure for testing mailers

1 parent 3e840c28
...@@ -71,11 +71,16 @@ proc mu_init {args} { ...@@ -71,11 +71,16 @@ proc mu_init {args} {
71 71
72 set MU_SPOOL_DIR "$MU_DATA_DIR/spool" 72 set MU_SPOOL_DIR "$MU_DATA_DIR/spool"
73 set MU_FOLDER_DIR "$MU_DATA_DIR/folder" 73 set MU_FOLDER_DIR "$MU_DATA_DIR/folder"
74
75 if {[llength $args] == 1 && [lindex $args 0] == "-noflags"} {
76 set MU_TOOL_FLAGS ""
77 } else {
74 set MU_TOOL_FLAGS "--mail-spool $MU_SPOOL_DIR" 78 set MU_TOOL_FLAGS "--mail-spool $MU_SPOOL_DIR"
75 for {set i 0} {$i < [llength $args]} {incr i} { 79 for {set i 0} {$i < [llength $args]} {incr i} {
76 append MU_TOOL_FLAGS " [lindex $args $i]" 80 append MU_TOOL_FLAGS " [lindex $args $i]"
77 } 81 }
78 } 82 }
83 }
79 } 84 }
80 85
81 proc mu_start {args} { 86 proc mu_start {args} {
...@@ -672,4 +677,92 @@ proc mu_test_file {args} { ...@@ -672,4 +677,92 @@ proc mu_test_file {args} {
672 return $result 677 return $result
673 } 678 }
674 679
680 # mailer_test [-message MESSAGE][-default (FAIL|XFAIL)]
681 # [-file FILENAME]
682 # [-input INPUT-LIST]
683 # [-args ARGS]
684 # [-pattern PATTERN-LIST][PATTERN...]
685 # INPUT-LIST - List of input strings
686 # PATTERN - Sequence to expect in return.
687 # MESSAGE - [optional] message to output
688 #
689 # FIXME: Need -retcode option.
690 #
691 proc mailer_test { args } {
692 global MU_TOOL
693 global MU_TOOL_FLAGS
694 global top_builddir
695 global verbose
696 global suppress_flag;
697 upvar timeout timeout
698
699 set default ""
700 set message ""
701 set invocation ""
702 set input ""
703 set pattern ""
704 set filename ""
705 for {set i 0} {$i < [llength $args]} {incr i} {
706 set a [lindex $args $i]
707 if {"$a" == "-default"} {
708 incr i
709 set default [lindex $args $i]
710 } elseif {"$a" == "-message"} {
711 incr i
712 set message [lindex $args $i]
713 } elseif {"$a" == "-file"} {
714 incr i
715 set filename [lindex $args $i]
716 } elseif {"$a" == "-pattern"} {
717 incr i
718 set pattern [lindex $args $i]
719 } elseif {"$a" == "-input"} {
720 incr i
721 set input [lindex $args $i]
722 } elseif {"$a" == "-args"} {
723 incr i
724 set a [lindex $args $i]
725 if {[llength $a] > 0} {
726 append invocation $a
727 }
728 } else {
729 set args [lrange $args $i end]
730 break
731 }
732 }
733
734 if {$i < [llength $args]} {
735 lappend pattern [lrange $args $i end]
736 }
737
738 verbose "Spawning $MU_TOOL $MU_TOOL_FLAGS $invocation" 1
675 739
740 set res [remote_spawn host "$MU_TOOL $MU_TOOL_FLAGS $invocation"]
741 if { $res < 0 || $res == "" } {
742 perror "Spawning $MU_TOOL $MU_TOOL_FLAGS $invocation failed."
743 return 1;
744 }
745
746 if {"$message" == ""} {
747 set message [lindex $args 0]
748 }
749
750 if $verbose>2 then {
751 send_user "Message is \"$message\"\n"
752 }
753
754 set result ""
755 verbose "INPUT: $input" 1
756 for {set i 0} {$result == "" && $i < [llength $input]} {incr i} {
757 set s [lindex $input $i]
758 verbose "SEND: $s" 1
759 set result [mu_send "[lindex $input $i]\n"]
760 verbose "RESULT: $result"
761 }
762
763 mu_send ""
764
765 remote_wait host 60
766
767 return [mu_test_file -default $default -message $message -pattern $pattern $filename]
768 }
......