2000-10-31 Philip Blundell <philb@gnu.org>
[binutils.git] / ld / testsuite / ld-sh / sh.exp
blobc646d269a893d2c1f55beec84f59173db9b3bda2
1 # Expect script for ld-sh tests
2 # Copyright (C) 1995, 1996, 1997 Free Software Foundation
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # Written by Ian Lance Taylor (ian@cygnus.com)
21 # Test SH relaxing. This tests the compiler and assembler as well as
22 # the linker.
24 if ![istarget sh*-*-*] {
25 return
28 set testsimple "SH simple relaxing"
30 if ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] {
31 unresolved $testsimple
32 } else { if ![ld_simple_link $ld tmpdir/sh1 "-relax tmpdir/sh1.o"] {
33 fail $testsimple
34 } else {
35 if ![ld_nm $nm tmpdir/sh1] {
36 unresolved $testsimple
37 } else {
38 if {![info exists nm_output(bar)] \
39 || ![info exists nm_output(foo)]} {
40 send_log "bad output from nm\n"
41 verbose "bad output from nm"
42 fail $testsimple
43 } else {
44 if {$nm_output(bar) != $nm_output(foo) + 4} {
45 send_log "foo == $nm_output(foo)\n"
46 verbose "foo == $nm_output(foo)"
47 send_log "bar == $nm_output(bar)\n"
48 verbose "bar == $nm_output(bar)"
49 fail $testsimple
50 } else {
51 pass $testsimple
55 } }
57 set testsrec "SH relaxing to S-records"
59 if ![ld_simple_link $ld tmpdir/sh1.s1 "-relax -oformat srec tmpdir/sh1.o"] {
60 fail $testsrec
61 } else {
62 # The file name is embedded in the S-records, so create both
63 # files with the same name.
64 catch "exec rm -f tmpdir/sh1.s2" exec_output
65 send_log "mv tmpdir/sh1.s1 tmpdir/sh1.s2\n"
66 verbose "mv tmpdir/sh1.s1 tmpdir/sh1.s2"
67 catch "exec mv tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
68 if ![string match "" $exec_output] {
69 send_log "$exec_output\n"
70 verbose "$exec_output"
71 unresolved $testsrec
72 } else {
73 send_log "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
74 verbose "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
75 catch "exec $objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1" exec_output
76 if ![string match "" $exec_output] {
77 send_log "$exec_output\n"
78 verbose "$exec_output"
79 unresolved $testsrec
80 } else {
81 send_log "cmp tmpdir/sh1.s1 tmpdir/sh1.s2\n"
82 verbose "cmp tmpdir/sh1.s1 tmpdir/sh1.s2"
83 catch "exec cmp tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
84 set exec_output [prune_warnings $exec_output]
85 if ![string match "" $exec_output] {
86 send_log "$exec_output\n"
87 verbose "$exec_output"
88 fail $testsrec
89 } else {
90 pass $testsrec
96 set testlink "SH relaxing"
97 set testjsr "SH confirm relaxing"
98 set testrun "SH relaxing execution"
100 if { [which $CC] == 0 } {
101 untested $testlink
102 untested $testjsr
103 untested $testrun
104 return
107 if {![ld_assemble $as "-relax $srcdir/$subdir/start.s" tmpdir/start.o] \
108 || ![ld_compile $CC "-O -mrelax $srcdir/$subdir/sh2.c" tmpdir/sh2.o]} {
109 unresolved $testlink
110 unresolved $testjsr
111 unresolved $testrun
112 return
115 if ![ld_simple_link $ld tmpdir/sh2 "-relax tmpdir/start.o tmpdir/sh2.o"] {
116 fail $testlink
117 unresolved $testjsr
118 unresolved $testrun
119 return
122 pass $testlink
124 send_log "$objdump -d tmpdir/sh2\n"
125 verbose "$objdump -d tmpdir/sh2"
126 catch "exec $objdump -d tmpdir/sh2" exec_output
127 if [string match "*jsr*" $exec_output] {
128 fail $testjsr
129 } else {
130 pass $testjsr
133 if { ![info exists SIM] || [which $SIM] == 0 } {
134 untested $testrun
135 return
138 set status [catch "exec $SIM tmpdir/sh2" exec_output]
139 if { $status == 0 } {
140 pass $testrun
141 } else {
142 fail $testrun