]>
Commit | Line | Data |
---|---|---|
6b543e86 | 1 | # Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. |
c66ce1f5 BK |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 2 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program; if not, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | # Define libstdc++-v3 callbacks for dg.exp. | |
18 | ||
19 | load_lib dg.exp | |
20 | load_lib libgloss.exp | |
9e78e45a | 21 | load_lib prune.exp |
c66ce1f5 | 22 | |
7db19937 L |
23 | proc libstdc++-v3-copy-files {srcfiles dstdir} { |
24 | foreach f $srcfiles { | |
25 | if { [catch { set symlink [file readlink $f] } x] } then { | |
26 | file copy -force $f $dstdir | |
27 | } else { | |
28 | if { [regexp "^/" "$symlink"] } then { | |
29 | file copy -force $symlink $dstdir | |
30 | } else { | |
31 | set dirname [file dirname $f] | |
32 | file copy -force $dirname/$symlink $dstdir | |
33 | } | |
34 | } | |
35 | } | |
36 | } | |
37 | ||
c66ce1f5 BK |
38 | proc libstdc++-v3-init { args } { |
39 | global srcdir | |
40 | global outdir | |
41 | global blddir | |
42 | global cxx | |
43 | global includes | |
44 | global cxxflags | |
256e7e85 AMT |
45 | global objdir |
46 | global gluefile wrap_flags | |
ec233c75 | 47 | global ld_library_path |
c20d89f5 | 48 | global tool_root_dir |
c66ce1f5 | 49 | |
c20d89f5 | 50 | set blddir [lookfor_file [get_multilibs] libstdc++-v3] |
28e8acb6 | 51 | |
c20d89f5 | 52 | # By default, we assume we want to run program images. |
ec233c75 BK |
53 | global dg-do-what-default |
54 | set dg-do-what-default run | |
55 | ||
56 | # Copy any required data files. | |
23cac885 BK |
57 | libstdc++-v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"] $outdir |
58 | libstdc++-v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"] $outdir | |
59 | ||
60 | # Compute lists of files to test. | |
61 | v3-compute-tests | |
ec233c75 BK |
62 | |
63 | # set LD_LIBRARY_PATH so that libgcc_s, libstdc++ binaries can be found. | |
c20d89f5 RO |
64 | # locate libgcc.a so we don't need to account for different values of |
65 | # SHLIB_EXT on different platforms | |
66 | set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] | |
67 | if {$gccdir != ""} { | |
68 | set gccdir [file dirname $gccdir] | |
69 | } | |
70 | ||
ec233c75 | 71 | set ld_library_path "." |
c20d89f5 | 72 | append ld_library_path ":${gccdir}" |
2937267b JJ |
73 | set compiler ${gccdir}/g++ |
74 | if { [is_remote host] == 0 && [which $compiler] != 0 } { | |
75 | foreach i "[exec $compiler --print-multi-lib]" { | |
76 | set mldir "" | |
77 | regexp -- "\[a-z0-9=/\.-\]*;" $i mldir | |
78 | set mldir [string trimright $mldir "\;@"] | |
79 | if { "$mldir" == "." } { | |
80 | continue | |
81 | } | |
82 | if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] == 1 } { | |
83 | append ld_library_path ":${gccdir}/${mldir}" | |
84 | } | |
85 | } | |
86 | } | |
ec233c75 BK |
87 | append ld_library_path ":${blddir}/src/.libs" |
88 | ||
9a3e5fd3 RO |
89 | # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but |
90 | # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH | |
91 | # (for the 64-bit ABI). The right way to do this would be to modify | |
92 | # unix.exp -- but that's not an option since it's part of DejaGNU | |
93 | # proper, so we do it here. We really only need to do | |
94 | # this on IRIX, but it shouldn't hurt to do it anywhere else. | |
95 | setenv LD_LIBRARY_PATH $ld_library_path | |
96 | setenv SHLIB_PATH $ld_library_path | |
97 | setenv LD_LIBRARYN32_PATH $ld_library_path | |
98 | setenv LD_LIBRARY64_PATH $ld_library_path | |
99 | ||
ec233c75 BK |
100 | # Do a bunch of handstands and backflips for cross compiling and |
101 | # finding simulators... | |
28e8acb6 | 102 | if [is_remote host] { |
fe413112 | 103 | set header [remote_download host ${blddir}/testsuite/testsuite_hooks.h] |
28e8acb6 | 104 | if { $header == "" } { |
fe413112 | 105 | verbose -log "Unable to download ${blddir}/testsuite/testsuite_hooks.h to host." |
28e8acb6 AMT |
106 | return "untested" |
107 | } | |
108 | set cxx [transform "g++"] | |
109 | set cxxflags "-ggdb3 -DDEBUG_ASSERT" | |
ffe94f83 | 110 | set includes "-I./" |
28e8acb6 AMT |
111 | } else { |
112 | # If we find a testsuite_flags file, we're testing in the build dir. | |
113 | set flags_file "${blddir}/testsuite_flags" | |
114 | if { [file exists $flags_file] } { | |
115 | set cxx [exec sh $flags_file --build-cxx] | |
116 | set cxxflags [exec sh $flags_file --cxxflags] | |
117 | set includes [exec sh $flags_file --build-includes] | |
118 | } else { | |
119 | set cxx [transform "g++"] | |
120 | set cxxflags "-ggdb3 -DDEBUG_ASSERT" | |
121 | set includes "-I${srcdir}" | |
122 | } | |
123 | } | |
c66ce1f5 | 124 | |
6746a299 NC |
125 | if { [target_info needs_status_wrapper]!=""} { |
126 | file delete ${objdir}/testglue.o; | |
256e7e85 AMT |
127 | set gluefile ${objdir}/testglue.o; |
128 | set result [build_wrapper $gluefile]; | |
129 | if { $result != "" } { | |
130 | set gluefile [lindex $result 0]; | |
131 | set wrap_flags [lindex $result 1]; | |
132 | } else { | |
133 | unset gluefile | |
134 | } | |
135 | } | |
c66ce1f5 BK |
136 | } |
137 | ||
138 | proc libstdc++-v3-dg-test { prog do_what extra_tool_flags } { | |
139 | # Set up the compiler flags, based on what we're going to do. | |
140 | ||
141 | switch $do_what { | |
142 | "preprocess" { | |
143 | set compile_type "preprocess" | |
144 | set output_file "[file rootname [file tail $prog]].i" | |
145 | } | |
146 | "compile" { | |
147 | set compile_type "assembly" | |
148 | set output_file "[file rootname [file tail $prog]].s" | |
149 | } | |
150 | "assemble" { | |
151 | set compile_type "object" | |
152 | set output_file "[file rootname [file tail $prog]].o" | |
153 | } | |
154 | "link" { | |
155 | set compile_type "executable" | |
c6d96f20 | 156 | set output_file "./[file rootname [file tail $prog]].exe" |
c66ce1f5 BK |
157 | } |
158 | "run" { | |
159 | set compile_type "executable" | |
160 | # FIXME: "./" is to cope with "." not being in $PATH. | |
161 | # Should this be handled elsewhere? | |
162 | # YES. | |
c6d96f20 | 163 | set output_file "./[file rootname [file tail $prog]].exe" |
c66ce1f5 BK |
164 | # This is the only place where we care if an executable was |
165 | # created or not. If it was, dg.exp will try to run it. | |
166 | remote_file build delete $output_file; | |
167 | } | |
168 | default { | |
169 | perror "$do_what: not a valid dg-do keyword" | |
170 | return "" | |
171 | } | |
172 | } | |
173 | set options "" | |
174 | if { $extra_tool_flags != "" } { | |
175 | lappend options "additional_flags=$extra_tool_flags" | |
176 | } | |
177 | ||
178 | set comp_output [libstdc++-v3_target_compile "$prog" "$output_file" "$compile_type" $options]; | |
9e78e45a | 179 | set comp_output [ prune_g++_output $comp_output ]; |
c66ce1f5 BK |
180 | |
181 | return [list $comp_output $output_file] | |
182 | } | |
183 | ||
184 | ||
185 | proc libstdc++-v3_target_compile { source dest type options } { | |
186 | global gluefile | |
187 | global wrap_flags | |
188 | global cxx | |
189 | global cxxflags | |
190 | global includes | |
d6c7e073 | 191 | global blddir |
c66ce1f5 BK |
192 | |
193 | if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { | |
194 | lappend options "libs=${gluefile}" | |
195 | lappend options "ldflags=${wrap_flags}" | |
196 | } | |
197 | ||
198 | set cxx_final $cxx | |
199 | set cxxlibglossflags [libgloss_link_flags] | |
200 | set cxx_final [concat $cxx_final $cxxlibglossflags] | |
201 | set cxx_final [concat $cxx_final $cxxflags] | |
202 | set cxx_final [concat $cxx_final $includes] | |
c6192d88 | 203 | |
8ea08b7d PE |
204 | lappend options "compiler=$cxx_final" |
205 | ||
d6c7e073 RO |
206 | # Picks up the freshly-built testsuite library corresponding to the |
207 | # multilib under test. | |
208 | lappend options "ldflags=-L${blddir}/testsuite" | |
8ea08b7d | 209 | lappend options "libs=-lv3test" |
c66ce1f5 BK |
210 | |
211 | return [target_compile $source $dest $type $options] | |
212 | } | |
213 | ||
abd3d600 | 214 | |
23cac885 BK |
215 | # Constructs lists of source files (full pathnames) to test. Two |
216 | # files are constructed: testsuite_files, which is used to test with | |
217 | # the default dg-runtest command, and testsuite_files_interactive, | |
218 | # which is used to test cases that require input to be entered. In | |
219 | # addition, both lists are pruned of wchar_t tests if the toolchain | |
220 | # under test does not support wchar_t functionality. | |
221 | # | |
222 | # We mimic the mkcheck script in that the first time this is run, all | |
223 | # existing files are listed in "testsuite_files" in the output | |
224 | # directory. Subsequent runs pull the list from that file, allowing | |
225 | # users to trim the list down to problematic tests, or just run | |
226 | # paticular directories or sub-directories of tests. | |
227 | # | |
228 | # Selecting individual tests can also be done with RUNTESTFLAGS, but | |
229 | # that doesn't really do all that we are trying to accomplish here. | |
230 | proc v3-compute-tests { } { | |
abd3d600 PE |
231 | global srcdir |
232 | global outdir | |
233 | ||
23cac885 BK |
234 | set tests_file "${outdir}/testsuite_files" |
235 | set tests_file_inter "${outdir}/testsuite_files_interactive" | |
abd3d600 | 236 | set sfiles "" |
23cac885 BK |
237 | |
238 | # If there is a testsuite_file, use it. | |
239 | if { [file exists $tests_file] } { | |
240 | return | |
241 | } | |
242 | ||
243 | # If not, generate it. | |
244 | set where_we_were [pwd] | |
245 | cd $srcdir | |
246 | foreach s [lsort [glob -nocomplain "*/*.cc" "*/*/*.cc" "{,*/}*/*/*/*.cc" ]] { | |
247 | lappend sfiles ${s} | |
abd3d600 | 248 | } |
23cac885 | 249 | cd $where_we_were |
abd3d600 | 250 | |
23cac885 | 251 | # Filter wchar_t tests. |
6b543e86 BK |
252 | # Disable wchar_t tests if library not configured to support |
253 | # wchar_t testing. | |
254 | set wchar_file "${outdir}/testsuite_wchar_t" | |
23cac885 | 255 | if { ! [file exists $wchar_file] } { |
6b543e86 BK |
256 | # Remove wchar_t tests files from list. |
257 | set res {} | |
258 | foreach w $sfiles { | |
259 | if [regexp "wchar_t" $w] { | |
23cac885 | 260 | verbose "element wchar list is $w" |
6b543e86 | 261 | } else { |
23cac885 | 262 | verbose "element non-wchar list is $w" |
6b543e86 BK |
263 | lappend res $w |
264 | } | |
265 | } | |
23cac885 BK |
266 | set sfiles ${res} |
267 | } | |
268 | ||
269 | # Filter interactive tests. | |
270 | # Use special rules to run these tests. | |
271 | set restwo {} | |
272 | set sfiles_inter {} | |
273 | foreach i $sfiles { | |
274 | if [regexp "_xin" $i] { | |
275 | verbose "element interactive list is $i" | |
276 | lappend sfiles_inter $i | |
277 | } else { | |
278 | verbose "element non-interactive list is $i" | |
279 | lappend restwo $i | |
280 | } | |
281 | } | |
282 | set sfiles ${restwo} | |
283 | ||
284 | # Write out testsuite_files. | |
285 | set f [open $tests_file "w"] | |
286 | foreach t $sfiles { | |
287 | puts $f $t | |
288 | } | |
289 | close $f | |
290 | ||
291 | # Write out testsuite_files_interactive. | |
292 | set f [open $tests_file_inter "w"] | |
293 | foreach t $sfiles_inter { | |
294 | puts $f $t | |
295 | } | |
296 | close $f | |
297 | } | |
298 | ||
299 | proc v3-list-tests { filename } { | |
300 | global srcdir | |
301 | global outdir | |
302 | ||
303 | set tests_file "${outdir}/${filename}" | |
304 | set sfiles "" | |
305 | ||
306 | # If there is a testsuite_file, use it. | |
307 | if { [file exists $tests_file] } { | |
308 | set f [open $tests_file] | |
309 | while { ! [eof $f] } { | |
310 | set t [gets $f] | |
311 | if { [string length "$t"] != 0 } { | |
312 | lappend sfiles ${srcdir}/${t} | |
313 | } | |
314 | } | |
315 | close $f | |
316 | } else { | |
317 | verbose "cannot open $tests_file" | |
6b543e86 | 318 | } |
23cac885 | 319 | return $sfiles |
6b543e86 | 320 | } |