1 # Copyright (C) 2001, 2003, 2004, 2007 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/>.
20 # ${tool}_check_compile -- Reports and returns pass/fail for a compilation
23 proc ${tool}_check_compile {testcase option objname gcc_output} {
25 set fatal_signal "*cc: Internal compiler error: program*got fatal signal"
27 if [string match "$fatal_signal 6" $gcc_output] then {
28 ${tool}_fail $testcase "Got Signal 6, $option"
32 if [string match "$fatal_signal 11" $gcc_output] then {
33 ${tool}_fail $testcase "Got Signal 11, $option"
37 if [string match "*internal compiler error*" $gcc_output] then {
38 ${tool}_fail $testcase "$option (internal compiler error)"
42 # We shouldn't get these because of -w, but just in case.
43 if [string match "*cc:*warning:*" $gcc_output] then {
44 warning "$testcase: (with warnings) $option"
45 send_log "$gcc_output\n"
46 unresolved "$testcase, $option"
50 set gcc_output [prune_warnings $gcc_output]
52 if { [info proc ${tool}-dg-prune] != "" } {
54 set gcc_output [${tool}-dg-prune $target_triplet $gcc_output]
57 set unsupported_message [${tool}_check_unsupported_p $gcc_output]
58 if { $unsupported_message != "" } {
59 unsupported "$testcase: $unsupported_message"
63 # remove any leftover LF/CR to make sure any output is legit
64 regsub -all -- "\[\r\n\]*" $gcc_output "" gcc_output
66 # If any message remains, we fail.
67 if ![string match "" $gcc_output] then {
68 ${tool}_fail $testcase $option
72 # fail if the desired object file doesn't exist.
73 # FIXME: there's no way of checking for existence on a remote host.
74 if {$objname != "" && ![is3way] && ![file exists $objname]} {
75 ${tool}_fail $testcase $option
79 ${tool}_pass $testcase $option
84 # ${tool}_pass -- utility to record a testcase passed
87 proc ${tool}_pass { testcase cflags } {
88 if { "$cflags" == "" } {
91 pass "$testcase, $cflags"
96 # ${tool}_fail -- utility to record a testcase failed
99 proc ${tool}_fail { testcase cflags } {
100 if { "$cflags" == "" } {
103 fail "$testcase, $cflags"
108 # ${tool}_finish -- called at the end of every script that calls ${tool}_init
110 # Hide all quirks of the testing environment from the testsuites. Also
111 # undo anything that ${tool}_init did that needs undoing.
114 proc ${tool}_finish { } {
115 # The testing harness apparently requires this.
118 if [info exists errorInfo] then {
122 # Might as well reset these (keeps our caller from wondering whether
123 # s/he has to or not).
124 global prms_id bug_id
130 # ${tool}_exit -- Does final cleanup when testing is complete
133 proc ${tool}_exit { } {
136 if [info exists gluefile] {
137 file_on_build delete $gluefile
143 # ${tool}_check_unsupported_p -- Check the compiler(/assembler/linker) output
144 # for text indicating that the testcase should be marked as "unsupported"
146 # Utility used by mike-gcc.exp and c-torture.exp.
147 # When dealing with a large number of tests, it's difficult to weed out the
148 # ones that are too big for a particular cpu (eg: 16 bit with a small amount
149 # of memory). There are various ways to deal with this. Here's one.
150 # Fortunately, all of the cases where this is likely to happen will be using
151 # gld so we can tell what the error text will look like.
154 proc ${tool}_check_unsupported_p { output } {
155 if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
158 if {[istarget spu-*-*] && \
159 [string match "*exceeds local store*" $output]} {
166 # runtest_file_p -- Provide a definition for older dejagnu releases
167 # and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
168 # (delete after next dejagnu release).
171 if { [info procs runtest_file_p] == "" } then {
172 proc runtest_file_p { runtests testcase } {
173 if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
174 if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
184 # Record additional sources files that must be compiled along with the
187 set additional_sources ""
189 proc dg-additional-sources { args } {
190 global additional_sources
191 set additional_sources [lindex $args 1]
194 # Record additional files -- other than source files -- that must be
195 # present on the system where the compiler runs.
197 set additional_files ""
199 proc dg-additional-files { args } {
200 global additional_files
201 set additional_files [lindex $args 1]
204 # Return an updated version of OPTIONS that mentions any additional
205 # source files registered with dg-additional-sources. SOURCE is the
206 # name of the test case.
208 proc dg-additional-files-options { options source } {
209 global additional_sources
210 global additional_files
211 set to_download [list]
212 if { $additional_sources != "" } then {
213 if [is_remote host] {
214 lappend options "additional_flags=$additional_sources"
216 regsub -all "^| " $additional_sources " [file dirname $source]/" additional_sources
217 if ![is_remote host] {
218 lappend options "additional_flags=$additional_sources"
220 set to_download [concat $to_download $additional_sources]
221 set additional_sources ""
223 if { $additional_files != "" } then {
224 regsub -all " " $additional_files " [file dirname $source]/" additional_files
225 set to_download [concat $to_download $additional_files]
226 set additional_files ""
228 if [is_remote host] {
229 foreach file $to_download {
230 remote_download host $file