OSDN Git Service

Update FSF addresses
[pf3gnuchains/pf3gnuchains4x.git] / ld / testsuite / ld-cdtest / cdtest.exp
1 # Expect script for LD cdtest Tests
2 #   Copyright 1993, 1994, 1995, 1997, 2001, 2004
3 #   Free Software Foundation, Inc.
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
17 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
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
25 set test1 "cdtest"
26 set test2 "cdtest with -Ur"
27
28 # This test requires running the executable generated by ld.
29 if ![isnative] {
30     return
31 }
32
33 if { [which $CXX] == 0 } {
34     untested $test1
35     untested $test2
36     return
37 }
38
39 if {   ![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] } {
42     unresolved $test1
43     unresolved $test2
44     return
45 }
46
47 set expected_output "$srcdir/$subdir/cdtest.dat"
48
49 if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
50     fail $test1
51 } else {
52     send_log   "tmpdir/cdtest >tmpdir/cdtest.out\n"
53     verbose    "tmpdir/cdtest >tmpdir/cdtest.out"
54     catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
55
56     if ![string match "" $exec_output] then {
57         send_log "$exec_output\n"
58         verbose "$exec_output" 1
59
60         fail $test1
61     } else {
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
65         set exec_output [prune_warnings $exec_output]
66
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
82         if [string match "" $exec_output] then {
83             pass $test1
84         } else {
85             send_log "$exec_output\n"
86             verbose  "$exec_output" 1
87
88             fail $test1
89         }
90     }
91 }
92
93 if ![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 {
99         send_log   "tmpdir/cdtest >tmpdir/cdtest.out\n"
100         verbose    "tmpdir/cdtest >tmpdir/cdtest.out"
101         catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
102
103         if ![string match "" $exec_output] then {
104             send_log "$exec_output\n"
105             verbose  "$exec_output" 1
106
107             fail $test2
108         } else {
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
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"
118                 verbose  "$exec_output" 1
119
120                 fail $test2
121             }
122         }
123     }
124 }