old-cross-binutils/ld/testsuite/ld.cdtest/cdtest.exp

87 lines
2.6 KiB
Text

#
# Expect script for LD cdtest Tests
# Copyright (C) 1993 Free Software Foundation
#
# This file 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. */
#
# Written by Jeffrey Wheat (cassidy@cygnus.com)
#
#
# Bugs:
# + Assumes native toolchain, not cross.
# + Doesn't detect compilation failures (including lack of C++ compiler)
# cleanly.
# + Shouldn't use fixed names in /tmp for temp files -- either use names
# in current directory, or generate unique names.
#
if $tracelevel then {
strace $tracelevel
}
set tmpdir /tmp
set ld $objdir/ld.new
set objects "$tmpdir/cdtest-main.o $tmpdir/cdtest-bar.o $tmpdir/cdtest-foo.o"
# compile the dependant objects
verbose "### Compiling dependant objects\n"
ld_compile "$CXX $CXXFLAGS" $srcdir/$subdir/cdtest-foo.cc $tmpdir/cdtest-foo.o
ld_compile "$CXX $CXXFLAGS" $srcdir/$subdir/cdtest-bar.cc $tmpdir/cdtest-bar.o
ld_compile "$CXX $CXXFLAGS" $srcdir/$subdir/cdtest-main.cc $tmpdir/cdtest-main.o
#
# main test loop
#
foreach test [glob -nocomplain $srcdir/$subdir/*.dat] {
global target
global status
global result
set target "$srcdir/$subdir/[file tail [file rootname $test]]"
set tmptarget "$tmpdir/[file tail [file rootname $test]]"
verbose "### Running test $target\n"
# link the target with objects and libraries
ld_link $ld $tmptarget $objects
# load (execute) the target
if ![file exists $tmptarget] then {
unresolved "$tmptarget doesn't exist."
} else {
catch "exec $tmptarget > $tmptarget.out" exec_output
# diff the expected and actual outputs
if [file exists $tmptarget.out] then {
catch "simple_diff $target.dat $tmptarget.out" status
} else {
fail "$tmptarget.out doesn't exist. error was $status"
}
}
# remove generated targets
verbose "Exec exec rm -f $tmptarget.o $tmptarget.out $tmptarget $tmptarget.grt"
catch "exec rm -f $tmptarget.o $tmptarget.out $tmptarget.grt $tmptarget" result
}
# remove dependant objects
verbose "Exec rm -f $objects"
catch "exec rm -f $objects" result
ld_exit