aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld.cdtest/cdtest.exp
blob: 127e184519537c8275d54eed2d1e0226993af829 (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
#
# 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.  */
#
#	$Id$
#
# Written by Jeffrey Wheat (cassidy@cygnus.com)
#

if $tracelevel then {
    strace $tracelevel
}

set tmpdir /tmp
set ld $objdir/ld.new

set objects "$tmpdir/cdtest-main.o $tmpdir/cdtest-func.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-func.cc $tmpdir/cdtest-func.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. $result"
    } 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"
    catch "exec rm -f $tmptarget.o $tmptarget.out" result
    verbose "Exec exec rm -f $tmptarget.grt $tmptarget"
    catch "exec rm -f $tmptarget.grt $tmptarget" result
}
    
# remove dependant objects	
verbose "Exec rm -f $objects"
catch "exec rm -f $objects" result
ld_exit