Typo fix in most recent entry.
[binutils.git] / ld / testsuite / ld-cdtest / cdtest.exp
blob82fbb88918ee662df540697e879bdc7e1e72356c
1 # Expect script for LD cdtest Tests
2 # Copyright 1993, 1994, 1995, 1997, 2001, 2004, 2007
3 # Free Software Foundation, Inc.
5 # This file is part of the GNU Binutils.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 # MA 02110-1301, USA.
22 # Written by Jeffrey Wheat (cassidy@cygnus.com)
23 # Rewritten by Ian Lance Taylor (ian@cygnus.com)
26 # Make sure that constructors are handled correctly.
28 set test1 "cdtest"
29 set test2 "cdtest with -Ur"
31 # This test requires running the executable generated by ld.
32 if ![isnative] {
33 return
36 if { [which $CXX] == 0 } {
37 untested $test1
38 untested $test2
39 return
42 if { ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-foo.cc tmpdir/cdtest-foo.o]
43 || ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-bar.cc tmpdir/cdtest-bar.o]
44 || ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-main.cc tmpdir/cdtest-main.o] } {
45 unresolved $test1
46 unresolved $test2
47 return
50 set expected_output "$srcdir/$subdir/cdtest.dat"
52 if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
53 fail $test1
54 } else {
55 send_log "tmpdir/cdtest >tmpdir/cdtest.out\n"
56 verbose "tmpdir/cdtest >tmpdir/cdtest.out"
57 catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
59 if ![string match "" $exec_output] then {
60 send_log "$exec_output\n"
61 verbose "$exec_output" 1
63 fail $test1
64 } else {
65 send_log "diff tmpdir/cdtest.out $expected_output\n"
66 verbose "diff tmpdir/cdtest.out $expected_output"
67 catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
68 set exec_output [prune_warnings $exec_output]
70 if ![string match "" $exec_output] then {
71 send_log "$exec_output\n"
72 verbose "$exec_output" 1
74 send_log "Checking against Named Return Value optimization\n"
75 verbose "Checking against Named Return Value optimization" 1
77 set expected_output "$srcdir/$subdir/cdtest-nrv.dat"
79 send_log "diff tmpdir/cdtest.out $expected_output\n"
80 verbose "diff tmpdir/cdtest.out $expected_output"
81 catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
82 set exec_output [prune_warnings $exec_output]
85 if [string match "" $exec_output] then {
86 pass $test1
87 } else {
88 send_log "$exec_output\n"
89 verbose "$exec_output" 1
91 fail $test1
96 if ![ld_relocate $ld tmpdir/cdtest.o {-Ur tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
97 fail $test2
98 } else {
99 if ![ld_link $ld tmpdir/cdtest tmpdir/cdtest.o] {
100 fail $test2
101 } else {
102 send_log "tmpdir/cdtest >tmpdir/cdtest.out\n"
103 verbose "tmpdir/cdtest >tmpdir/cdtest.out"
104 catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
106 if ![string match "" $exec_output] then {
107 send_log "$exec_output\n"
108 verbose "$exec_output" 1
110 fail $test2
111 } else {
112 send_log "diff tmpdir/cdtest.out $expected_output\n"
113 verbose "diff tmpdir/cdtest.out $expected_output"
114 catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
115 set exec_output [prune_warnings $exec_output]
117 if [string match "" $exec_output] then {
118 pass $test2
119 } else {
120 send_log "$exec_output\n"
121 verbose "$exec_output" 1
123 fail $test2