aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld.bootstrap/bootstrap.exp
blob: 66337bf48c19520a7516c7a56b9e197c34d6a1f8 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#
# Expect script for LD Bootstrap 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 stage 0

#
# link an object using relocation
#

ld_relocate $objdir/ld.new $tmpdir/ld-partial.o $OFILES
	
ld_link $objdir/ld.new $tmpdir/ld.partial $tmpdir/ld-partial.o

ld_link $tmpdir/ld.partial $tmpdir/ld.full $OFILES

ld_link $tmpdir/ld.full $tmpdir/ld.$stage $OFILES

#
# main test loop
#
for { set stage 0 } { $stage < 9 } { incr stage } {
    
    global OFILES
    global BFDLIB
    global LIBIBERTY
    global HOSTING_EMU
    global HOSTING_CRT0
    global HOSTING_LIBS
    
    set status -1
    
    set tmpstage $stage 
    set ld_old $tmpdir/ld.$stage
    set ld_new $tmpdir/ld.[incr tmpstage]
 
    verbose "### Running test $target\n" 1
    verbose "### stage is now $stage\n" 1
    
    # link the target with itself
    ld_link $ld_old $ld_new $OFILES
    
    # load (compare) the target 	
    if ![file exists $ld_old] then {
	unresolved "$ld_old doesn't exist." 
    }
    
    if ![file exists $ld_new] then {
	unresolved "$ld_new doesn't exist." 
    }
    
    # compare the old and new targets
    set status [ eval ld_load "$ld_old $ld_new" ]
    case $status in {
	"0" { 
	    pass "$ld_old == $ld_new"
	}
	"1" {
	    fail "$tmptarget aborted" 
	}
	"-1" { 
	    perror "Couldn't load $tmptarget." 
	}
    }

# remove generated targets
verbose "### EXEC exec rm -f $ld_old"
catch "exec rm -f $ld_old" result
}

# remove last generated targets
verbose "### EXEC rm -f $ld_old $ld_new"
catch "exec rm -f $ld_old $ld_new" result
ld_exit