mail.local.exp 2.98 KB
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 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., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA.

source $top_srcdir/testsuite/lib/mailutils.exp

mu_init "--authentication generic --authorization virtdomain"
mu_version
if ![mu_check_capability ENABLE_VIRTUAL_DOMAINS] {
    clone_output "WARNING: Support for virtual domains not compiled in"
    clone_output "WARNING: Skipping tests for mail.local"
    exit 0
}

mu_prepare_spools

set ETC_DIR "$MU_DATA_DIR/etc"

set output [remote_exec host "$MU_MAKESPOOL \
	                  -subst \"s,@MU_SPOOL_DIR@,$MU_SPOOL_DIR,\" \
			                    $MU_RC_DIR $ETC_DIR" ]
if [lindex $output 0] {
        perror "Cannot create ETC_DIR: [lindex $output 1]"
        exit 1
}
append MU_TOOL_FLAGS " --virtual-passwd-dir $ETC_DIR"

set mu_filename "$MU_SPOOL_DIR/INBOX"
set env(MTA_DIAG) "$mu_filename"

# mail_local_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_local_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 ""
    set invocation ""
    
    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
	}
    }

    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 $invocation]
}