]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/testsuite/ld-cdtest/cdtest.exp
* bsd-uthread.c (bsd_uthread_wait): Don't try to fetch thread IDs
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-cdtest / cdtest.exp
CommitLineData
252b5132 1# Expect script for LD cdtest Tests
aef6203b
AM
2# Copyright 1993, 1994, 1995, 1997, 2001, 2004
3# Free Software Foundation, Inc.
252b5132
RH
4#
5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
75be928b 17# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
252b5132
RH
18#
19# Written by Jeffrey Wheat (cassidy@cygnus.com)
20# Rewritten by Ian Lance Taylor (ian@cygnus.com)
21#
22
23# Make sure that constructors are handled correctly.
24
25set test1 "cdtest"
26set test2 "cdtest with -Ur"
27
28# This test requires running the executable generated by ld.
29if ![isnative] {
30 return
31}
32
33if { [which $CXX] == 0 } {
34 untested $test1
35 untested $test2
36 return
37}
38
8bfaaee7
AM
39if { ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-foo.cc tmpdir/cdtest-foo.o]
40 || ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-bar.cc tmpdir/cdtest-bar.o]
41 || ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-main.cc tmpdir/cdtest-main.o] } {
252b5132
RH
42 unresolved $test1
43 unresolved $test2
44 return
45}
46
39c183c1
NC
47set expected_output "$srcdir/$subdir/cdtest.dat"
48
252b5132
RH
49if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
50 fail $test1
51} else {
39c183c1
NC
52 send_log "tmpdir/cdtest >tmpdir/cdtest.out\n"
53 verbose "tmpdir/cdtest >tmpdir/cdtest.out"
252b5132 54 catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
39c183c1 55
252b5132
RH
56 if ![string match "" $exec_output] then {
57 send_log "$exec_output\n"
58 verbose "$exec_output" 1
39c183c1 59
252b5132
RH
60 fail $test1
61 } else {
39c183c1
NC
62 send_log "diff tmpdir/cdtest.out $expected_output\n"
63 verbose "diff tmpdir/cdtest.out $expected_output"
64 catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
252b5132
RH
65 set exec_output [prune_warnings $exec_output]
66
39c183c1
NC
67 if ![string match "" $exec_output] then {
68 send_log "$exec_output\n"
69 verbose "$exec_output" 1
70
71 send_log "Checking against Named Return Value optimization\n"
72 verbose "Checking against Named Return Value optimization" 1
73
74 set expected_output "$srcdir/$subdir/cdtest-nrv.dat"
75
76 send_log "diff tmpdir/cdtest.out $expected_output\n"
77 verbose "diff tmpdir/cdtest.out $expected_output"
78 catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
79 set exec_output [prune_warnings $exec_output]
80 }
81
252b5132
RH
82 if [string match "" $exec_output] then {
83 pass $test1
84 } else {
85 send_log "$exec_output\n"
39c183c1
NC
86 verbose "$exec_output" 1
87
252b5132
RH
88 fail $test1
89 }
90 }
91}
92
93if ![ld_relocate $ld tmpdir/cdtest.o {-Ur tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
94 fail $test2
95} else {
96 if ![ld_link $ld tmpdir/cdtest tmpdir/cdtest.o] {
97 fail $test2
98 } else {
39c183c1
NC
99 send_log "tmpdir/cdtest >tmpdir/cdtest.out\n"
100 verbose "tmpdir/cdtest >tmpdir/cdtest.out"
252b5132 101 catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
39c183c1 102
252b5132
RH
103 if ![string match "" $exec_output] then {
104 send_log "$exec_output\n"
39c183c1
NC
105 verbose "$exec_output" 1
106
252b5132
RH
107 fail $test2
108 } else {
39c183c1
NC
109 send_log "diff tmpdir/cdtest.out $expected_output\n"
110 verbose "diff tmpdir/cdtest.out $expected_output"
111 catch "exec diff tmpdir/cdtest.out $expected_output" exec_output
252b5132
RH
112 set exec_output [prune_warnings $exec_output]
113
114 if [string match "" $exec_output] then {
115 pass $test2
116 } else {
117 send_log "$exec_output\n"
39c183c1
NC
118 verbose "$exec_output" 1
119
252b5132
RH
120 fail $test2
121 }
122 }
123 }
124}