expect-tests.exp   [plain text]


#   Copyright (C) 1988, 1990, 1991, 1992, 1996, 1997 Free Software Foundation, Inc.

# 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., 675 Mass Ave, Cambridge, MA 02139, USA.  

# Please email any bugs, comments, and/or additions to this file to:
# bug-dejagnu@prep.ai.mit.edu

# This file was written by Rob Savoye. (rob@cygnus.com)

#
# the initial work on the version of these tests from the tcl release was done
# by Mary Ann May-Pumphrey of Sun Microsystems.
#
if $tracelevel then {
	strace $tracelevel
	}

expect_before buffer_full { error "Buffer full" }
expect_start

set timeoutmsg "Timed out: Never got started, "
set timeout 20
set file all
set command "unidentified test in $file"

if ![file exists ${srcdir}/../tests] {
    perror "The source for the test cases is missing." 0
    return -1
}
send "cd ${srcdir}/../tests\r"
expect {
    -re "set VERBOSE 1\[\r\n\]*1\[\r\n\]*$eprompt" {
	verbose "Set verbose flag for tests"
	exp_continue
    }
    -re "cd $srcdir/../tests\[\r\n\]*$eprompt" {
	verbose "Changed directory to $srcdir/../tests" 2
    }
    -re "no files matched glob pattern" {
	warning "Didn't cd to $srcdir/../tests"
    }
    timeout {
	perror "Couldn't change directories" 0
	return -1
    }
}

exp_send "source $file\r"
expect {
    -re "source $file\[\r\n\]*$eprompt" {
	verbose "Sourced test $file ..."
	set timeoutmsg "Never got to the end of "
	exp_continue
    }
    "install Tcl or set your TCL_LIBRARY environment variable" {
	perror "You need to set the TCL_LIBRARY environment variable"
	return -1
    }
    -re "no files matched glob pattern" {
	warning "Didn't cd to $srcdir/../tests"
    }
    -re "\[\r\n\]*\\+\\+\\+\\+ (\[a-z\]*-\[.0-9\]*) PASSED\[\r\n\]*" {
	pass $expect_out(1,string)
	exp_continue
    }
    -re "\[\r\n\]*\\+* (\[a-z\]*-\[.0-9\]*) FAILED\[\r\n\]*" {
	fail $expect_out(1,string)
	exp_continue
    }
    -re "Test generated error:\[\r\n\]*.*\[\r\n\]*" {
	regsub "Test generated error:\[\r\n\]+" $expect_out(0,string) "" tmp
	regsub -all "\[\r\n\]*\[a-z.\]test\[\r\n\]*" $tmp "" tmp
	regsub -all "\[\r\n\]*" $tmp "" tmp
	perror "Got a test case bug \"$tmp\""
	exp_continue
    }
    -re "\[x\]+ \[a-i\]+ \[A-K\]+ \[0-9\]+ " {
	verbose "Got standard output message from exec 8.1 test." 3
	exp_continue
    }
    "*Error: bad option *" {
	fail "$command (Got a bad option)"
    }
    eof {
	verbose "Done" 2
    }
    timeout {
	warning "$timeoutmsg $file"		    
    }
}

catch close