]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/testsuite/ld-cdtest/cdtest.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-cdtest / cdtest.exp
CommitLineData
252b5132 1# Expect script for LD cdtest Tests
250d07de 2# Copyright (C) 1993-2021 Free Software Foundation, Inc.
252b5132 3#
f96b4a7b
NC
4# This file is part of the GNU Binutils.
5#
6# This program is free software; you can redistribute it and/or modify
252b5132 7# it under the terms of the GNU General Public License as published by
f96b4a7b 8# the Free Software Foundation; either version 3 of the License, or
252b5132 9# (at your option) any later version.
f96b4a7b 10#
252b5132
RH
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.
f96b4a7b 15#
252b5132
RH
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
f96b4a7b
NC
18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19# MA 02110-1301, USA.
252b5132
RH
20#
21# Written by Jeffrey Wheat (cassidy@cygnus.com)
22# Rewritten by Ian Lance Taylor (ian@cygnus.com)
23#
24
25# Make sure that constructors are handled correctly.
26
27set test1 "cdtest"
28set test2 "cdtest with -Ur"
29
30# This test requires running the executable generated by ld.
31if ![isnative] {
32 return
33}
34
35if { [which $CXX] == 0 } {
36 untested $test1
37 untested $test2
38 return
39}
40
8bfaaee7
AM
41if { ![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] } {
252b5132
RH
44 unresolved $test1
45 unresolved $test2
46 return
47}
48
39c183c1
NC
49set expected_output "$srcdir/$subdir/cdtest.dat"
50
d9816402 51if ![ld_link $CC tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
252b5132
RH
52 fail $test1
53} else {
39c183c1
NC
54 send_log "tmpdir/cdtest >tmpdir/cdtest.out\n"
55 verbose "tmpdir/cdtest >tmpdir/cdtest.out"
252b5132 56 catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
39c183c1 57
252b5132
RH
58 if ![string match "" $exec_output] then {
59 send_log "$exec_output\n"
60 verbose "$exec_output" 1
39c183c1 61
252b5132
RH
62 fail $test1
63 } else {
39c183c1
NC
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
252b5132
RH
67 set exec_output [prune_warnings $exec_output]
68
39c183c1
NC
69 if ![string match "" $exec_output] then {
70 send_log "$exec_output\n"
71 verbose "$exec_output" 1
72
73 send_log "Checking against Named Return Value optimization\n"
74 verbose "Checking against Named Return Value optimization" 1
75
76 set expected_output "$srcdir/$subdir/cdtest-nrv.dat"
77
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]
82 }
83
252b5132
RH
84 if [string match "" $exec_output] then {
85 pass $test1
86 } else {
87 send_log "$exec_output\n"
39c183c1
NC
88 verbose "$exec_output" 1
89
252b5132
RH
90 fail $test1
91 }
92 }
93}
94
5b537ffc
AM
95# PR 46
96if [is_pecoff_format] {
97 setup_xfail *-*-*
98}
99
252b5132
RH
100if ![ld_relocate $ld tmpdir/cdtest.o {-Ur tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
101 fail $test2
102} else {
d9816402 103 if ![ld_link $CC tmpdir/cdtest tmpdir/cdtest.o] {
252b5132
RH
104 fail $test2
105 } else {
39c183c1
NC
106 send_log "tmpdir/cdtest >tmpdir/cdtest.out\n"
107 verbose "tmpdir/cdtest >tmpdir/cdtest.out"
252b5132 108 catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
39c183c1 109
252b5132
RH
110 if ![string match "" $exec_output] then {
111 send_log "$exec_output\n"
39c183c1
NC
112 verbose "$exec_output" 1
113
252b5132
RH
114 fail $test2
115 } else {
39c183c1
NC
116 send_log "diff tmpdir/cdtest.out $expected_output\n"
117 verbose "diff tmpdir/cdtest.out $expected_output"
118 catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
252b5132
RH
119 set exec_output [prune_warnings $exec_output]
120
121 if [string match "" $exec_output] then {
122 pass $test2
123 } else {
124 send_log "$exec_output\n"
39c183c1
NC
125 verbose "$exec_output" 1
126
252b5132
RH
127 fail $test2
128 }
129 }
130 }
131}