e921af32347840c0e44c2b5495d2a3b516bd3da4
[external/binutils.git] / ld / testsuite / ld-versados / versados.exp
1 # Expect script for ld-versados tests
2 #   Copyright 1995, 1997 Free Software Foundation, Inc.
3 #
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.
13
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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18 # Written by Steve Chamberlain (sac@cygnus.com)
19 #
20
21 # Make sure that ld can read versados images and
22 # generate binaries which are identical to the customer's
23 # old method.
24
25 # This test can only be run if ld generates native executables.
26
27 # This test can only be run on 68k coff targets
28 # Square bracket expressions seem to confuse istarget.
29 if { ![istarget m68k-*-coff*] } then {
30     return
31 }
32
33 set testname "LD VERSADOS"
34
35
36 proc inspect { whichone } {
37     global objdump
38     global exec_output
39     global srcdir
40     global subdir
41     global testname
42
43     send_log "$objdump -s tmpdir/$whichone.out >tmpdir/$whichone.dump\n"
44     catch "exec $objdump -s tmpdir/$whichone.out | grep -v srec >tmpdir/$whichone.dump" exec_output
45
46     if ![string match "" $exec_output] {
47         send_log "$exec_output\n"
48         verbose $exec_output
49         unresolved $testname
50         return 0
51     }
52
53     send_log "$objdump -s $srcdir/$subdir/$whichone.ook >tmpdir/$whichone.dok\n"
54     catch "exec $objdump -s $srcdir/$subdir/$whichone.ook | grep -v srec >tmpdir/$whichone.dok" exec_output
55
56     if ![string match "" $exec_output] {
57         send_log "$exec_output\n"
58         verbose $exec_output
59         unresolved $testname
60         return 0
61     }
62
63     # compare it with the correct output
64     catch "exec diff tmpdir/$whichone.dump tmpdir/$whichone.dok" exec_output
65     if ![string match "" $exec_output] {
66         send_log "$exec_output\n"
67         verbose $exec_output
68         fail $testname
69         return 0
70     }
71
72     return 1
73 }
74
75 if ![ld_simple_link $ld tmpdir/t1.out \
76         " -T $srcdir/$subdir/t1.ld $srcdir/$subdir/t1-1.ro  $srcdir/$subdir/t1-2.ro"] {
77     fail $testname
78     return
79 } else {
80     # Get a dump of what we've got, and what we should have
81     if ![inspect t1] {
82         return
83     }
84 }
85
86
87 if ![ld_simple_link $ld  tmpdir/t2.out \
88         " -T $srcdir/$subdir/t2.ld $srcdir/$subdir/t2-2.ro \
89         $srcdir/$subdir/t2-1.ro  $srcdir/$subdir/t2-3.ro"] {
90     fail $testname
91     return
92 } else {
93     # Get a dump of what we've got, and what we should have
94     if ![inspect t2] {
95         return
96     }
97 }
98
99 pass $testname