Commit | Line | Data |
---|---|---|
252b5132 | 1 | # Expect script for LD cdtest Tests |
39c183c1 | 2 | # Copyright 1993, 1994, 1995, 1997, 2001 Free Software Foundation, Inc. |
252b5132 RH |
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | # | |
18 | # Written by Jeffrey Wheat (cassidy@cygnus.com) | |
19 | # Rewritten by Ian Lance Taylor (ian@cygnus.com) | |
20 | # | |
21 | ||
22 | # Make sure that constructors are handled correctly. | |
23 | ||
24 | set test1 "cdtest" | |
25 | set test2 "cdtest with -Ur" | |
26 | ||
27 | # This test requires running the executable generated by ld. | |
28 | if ![isnative] { | |
29 | return | |
30 | } | |
31 | ||
32 | if { [which $CXX] == 0 } { | |
33 | untested $test1 | |
34 | untested $test2 | |
35 | return | |
36 | } | |
37 | ||
39c183c1 NC |
38 | if { ![ld_compile "$CXX $CXXFLAGS -fgnu-linker -fno-exceptions" $srcdir/$subdir/cdtest-foo.cc tmpdir/cdtest-foo.o] |
39 | || ![ld_compile "$CXX $CXXFLAGS -fgnu-linker -fno-exceptions" $srcdir/$subdir/cdtest-bar.cc tmpdir/cdtest-bar.o] | |
40 | || ![ld_compile "$CXX $CXXFLAGS -fgnu-linker -fno-exceptions" $srcdir/$subdir/cdtest-main.cc tmpdir/cdtest-main.o] } { | |
252b5132 RH |
41 | unresolved $test1 |
42 | unresolved $test2 | |
43 | return | |
44 | } | |
45 | ||
39c183c1 NC |
46 | set expected_output "$srcdir/$subdir/cdtest.dat" |
47 | ||
252b5132 RH |
48 | if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] { |
49 | fail $test1 | |
50 | } else { | |
39c183c1 NC |
51 | send_log "tmpdir/cdtest >tmpdir/cdtest.out\n" |
52 | verbose "tmpdir/cdtest >tmpdir/cdtest.out" | |
252b5132 | 53 | catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output |
39c183c1 | 54 | |
252b5132 RH |
55 | if ![string match "" $exec_output] then { |
56 | send_log "$exec_output\n" | |
57 | verbose "$exec_output" 1 | |
39c183c1 | 58 | |
252b5132 RH |
59 | fail $test1 |
60 | } else { | |
39c183c1 NC |
61 | send_log "diff tmpdir/cdtest.out $expected_output\n" |
62 | verbose "diff tmpdir/cdtest.out $expected_output" | |
63 | catch "exec diff tmpdir/cdtest.out $expected_output" exec_output | |
252b5132 RH |
64 | set exec_output [prune_warnings $exec_output] |
65 | ||
39c183c1 NC |
66 | if ![string match "" $exec_output] then { |
67 | send_log "$exec_output\n" | |
68 | verbose "$exec_output" 1 | |
69 | ||
70 | send_log "Checking against Named Return Value optimization\n" | |
71 | verbose "Checking against Named Return Value optimization" 1 | |
72 | ||
73 | set expected_output "$srcdir/$subdir/cdtest-nrv.dat" | |
74 | ||
75 | send_log "diff tmpdir/cdtest.out $expected_output\n" | |
76 | verbose "diff tmpdir/cdtest.out $expected_output" | |
77 | catch "exec diff tmpdir/cdtest.out $expected_output" exec_output | |
78 | set exec_output [prune_warnings $exec_output] | |
79 | } | |
80 | ||
252b5132 RH |
81 | if [string match "" $exec_output] then { |
82 | pass $test1 | |
83 | } else { | |
84 | send_log "$exec_output\n" | |
39c183c1 NC |
85 | verbose "$exec_output" 1 |
86 | ||
252b5132 RH |
87 | fail $test1 |
88 | } | |
89 | } | |
90 | } | |
91 | ||
92 | if ![ld_relocate $ld tmpdir/cdtest.o {-Ur tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] { | |
93 | fail $test2 | |
94 | } else { | |
95 | if ![ld_link $ld tmpdir/cdtest tmpdir/cdtest.o] { | |
96 | fail $test2 | |
97 | } else { | |
39c183c1 NC |
98 | send_log "tmpdir/cdtest >tmpdir/cdtest.out\n" |
99 | verbose "tmpdir/cdtest >tmpdir/cdtest.out" | |
252b5132 | 100 | catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output |
39c183c1 | 101 | |
252b5132 RH |
102 | if ![string match "" $exec_output] then { |
103 | send_log "$exec_output\n" | |
39c183c1 NC |
104 | verbose "$exec_output" 1 |
105 | ||
252b5132 RH |
106 | fail $test2 |
107 | } else { | |
39c183c1 NC |
108 | send_log "diff tmpdir/cdtest.out $expected_output\n" |
109 | verbose "diff tmpdir/cdtest.out $expected_output" | |
110 | catch "exec diff tmpdir/cdtest.out $expected_output" exec_output | |
252b5132 RH |
111 | set exec_output [prune_warnings $exec_output] |
112 | ||
113 | if [string match "" $exec_output] then { | |
114 | pass $test2 | |
115 | } else { | |
116 | send_log "$exec_output\n" | |
39c183c1 NC |
117 | verbose "$exec_output" 1 |
118 | ||
252b5132 RH |
119 | fail $test2 |
120 | } | |
121 | } | |
122 | } | |
123 | } |