1 # Copyright
(C
) 2001, 2003, 2004 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
, 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA.
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 set unsupported_message [${tool}_check_unsupported_p $gcc_output]
53 if { $unsupported_message != "" } {
54 unsupported "$testcase: $unsupported_message"
58 # remove any leftover LF/CR to make sure any output is legit
59 regsub -all -- "\[\r\n\]*" $gcc_output "" gcc_output
61 # If any message remains, we fail.
62 if ![string match "" $gcc_output] then {
63 ${tool}_fail $testcase $option
67 # fail if the desired object file doesn't exist.
68 # FIXME
: there
's no way of checking for existence on a remote host.
69 if {$objname != "" && ![is3way] && ![file exists $objname]} {
70 ${tool}_fail $testcase $option
74 ${tool}_pass $testcase $option
79 # ${tool}_pass -- utility to record a testcase passed
82 proc ${tool}_pass { testcase cflags } {
83 if { "$cflags" == "" } {
86 pass "$testcase, $cflags"
91 # ${tool}_fail -- utility to record a testcase failed
94 proc ${tool}_fail { testcase cflags } {
95 if { "$cflags" == "" } {
98 fail "$testcase, $cflags"
103 # ${tool}_finish -- called at the end of every script that calls ${tool}_init
105 # Hide all quirks of the testing environment from the testsuites. Also
106 # undo anything that ${tool}_init did that needs undoing.
109 proc ${tool}_finish { } {
110 # The testing harness apparently requires this.
113 if [info exists errorInfo] then {
117 # Might as well reset these (keeps our caller from wondering whether
118 # s/he has to or not).
119 global prms_id bug_id
125 # ${tool}_exit -- Does final cleanup when testing is complete
128 proc ${tool}_exit { } {
131 if [info exists gluefile] {
132 file_on_build delete $gluefile
138 # ${tool}_check_unsupported_p -- Check the compiler(/assembler/linker) output
139 # for text indicating that the testcase should be marked as "unsupported"
141 # Utility used by mike-gcc.exp and c-torture.exp.
142 # When dealing with a large number of tests, it's difficult to weed out the
143 # ones that are too big
for a particular cpu
(eg
: 16 bit with a small amount
144 # of memory
). There are various ways to deal with this. Here
's one.
145 # Fortunately, all of the cases where this is likely to happen will be using
146 # gld so we can tell what the error text will look like.
149 proc ${tool}_check_unsupported_p { output } {
150 if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
157 # runtest_file_p -- Provide a definition for older dejagnu releases
158 # and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
159 # (delete after next dejagnu release).
162 if { [info procs runtest_file_p] == "" } then {
163 proc runtest_file_p { runtests testcase } {
164 if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
165 if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
175 # Record additional sources files that must be compiled along with the
178 set additional_sources ""
180 proc dg-additional-sources { args } {
181 global additional_sources
182 set additional_sources [lindex $args 1]
185 # Record additional files -- other than source files -- that must be
186 # present on the system where the compiler runs.
188 set additional_files ""
190 proc dg-additional-files { args } {
191 global additional_files
192 set additional_files [lindex $args 1]
195 # Return an updated version of OPTIONS that mentions any additional
196 # source files registered with dg-additional-sources. SOURCE is the
197 # name of the test case.
199 proc dg-additional-files-options { options source } {
200 global additional_sources
201 global additional_files
202 set to_download [list]
203 if { $additional_sources != "" } then {
204 if [is_remote host] {
205 lappend options "additional_flags=$additional_sources"
207 regsub -all "^| " $additional_sources " [file dirname $source]/" additional_sources
208 if ![is_remote host] {
209 lappend options "additional_flags=$additional_sources"
211 set to_download [concat $to_download $additional_sources]
212 set additional_sources ""
214 if { $additional_files != "" } then {
215 regsub -all " " $additional_files " [file dirname $source]/" additional_files
216 set to_download [concat $to_download $additional_files]
217 set additional_files ""
219 if [is_remote host] {
220 foreach file $to_download {
221 remote_download host $file
228 # Return a colon-separate list of directories to search for libraries
229 # for COMPILER, including multilib directories.
231 proc gcc-set-multilib-library-path { compiler } {
234 # ??? rootme will not be set when testing an installed compiler.
235 # In that case, we should perhaps use some other method to find
237 if {![info exists rootme]} {
241 set libpath ":${rootme}"
242 set compiler [lindex $compiler 0]
243 if { [is_remote host] == 0 && [which $compiler] != 0 } {
244 foreach i "[exec $compiler --print-multi-lib]" {
246 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
247 set mldir [string trimright $mldir "\;@"]
248 if { "$mldir" == "." } {
251 if { [llength [glob -nocomplain ${rootme}/${mldir}/libgcc_s*.so.*]] >= 1 } {
252 append libpath ":${rootme}/${mldir}"