1 # Copyright
(C
) 2001-2014 Free Software Foundation
, Inc.
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
3 of the License
, or
6 #
(at your option
) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC
; see the file COPYING3.
If not see
15 #
<http
://www.gnu.org
/licenses
/>.
17 load_lib target
-libpath.exp
22 # $
{tool
}_check_compile
-- Reports and returns pass
/fail
for a compilation
25 proc $
{tool
}_check_compile
{testcase option objname gcc_output
} {
27 set fatal_signal
"*cc: Internal compiler error: program*got fatal signal"
29 if [string match
"$fatal_signal 6" $gcc_output] then {
30 $
{tool
}_fail $testcase
"Got Signal 6, $option"
34 if [string match
"$fatal_signal 11" $gcc_output] then {
35 $
{tool
}_fail $testcase
"Got Signal 11, $option"
39 if [string match
"*internal compiler error*" $gcc_output] then {
40 $
{tool
}_fail $testcase
"$option (internal compiler error)"
44 # We shouldn
't get these because of -w, but just in case.
45 if [string match "*cc:*warning:*" $gcc_output] then {
46 warning "$testcase: (with warnings) $option"
47 send_log "$gcc_output\n"
48 unresolved "$testcase, $option"
52 set gcc_output [prune_warnings $gcc_output]
54 if { [info proc ${tool}-dg-prune] != "" } {
56 set gcc_output [${tool}-dg-prune $target_triplet $gcc_output]
59 set unsupported_message [${tool}_check_unsupported_p $gcc_output]
60 if { $unsupported_message != "" } {
61 unsupported "$testcase: $unsupported_message"
65 # remove any leftover LF/CR to make sure any output is legit
66 regsub -all -- "\[\r\n\]*" $gcc_output "" gcc_output
68 # If any message remains, we fail.
69 if ![string match "" $gcc_output] then {
70 ${tool}_fail $testcase $option
74 # fail if the desired object file doesn't exist.
75 # FIXME
: there
's no way of checking for existence on a remote host.
76 if {$objname != "" && ![is3way] && ![file exists $objname]} {
77 ${tool}_fail $testcase $option
81 ${tool}_pass $testcase $option
86 # ${tool}_pass -- utility to record a testcase passed
89 proc ${tool}_pass { testcase cflags } {
90 if { "$cflags" == "" } {
93 pass "$testcase, $cflags"
98 # ${tool}_fail -- utility to record a testcase failed
101 proc ${tool}_fail { testcase cflags } {
102 if { "$cflags" == "" } {
105 fail "$testcase, $cflags"
110 # ${tool}_finish -- called at the end of every script that calls ${tool}_init
112 # Hide all quirks of the testing environment from the testsuites. Also
113 # undo anything that ${tool}_init did that needs undoing.
116 proc ${tool}_finish { } {
117 # The testing harness apparently requires this.
120 if [info exists errorInfo] then {
124 # Might as well reset these (keeps our caller from wondering whether
125 # s/he has to or not).
126 global prms_id bug_id
132 # ${tool}_exit -- Does final cleanup when testing is complete
135 proc ${tool}_exit { } {
138 if [info exists gluefile] {
139 file_on_build delete $gluefile
145 # ${tool}_check_unsupported_p -- Check the compiler(/assembler/linker) output
146 # for text indicating that the testcase should be marked as "unsupported"
148 # Utility used by mike-gcc.exp and c-torture.exp.
149 # When dealing with a large number of tests, it's difficult to weed out the
150 # ones that are too big
for a particular cpu
(eg
: 16 bit with a small amount
151 # of memory
). There are various ways to deal with this. Here
's one.
152 # Fortunately, all of the cases where this is likely to happen will be using
153 # gld so we can tell what the error text will look like.
156 proc ${tool}_check_unsupported_p { output } {
157 if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
160 if { [regexp "(^|\n)\[^\n\]*: relocation truncated to fit" $output]
161 && [check_effective_target_tiny] } {
165 if { [istarget spu-*-*] && \
166 [string match "*exceeds local store*" $output] } {
173 # runtest_file_p -- Provide a definition for older dejagnu releases
174 # and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
175 # (delete after next dejagnu release).
178 if { [info procs runtest_file_p] == "" } then {
179 proc runtest_file_p { runtests testcase } {
180 if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
181 if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
191 if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \
192 && [info procs runtest_file_p] != [list] \
193 && [info procs gcc_parallelize_saved_runtest_file_p] == [list] } then {
194 global gcc_runtest_parallelize_counter
195 global gcc_runtest_parallelize_counter_minor
196 global gcc_runtest_parallelize_enable
197 global gcc_runtest_parallelize_dir
198 global gcc_runtest_parallelize_last
200 set gcc_runtest_parallelize_counter 0
201 set gcc_runtest_parallelize_counter_minor 0
202 set gcc_runtest_parallelize_enable 1
203 set gcc_runtest_parallelize_dir [getenv GCC_RUNTEST_PARALLELIZE_DIR]
204 set gcc_runtest_parallelize_last 0
206 proc gcc_parallel_test_run_p { testcase } {
207 global gcc_runtest_parallelize_counter
208 global gcc_runtest_parallelize_counter_minor
209 global gcc_runtest_parallelize_enable
210 global gcc_runtest_parallelize_dir
211 global gcc_runtest_parallelize_last
213 if { $gcc_runtest_parallelize_enable == 0 } {
217 # Only test the filesystem every 10th iteration
218 incr gcc_runtest_parallelize_counter_minor
219 if { $gcc_runtest_parallelize_counter_minor == 10 } {
220 set gcc_runtest_parallelize_counter_minor 0
222 if { $gcc_runtest_parallelize_counter_minor != 1 } {
223 #verbose -log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter $gcc_runtest_parallelize_last"
224 return $gcc_runtest_parallelize_last
227 set path $gcc_runtest_parallelize_dir/$gcc_runtest_parallelize_counter
229 if {![catch {open $path {RDWR CREAT EXCL} 0600} fd]} {
231 set gcc_runtest_parallelize_last 1
232 #verbose -log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter 1"
233 incr gcc_runtest_parallelize_counter
236 set gcc_runtest_parallelize_last 0
237 #verbose -log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter 0"
238 incr gcc_runtest_parallelize_counter
242 proc gcc_parallel_test_enable { val } {
243 global gcc_runtest_parallelize_enable
244 set gcc_runtest_parallelize_enable $val
247 rename runtest_file_p gcc_parallelize_saved_runtest_file_p
248 proc runtest_file_p { runtests testcase } {
249 if ![gcc_parallelize_saved_runtest_file_p $runtests $testcase] {
252 return [gcc_parallel_test_run_p $testcase]
257 proc gcc_parallel_test_run_p { testcase } {
261 proc gcc_parallel_test_enable { val } {
266 # Like dg-options, but adds to the default options rather than replacing them.
268 proc dg-additional-options { args } {
269 upvar dg-extra-tool-flags extra-tool-flags
271 if { [llength $args] > 3 } {
272 error "[lindex $args 0]: too many arguments"
276 if { [llength $args] >= 3 } {
277 switch [dg-process-target [lindex $args 2]] {
278 "S" { eval lappend extra-tool-flags [lindex $args 1] }
280 "F" { error "[lindex $args 0]: `xfail' not allowed here
" }
281 "P" { error "[lindex $args 0]: `xfail' not allowed here" }
284 eval lappend extra
-tool
-flags
[lindex $
args 1]
288 # Record additional sources files that must be compiled along with the
291 set additional_sources
""
293 proc dg
-additional
-sources
{ args } {
294 global additional_sources
295 set additional_sources
[lindex $
args 1]
298 # Record additional files
-- other than source files
-- that must be
299 # present
on the
system where the compiler runs.
301 set additional_files
""
303 proc dg
-additional
-files
{ args } {
304 global additional_files
305 set additional_files
[lindex $
args 1]
308 #
Return an updated version of OPTIONS that mentions
any additional
309 # source files registered with dg
-additional
-sources. SOURCE is the
310 #
name of the test case.
312 proc dg
-additional
-files
-options
{ options source
} {
313 global additional_sources
314 global additional_files
315 set to_download
[list
]
316 if { $additional_sources
!= "" } then {
317 if [is_remote host
] {
318 lappend options
"additional_flags=$additional_sources"
320 regsub
-all
"^| " $additional_sources " [file dirname $source]/" additional_sources
321 if ![is_remote host
] {
322 lappend options
"additional_flags=$additional_sources"
324 set to_download
[concat $to_download $additional_sources
]
325 set additional_sources
""
327 if { $additional_files
!= "" } then {
328 regsub
-all
"^| " $additional_files " [file dirname $source]/" additional_files
329 set to_download
[concat $to_download $additional_files
]
330 set additional_files
""
332 if [is_remote host
] {
333 foreach file $to_download
{
334 remote_download host $file
341 #
Return a colon
-separate list of directories to search
for libraries
342 #
for COMPILER
, including multilib directories.
344 proc gcc
-set-multilib
-library
-path
{ compiler
} {
347 # ??? rootme will not be
set when testing an installed compiler.
348 # In that case
, we should perhaps use some other method to find
350 if {![info exists rootme
]} {
354 set libpath
":${rootme}"
355 set options
[lrange $compiler
1 end
]
356 set compiler
[lindex $compiler
0]
357 if { [is_remote host
] == 0 && [which $compiler
] != 0 } {
358 foreach i
"[eval exec $compiler $options --print-multi-lib]" {
360 regexp
-- "\[a-z0-9=_/\.-\]*;" $i mldir
361 set mldir
[string trimright $mldir
"\;@"]
362 if { "$mldir" == "." } {
365 if { [llength
[glob
-nocomplain $
{rootme
}/$
{mldir
}/libgcc_s
*.so.
*]] >= 1 } {
366 append libpath
":${rootme}/${mldir}"