1 # Expect script
for LD cdtest Tests
2 # Copyright
(C
) 1993-2019 Free Software Foundation
, Inc.
4 # This file is part of the GNU Binutils.
6 # This
program is free software
; you can redistribute it and
/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation
; either version
3 of the License
, or
9 #
(at your option
) any later version.
11 # This
program is distributed in the hope that it will be useful
,
12 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License
for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this
program; if not
, write to the Free Software
18 # Foundation
, Inc.
, 51 Franklin Street
- Fifth Floor
, Boston
,
21 # Written by Jeffrey Wheat
(cassidy@cygnus.com
)
22 # Rewritten by Ian Lance Taylor
(ian@cygnus.com
)
25 # Make sure that constructors are handled correctly.
28 set test2
"cdtest with -Ur"
30 # This test requires running the executable generated by
ld.
35 if { [which $CXX
] == 0 } {
41 if { ![ld_compile
"$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-foo.cc tmpdir/cdtest-foo.o]
42 ||
![ld_compile
"$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-bar.cc tmpdir/cdtest-bar.o]
43 ||
![ld_compile
"$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-main.cc tmpdir/cdtest-main.o] } {
49 set expected_output
"$srcdir/$subdir/cdtest.dat"
51 if ![ld_link $CC tmpdir
/cdtest
{tmpdir
/cdtest
-foo.o tmpdir
/cdtest
-bar.o tmpdir
/cdtest
-main.o
}] {
54 send_log
"tmpdir/cdtest >tmpdir/cdtest.out\n"
55 verbose
"tmpdir/cdtest >tmpdir/cdtest.out"
56 catch
"exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
58 if ![string match
"" $exec_output] then {
59 send_log
"$exec_output\n"
60 verbose
"$exec_output" 1
64 send_log
"diff tmpdir/cdtest.out $expected_output\n"
65 verbose
"diff tmpdir/cdtest.out $expected_output"
66 catch
"exec diff tmpdir/cdtest.out $expected_output" exec_output
67 set exec_output
[prune_warnings $exec_output
]
69 if ![string match
"" $exec_output] then {
70 send_log
"$exec_output\n"
71 verbose
"$exec_output" 1
73 send_log
"Checking against Named Return Value optimization\n"
74 verbose
"Checking against Named Return Value optimization" 1
76 set expected_output
"$srcdir/$subdir/cdtest-nrv.dat"
78 send_log
"diff tmpdir/cdtest.out $expected_output\n"
79 verbose
"diff tmpdir/cdtest.out $expected_output"
80 catch
"exec diff tmpdir/cdtest.out $expected_output" exec_output
81 set exec_output
[prune_warnings $exec_output
]
84 if [string match
"" $exec_output] then {
87 send_log
"$exec_output\n"
88 verbose
"$exec_output" 1
95 if ![ld_relocate $
ld tmpdir
/cdtest.o
{-Ur tmpdir
/cdtest
-foo.o tmpdir
/cdtest
-bar.o tmpdir
/cdtest
-main.o
}] {
98 if ![ld_link $CC tmpdir
/cdtest tmpdir
/cdtest.o
] {
101 send_log
"tmpdir/cdtest >tmpdir/cdtest.out\n"
102 verbose
"tmpdir/cdtest >tmpdir/cdtest.out"
103 catch
"exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
105 if ![string match
"" $exec_output] then {
106 send_log
"$exec_output\n"
107 verbose
"$exec_output" 1
111 send_log
"diff tmpdir/cdtest.out $expected_output\n"
112 verbose
"diff tmpdir/cdtest.out $expected_output"
113 catch
"exec diff tmpdir/cdtest.out $expected_output" exec_output
114 set exec_output
[prune_warnings $exec_output
]
116 if [string match
"" $exec_output] then {
119 send_log
"$exec_output\n"
120 verbose
"$exec_output" 1