summaryrefslogtreecommitdiffabout
path: root/mail.remote/testsuite/lib/mail.remote.exp
blob: b1d6ac9a8fdbdc8f3fed7e50221de37f3163d1a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2004, Free Software Foundation
#  
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#   
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#  
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 

source $top_srcdir/testsuite/lib/mailutils.exp

mu_init -noflags
mu_prepare_spools
set mu_filename "$MU_FOLDER_DIR/mta.diag"
set env(MTA_DIAG) "$mu_filename"

# mail_remote_test [-message MESSAGE][-default (FAIL|XFAIL)]
#            [-input INPUT-LIST]
#            [-args ARGS][-pattern PATTERN-LIST][PATTERN...]
# INPUT-LIST - List of input strings for MU_TOOL
# PATTERN   - Sequence to expect in return. 
# MESSAGE   - [optional] message to output
# ARGS      - Additional arguments to MU_TOOL
proc mail_remote_test { args } {
    global MU_TOOL
    global top_builddir
    global verbose
    global suppress_flag;
    global mu_filename
    upvar timeout timeout

    set default ""
    set message ""
    set invocation ""
    set input ""
    set pattern ""
    for {set i 0} {$i < [llength $args]} {incr i} {
	set a [lindex $args $i]
	if {"$a" == "-default"} {
	    incr i
	    set default [lindex $args $i]
	} elseif {"$a" == "-message"} {
	    incr i
	    set message [lindex $args $i]
	} elseif {"$a" == "-pattern"} {
	    incr i
	    set pattern [lindex $args $i]
	} elseif {"$a" == "-input"} {
	    incr i
	    set input [lindex $args $i]
	} elseif {"$a" == "-args"} {
	    incr i
	    set a [lindex $args $i]
	    if {[llength $a] > 0} {
		append invocation $a
	    }
	} else {
	    set args [lrange $args $i end]
	    break
	}
    }

    set res [remote_spawn host "${top_builddir}/examples/mta -bd"]
    if { $res < 0 || $res == "" } {
	perror "Spawning mta failed."
	return 1
    }

    remote_expect host 60 {
	-re "\[0-9\]\[0-9\]*" {
	    set port $expect_out(buffer)
	    set url "smtp://127.0.0.1:$port"
	    verbose "URL: $url" 1
	}
	default {
	    perror "Spawning mta failed."
	            return 1
	}
    }

    if {"$message" == ""}  {
	set message [lindex $args 0]
    }

    if $verbose>2 then {
	send_user "Message is \"$message\"\n"
    }

    return [mailer_test -default $default -message $message \
	                -input $input -pattern $pattern -file \
			$mu_filename -args "--mailer $url $invocation"]
}


Return to:

Send suggestions and report system problems to the System administrator.