#   Copyright (C) 1992 - 2002,2003 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@gnu.org

# This file was written by Rob Savoye. (rob@welcomehome.org)

load_lib util-defs.exp

# move the site.exp file so we have no default to confuse us.
#if [file exists $objdir/site.exp] {
#    catch "exec mv -f $objdir/site.exp $objdir/site.ignore"
#}
set fd [open site.exp w]
puts ${fd} "set host_triplet $host_triplet"
puts ${fd} "set srcdir $srcdir/.."
puts ${fd} "set objdir $objdir/.."
puts ${fd} "set tmpdir $objdir/../tmpdir"
close $fd

#
# Set up the list.
# 1st field is the command line option.
# 2nd field is the pattern to match.
#	NOTE - No variable substitutions can be used.
# 3rd field is an optional message to print with PASS/FAIL.
#


set tests {
    { "-v --tool xXx" "Found.*site\..*Loading.*utils\.exp" "Loading library files" }
    { "-v --tool xXx" "Expect binary is.*Using.*main test driver" "Loading basic packages" }
    { "--F --tool x" "Illegal Argument \"--F\"" "Bad argument" }
    { "--tool x" "Couldn't find tool init file" "Bad tool name" }
    { "--help" "USAGE:*" "Display help" }
    { "-v -v -v" "Verbose level is 3" "Verbose set correctly" }
    { "-V" "Expect version is.*Tcl version is.*Framework version is*" "--version" }
    { "-v --target m68k-vxworks" "Target is m68k-vxworks" "--target option" }
    { "-v --host sparc-sun-sunos4.1.9" "Native configuration is sparc-sun-sunos4.1.9" "--host option" }
    { "-v -a" "Print all test output to screen" "--all option" }
    { "-v --objdir xXx" "Using test binaries in xXx" "--objdir option" }
    { "-v --tool xXx" "Testing xXx" "--tool option" }
    { "-v --debug" "Expect Debugging is ON" "--debug option" }
    { "-v --D0" "Tcl debugger is ON" "--D0 option" }
}

# Commented out for now--this is failing because of a TCL8 strace interaction.
#    { "-v --strace 1" "Source Trace level is now 1.* 1  if" "--strace option" }


# Old tests not used anymore
#    { "-v --build sparc-sun-sunos4.1.9" "Native configuration is sparc-sun-sunos4.1.9" "--build option" }
#    { "-v --srcdir xXx" "Using test sources in xXx" "--srcdir option" }

foreach i $tests {
    if [util_test "$RUNTEST" "[lindex $i 0] -srcdir ${srcdir}/runtest.all" "" "[lindex $i 1]"] {
        fail "[lindex $i 2]"
    } else {
        pass "[lindex $i 2]"
    }
}


set fd [open site.exp w]
puts ${fd} "set host_triplet $host_triplet"
puts ${fd} "set srcdir $srcdir"
puts ${fd} "set objdir $objdir"
puts ${fd} "set tmpdir $objdir/tmpdir"
close $fd

# clean up log files left by the child runtest
if [file exists $objdir/x.sum] {
    exec rm -f $objdir/x.*
}
if [file exists $objdir/xXx.sum] {
    exec rm -f $objdir/xXx.*
}
