Commit | Line | Data |
---|---|---|
252b5132 | 1 | # Expect script for LD cdtest Tests |
aa820537 | 2 | # Copyright 1993, 1994, 1995, 1997, 2001, 2004, 2005, 2007 |
aef6203b | 3 | # Free Software Foundation, Inc. |
252b5132 | 4 | # |
f96b4a7b NC |
5 | # This file is part of the GNU Binutils. |
6 | # | |
7 | # This program is free software; you can redistribute it and/or modify | |
252b5132 | 8 | # it under the terms of the GNU General Public License as published by |
f96b4a7b | 9 | # the Free Software Foundation; either version 3 of the License, or |
252b5132 | 10 | # (at your option) any later version. |
f96b4a7b | 11 | # |
252b5132 RH |
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. | |
f96b4a7b | 16 | # |
252b5132 RH |
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 | |
f96b4a7b NC |
19 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 | # MA 02110-1301, USA. | |
252b5132 RH |
21 | # |
22 | # Written by Jeffrey Wheat (cassidy@cygnus.com) | |
23 | # Rewritten by Ian Lance Taylor (ian@cygnus.com) | |
24 | # | |
25 | ||
26 | # Make sure that constructors are handled correctly. | |
27 | ||
28 | set test1 "cdtest" | |
29 | set test2 "cdtest with -Ur" | |
30 | ||
31 | # This test requires running the executable generated by ld. | |
32 | if ![isnative] { | |
33 | return | |
34 | } | |
35 | ||
36 | if { [which $CXX] == 0 } { | |
37 | untested $test1 | |
38 | untested $test2 | |
39 | return | |
40 | } | |
41 | ||
8bfaaee7 AM |
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] } { | |
252b5132 RH |
45 | unresolved $test1 |
46 | unresolved $test2 | |
47 | return | |
48 | } | |
49 | ||
39c183c1 NC |
50 | set expected_output "$srcdir/$subdir/cdtest.dat" |
51 | ||
252b5132 RH |
52 | if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] { |
53 | fail $test1 | |
54 | } else { | |
39c183c1 NC |
55 | send_log "tmpdir/cdtest >tmpdir/cdtest.out\n" |
56 | verbose "tmpdir/cdtest >tmpdir/cdtest.out" | |
252b5132 | 57 | catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output |
39c183c1 | 58 | |
252b5132 RH |
59 | if ![string match "" $exec_output] then { |
60 | send_log "$exec_output\n" | |
61 | verbose "$exec_output" 1 | |
39c183c1 | 62 | |
252b5132 RH |
63 | fail $test1 |
64 | } else { | |
39c183c1 NC |
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 | |
252b5132 RH |
68 | set exec_output [prune_warnings $exec_output] |
69 | ||
39c183c1 NC |
70 | if ![string match "" $exec_output] then { |
71 | send_log "$exec_output\n" | |
72 | verbose "$exec_output" 1 | |
73 | ||
74 | send_log "Checking against Named Return Value optimization\n" | |
75 | verbose "Checking against Named Return Value optimization" 1 | |
76 | ||
77 | set expected_output "$srcdir/$subdir/cdtest-nrv.dat" | |
78 | ||
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] | |
83 | } | |
84 | ||
252b5132 RH |
85 | if [string match "" $exec_output] then { |
86 | pass $test1 | |
87 | } else { | |
88 | send_log "$exec_output\n" | |
39c183c1 NC |
89 | verbose "$exec_output" 1 |
90 | ||
252b5132 RH |
91 | fail $test1 |
92 | } | |
93 | } | |
94 | } | |
95 | ||
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 { | |
39c183c1 NC |
102 | send_log "tmpdir/cdtest >tmpdir/cdtest.out\n" |
103 | verbose "tmpdir/cdtest >tmpdir/cdtest.out" | |
252b5132 | 104 | catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output |
39c183c1 | 105 | |
252b5132 RH |
106 | if ![string match "" $exec_output] then { |
107 | send_log "$exec_output\n" | |
39c183c1 NC |
108 | verbose "$exec_output" 1 |
109 | ||
252b5132 RH |
110 | fail $test2 |
111 | } else { | |
39c183c1 NC |
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 | |
252b5132 RH |
115 | set exec_output [prune_warnings $exec_output] |
116 | ||
117 | if [string match "" $exec_output] then { | |
118 | pass $test2 | |
119 | } else { | |
120 | send_log "$exec_output\n" | |
39c183c1 NC |
121 | verbose "$exec_output" 1 |
122 | ||
252b5132 RH |
123 | fail $test2 |
124 | } | |
125 | } | |
126 | } | |
127 | } |