1 # Copyright (C) 2001, 2003 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 2 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 this program; if not, write to the Free Software
15 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # ${tool}_check_compile -- Reports and returns pass/fail for a compilation
21 proc ${tool}_check_compile {testcase option objname gcc_output} {
23 set fatal_signal "*cc: Internal compiler error: program*got fatal signal"
25 if [string match "$fatal_signal 6" $gcc_output] then {
26 ${tool}_fail $testcase "Got Signal 6, $option"
30 if [string match "$fatal_signal 11" $gcc_output] then {
31 ${tool}_fail $testcase "Got Signal 11, $option"
35 # We shouldn't get these because of -w, but just in case.
36 if [string match "*cc:*warning:*" $gcc_output] then {
37 warning "$testcase: (with warnings) $option"
38 send_log "$gcc_output\n"
39 unresolved "$testcase, $option"
43 set gcc_output [prune_warnings $gcc_output]
45 set unsupported_message [${tool}_check_unsupported_p $gcc_output]
46 if { $unsupported_message != "" } {
47 unsupported "$testcase: $unsupported_message"
51 # remove any leftover LF/CR to make sure any output is legit
52 regsub -all -- "\[\r\n\]*" $gcc_output "" gcc_output
54 # If any message remains, we fail.
55 if ![string match "" $gcc_output] then {
56 ${tool}_fail $testcase $option
60 # fail if the desired object file doesn't exist.
61 # FIXME: there's no way of checking for existence on a remote host.
62 if {$objname != "" && ![is3way] && ![file exists $objname]} {
63 ${tool}_fail $testcase $option
67 ${tool}_pass $testcase $option
72 # ${tool}_pass -- utility to record a testcase passed
75 proc ${tool}_pass { testcase cflags } {
76 if { "$cflags" == "" } {
79 pass "$testcase, $cflags"
84 # ${tool}_fail -- utility to record a testcase failed
87 proc ${tool}_fail { testcase cflags } {
88 if { "$cflags" == "" } {
91 fail "$testcase, $cflags"
96 # ${tool}_finish -- called at the end of every script that calls ${tool}_init
98 # Hide all quirks of the testing environment from the testsuites. Also
99 # undo anything that ${tool}_init did that needs undoing.
102 proc ${tool}_finish { } {
103 # The testing harness apparently requires this.
106 if [info exists errorInfo] then {
110 # Might as well reset these (keeps our caller from wondering whether
111 # s/he has to or not).
112 global prms_id bug_id
118 # ${tool}_exit -- Does final cleanup when testing is complete
121 proc ${tool}_exit { } {
124 if [info exists gluefile] {
125 file_on_build delete $gluefile;
131 # ${tool}_check_unsupported_p -- Check the compiler(/assembler/linker) output
132 # for text indicating that the testcase should be marked as "unsupported"
134 # Utility used by mike-gcc.exp and c-torture.exp.
135 # When dealing with a large number of tests, it's difficult to weed out the
136 # ones that are too big for a particular cpu (eg: 16 bit with a small amount
137 # of memory). There are various ways to deal with this. Here's one.
138 # Fortunately, all of the cases where this is likely to happen will be using
139 # gld so we can tell what the error text will look like.
142 proc ${tool}_check_unsupported_p { output } {
143 if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
150 # runtest_file_p -- Provide a definition for older dejagnu releases
151 # and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
152 # (delete after next dejagnu release).
155 if { [info procs runtest_file_p] == "" } then {
156 proc runtest_file_p { runtests testcase } {
157 if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
158 if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
168 # Record additional sources files that must be compiled along with the
171 set additional_sources ""
173 proc dg-additional-sources { args } {
174 global additional_sources
175 set additional_sources [lindex $args 1]
178 # Record additional files -- other than source files -- that must be
179 # present on the system where the compiler runs.
181 set additional_files ""
183 proc dg-additional-files { args } {
184 global additional_files
185 set additional_files [lindex $args 1]
188 # Return an updated version of OPTIONS that mentions any additional
189 # source files registered with dg-additional-sources. SOURCE is the
190 # name of the test case.
192 proc dg-additional-files-options { options source } {
193 global additional_sources
194 global additional_files
195 set to_download [list]
196 if { $additional_sources != "" } then {
197 if [is_remote host] {
198 lappend options "additional_flags=$additional_sources"
200 regsub -all "^| " $additional_sources " [file dirname $source]/" additional_sources
201 if ![is_remote host] {
202 lappend options "additional_flags=$additional_sources"
204 set to_download [concat $to_download $additional_sources]
205 set additional_sources ""
207 if { $additional_files != "" } then {
208 regsub -all " " $additional_files " [file dirname $source]/" additional_files
209 set to_download [concat $to_download $additional_files]
210 set additional_files ""
212 if [is_remote host] {
213 foreach file $to_download {
214 remote_download host $file