libgfortran/ChangeLog:
[official-gcc.git] / gcc / testsuite / lib / gcc-defs.exp
blob69a597162b0e3c18456447dd195e259d9267ff1d
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.
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.
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
19 load_lib wrapper.exp
22 # ${tool}_check_compile -- Reports and returns pass/fail for a compilation
25 proc ${tool}_check_compile {testcase option objname gcc_output} {
26 global tool
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"
31 return 0
34 if [string match "$fatal_signal 11" $gcc_output] then {
35 ${tool}_fail $testcase "Got Signal 11, $option"
36 return 0
39 if [string match "*internal compiler error*" $gcc_output] then {
40 ${tool}_fail $testcase "$option (internal compiler error)"
41 return 0
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"
49 return 0
52 set gcc_output [prune_warnings $gcc_output]
54 if { [info proc ${tool}-dg-prune] != "" } {
55 global target_triplet
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"
62 return 0
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
71 return 0
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
78 return 0
81 ${tool}_pass $testcase $option
82 return 1
86 # ${tool}_pass -- utility to record a testcase passed
89 proc ${tool}_pass { testcase cflags } {
90 if { "$cflags" == "" } {
91 pass "$testcase"
92 } else {
93 pass "$testcase, $cflags"
98 # ${tool}_fail -- utility to record a testcase failed
101 proc ${tool}_fail { testcase cflags } {
102 if { "$cflags" == "" } {
103 fail "$testcase"
104 } else {
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.
118 global errorInfo
120 if [info exists errorInfo] then {
121 unset errorInfo
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
127 set prms_id 0
128 set bug_id 0
132 # ${tool}_exit -- Does final cleanup when testing is complete
135 proc ${tool}_exit { } {
136 global gluefile
138 if [info exists gluefile] {
139 file_on_build delete $gluefile
140 unset 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] {
158 return "memory full"
160 if { [istarget spu-*-*] && \
161 [string match "*exceeds local store*" $output] } {
162 return "memory full"
164 return ""
168 # runtest_file_p -- Provide a definition for older dejagnu releases
169 # and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
170 # (delete after next dejagnu release).
173 if { [info procs runtest_file_p] == "" } then {
174 proc runtest_file_p { runtests testcase } {
175 if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
176 if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
177 return 1
178 } else {
179 return 0
182 return 1
186 # Like dg-options, but adds to the default options rather than replacing them.
188 proc dg-additional-options { args } {
189 upvar dg-extra-tool-flags extra-tool-flags
191 if { [llength $args] > 3 } {
192 error "[lindex $args 0]: too many arguments"
193 return
196 if { [llength $args] >= 3 } {
197 switch [dg-process-target [lindex $args 2]] {
198 "S" { eval lappend extra-tool-flags [lindex $args 1] }
199 "N" { }
200 "F" { error "[lindex $args 0]: `xfail' not allowed here" }
201 "P" { error "[lindex $args 0]: `xfail' not allowed here" }
203 } else {
204 eval lappend extra-tool-flags [lindex $args 1]
208 # Record additional sources files that must be compiled along with the
209 # main source file.
211 set additional_sources ""
213 proc dg-additional-sources { args } {
214 global additional_sources
215 set additional_sources [lindex $args 1]
218 # Record additional files -- other than source files -- that must be
219 # present on the system where the compiler runs.
221 set additional_files ""
223 proc dg-additional-files { args } {
224 global additional_files
225 set additional_files [lindex $args 1]
228 # Return an updated version of OPTIONS that mentions any additional
229 # source files registered with dg-additional-sources. SOURCE is the
230 # name of the test case.
232 proc dg-additional-files-options { options source } {
233 global additional_sources
234 global additional_files
235 set to_download [list]
236 if { $additional_sources != "" } then {
237 if [is_remote host] {
238 lappend options "additional_flags=$additional_sources"
240 regsub -all "^| " $additional_sources " [file dirname $source]/" additional_sources
241 if ![is_remote host] {
242 lappend options "additional_flags=$additional_sources"
244 set to_download [concat $to_download $additional_sources]
245 set additional_sources ""
247 if { $additional_files != "" } then {
248 regsub -all "^| " $additional_files " [file dirname $source]/" additional_files
249 set to_download [concat $to_download $additional_files]
250 set additional_files ""
252 if [is_remote host] {
253 foreach file $to_download {
254 remote_download host $file
258 return $options
261 # Return a colon-separate list of directories to search for libraries
262 # for COMPILER, including multilib directories.
264 proc gcc-set-multilib-library-path { compiler } {
265 global rootme
267 # ??? rootme will not be set when testing an installed compiler.
268 # In that case, we should perhaps use some other method to find
269 # libraries.
270 if {![info exists rootme]} {
271 return ""
274 set libpath ":${rootme}"
275 set options [lrange $compiler 1 end]
276 set compiler [lindex $compiler 0]
277 if { [is_remote host] == 0 && [which $compiler] != 0 } {
278 foreach i "[eval exec $compiler $options --print-multi-lib]" {
279 set mldir ""
280 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
281 set mldir [string trimright $mldir "\;@"]
282 if { "$mldir" == "." } {
283 continue
285 if { [llength [glob -nocomplain ${rootme}/${mldir}/libgcc_s*.so.*]] >= 1 } {
286 append libpath ":${rootme}/${mldir}"
291 return $libpath