Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / lib / go-torture.exp
blob8c4be209b661d6facd3afda0809a18ee9bb69714
1 # Copyright (C) 2009 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 # Please email any bugs, comments, and/or additions to this file to
18 # the author.
20 # This file was written by Ian Lance Taylor <iant@google.com> based on
21 # fortran-torture.exp by Steven Bosscher and Rob Savoye.
23 load_lib target-supports.exp
25 # The default option list can be overridden by
26 # TORTURE_OPTIONS="{ { list1 } ... { listN } }"
28 if ![info exists TORTURE_OPTIONS] {
29 set TORTURE_OPTIONS [list \
30 { -O0 } { -O1 } { -O2 } \
31 { -O2 -fomit-frame-pointer -finline-functions } \
32 { -O2 -fomit-frame-pointer -finline-functions -funroll-loops } \
33 { -O2 -fbounds-check } \
34 { -O3 -g } \
35 { -Os }]
40 # go-torture-compile -- compile a go.go-torture testcase.
42 # SRC is the full pathname of the testcase.
43 # OPTION is the specific compiler flag we're testing (eg: -O2).
45 proc go-torture-compile { src option } {
46 global output
47 global srcdir tmpdir
48 global host_triplet
50 set output "$tmpdir/[file tail [file rootname $src]].o"
52 regsub "(?q)$srcdir/" $src "" testcase
54 # If we couldn't rip $srcdir out of `src' then just do the best we can.
55 # The point is to reduce the unnecessary noise in the logs. Don't strip
56 # out too much because different testcases with the same name can confuse
57 # `test-tool'.
58 if [string match "/*" $testcase] {
59 set testcase "[file tail [file dirname $src]]/[file tail $src]"
62 verbose "Testing $testcase, $option" 1
64 # Run the compiler and get results in comp_output.
65 set options ""
66 lappend options "additional_flags=-w $option"
68 set comp_output [go_target_compile "$src" "$output" object $options]
70 # See if we got something bad.
71 set fatal_signal "*go*: Internal compiler error: program*got fatal signal"
73 if [string match "$fatal_signal 6" $comp_output] then {
74 go_fail $testcase "Got Signal 6, $option"
75 catch { remote_file build delete $output }
76 return
79 if [string match "$fatal_signal 11" $comp_output] then {
80 go_fail $testcase "Got Signal 11, $option"
81 catch { remote_file build delete $output }
82 return
85 if [string match "*internal compiler error*" $comp_output] then {
86 go_fail $testcase "$option (internal compiler error)"
87 catch { remote_file build delete $output }
88 return
91 # We shouldn't get these because of -w, but just in case.
92 if [string match "*go*:*warning:*" $comp_output] then {
93 warning "$testcase: (with warnings) $option"
94 send_log "$comp_output\n"
95 unresolved "$testcase, $option"
96 catch { remote_file build delete $output }
97 return
100 # Prune warnings we know are unwanted.
101 set comp_output [prune_warnings $comp_output]
103 # Report if the testcase is not supported.
104 set unsupported_message [go_check_unsupported_p $comp_output]
105 if { $unsupported_message != "" } {
106 unsupported "$testcase: $unsupported_message"
107 catch { remote_file build delete $output }
108 return
111 # remove any leftover LF/CR to make sure any output is legit
112 regsub -all -- "\[\r\n\]*" $comp_output "" comp_output
114 # If any message remains, we fail.
115 if ![string match "" $comp_output] then {
116 go_fail $testcase $option
117 catch { remote_file build delete $output }
118 return
121 go_pass $testcase $option
122 catch { remote_file build delete $output }
127 # go-torture-execute -- compile and execute a testcase.
129 # SRC is the full pathname of the testcase.
131 # If the testcase has an associated .x file, we source that to run the
132 # test instead. We use .x so that we don't lengthen the existing filename
133 # to more than 14 chars.
135 proc go-torture-execute { src } {
136 global output
137 global srcdir tmpdir
138 global tool
139 global compiler_conditional_xfail_data
140 global TORTURE_OPTIONS
141 global go_execute_args
143 # Check for alternate driver.
144 set additional_flags ""
145 if [file exists [file rootname $src].x] {
146 verbose "Using alternate driver [file rootname [file tail $src]].x" 2
147 set done_p 0
148 catch "set done_p \[source [file rootname $src].x\]"
149 if { $done_p } {
150 return
154 # Setup the options for the testcase run.
155 set option_list $TORTURE_OPTIONS
156 set executable $tmpdir/[file tail [file rootname $src].x]
157 regsub "(?q)$srcdir/" $src "" testcase
159 if { ! [info exists go_execute_args] } {
160 set go_execute_args ""
163 # If we couldn't rip $srcdir out of `src' then just do the best we can.
164 # The point is to reduce the unnecessary noise in the logs. Don't strip
165 # out too much because different testcases with the same name can confuse
166 # `test-tool'.
167 if [string match "/*" $testcase] {
168 set testcase "[file tail [file dirname $src]]/[file tail $src]"
171 # Walk the list of options and copmile and run the testcase for all
172 # options that are not explicitly disabled by the .x script (if present).
173 foreach option $option_list {
175 # Torture_{compile,execute}_xfail are set by the .x script.
176 if [info exists torture_compile_xfail] {
177 setup_xfail $torture_compile_xfail
180 # Torture_execute_before_{compile,execute} can be set by the .x script.
181 if [info exists torture_eval_before_compile] {
182 set ignore_me [eval $torture_eval_before_compile]
185 # FIXME: We should make sure that the modules required by this testcase
186 # exist. If not, the testcase should XFAIL.
188 # Compile the testcase.
189 catch { remote_file build delete $executable }
190 verbose "Testing $testcase, $option" 1
192 set options ""
193 lappend options "additional_flags=-w $option"
194 if { $additional_flags != "" } {
195 lappend options "additional_flags=$additional_flags"
197 set comp_output [go_target_compile "$src" "$executable" executable $options]
199 # See if we got something bad.
200 set fatal_signal "*go*: Internal compiler error: program*got fatal signal"
202 if [string match "$fatal_signal 6" $comp_output] then {
203 go_fail $testcase "Got Signal 6, $option"
204 catch { remote_file build delete $executable }
205 continue
208 if [string match "$fatal_signal 11" $comp_output] then {
209 go_fail $testcase "Got Signal 11, $option"
210 catch { remote_file build delete $executable }
211 continue
214 if [string match "*internal compiler error*" $comp_output] then {
215 go_fail $testcase "$option (internal compiler error)"
216 catch { remote_file build delete $executable }
217 continue
220 # We shouldn't get these because of -w, but just in case.
221 if [string match "*go*:*warning:*" $comp_output] then {
222 warning "$testcase: (with warnings) $option"
223 send_log "$comp_output\n"
224 unresolved "$testcase, $option"
225 catch { remote_file build delete $executable }
226 continue
229 # Prune warnings we know are unwanted.
230 set comp_output [prune_warnings $comp_output]
232 # Report if the testcase is not supported.
233 set unsupported_message [go_check_unsupported_p $comp_output]
234 if { $unsupported_message != "" } {
235 unsupported "$testcase: $unsupported_message"
236 continue
237 } elseif ![file exists $executable] {
238 if ![is3way] {
239 fail "$testcase compilation, $option"
240 untested "$testcase execution, $option"
241 continue
242 } else {
243 # FIXME: since we can't test for the existence of a remote
244 # file without short of doing an remote file list, we assume
245 # that since we got no output, it must have compiled.
246 pass "$testcase compilation, $option"
248 } else {
249 pass "$testcase compilation, $option"
252 if [info exists torture_execute_xfail] {
253 setup_xfail $torture_execute_xfail
256 if [info exists torture_eval_before_execute] {
257 set ignore_me [eval $torture_eval_before_execute]
260 # Run the testcase, and analyse the output.
261 set result [go_load "$executable" "$go_execute_args" ""]
262 set status [lindex $result 0]
263 set output [lindex $result 1]
265 # In order to cooperate nicely with the master Go testsuite,
266 # if the output contains the string BUG, we treat the test as
267 # failing.
268 if [ string match "*BUG*" $output ] {
269 set status "fail"
272 if { $status == "pass" } {
273 catch { remote_file build delete $executable }
275 $status "$testcase execution, $option"
281 # search_for_re -- looks for a string match in a file
283 proc search_for_re { file pattern } {
284 set fd [open $file r]
285 while { [gets $fd cur_line]>=0 } {
286 set lower [string tolower $cur_line]
287 if [regexp "$pattern" $lower] then {
288 close $fd
289 return 1
292 close $fd
293 return 0
298 # go-torture -- the go-torture testcase source file processor
300 # This runs compilation only tests (no execute tests).
302 # SRC is the full pathname of the testcase, or just a file name in which
303 # case we prepend $srcdir/$subdir.
305 # If the testcase has an associated .x file, we source that to run the
306 # test instead. We use .x so that we don't lengthen the existing filename
307 # to more than 14 chars.
309 proc go-torture { args } {
310 global srcdir subdir
311 global compiler_conditional_xfail_data
312 global TORTURE_OPTIONS
314 set src [lindex $args 0]
315 if { [llength $args] > 1 } {
316 set options [lindex $args 1]
317 } else {
318 set options ""
321 # Prepend $srdir/$subdir if missing.
322 if ![string match "*/*" $src] {
323 set src "$srcdir/$subdir/$src"
326 # Check for alternate driver.
327 if [file exists [file rootname $src].x] {
328 verbose "Using alternate driver [file rootname [file tail $src]].x" 2
329 set done_p 0
330 catch "set done_p \[source [file rootname $src].x\]"
331 if { $done_p } {
332 return
336 # loop through all the options
337 set option_list $TORTURE_OPTIONS
338 foreach option $option_list {
340 # torture_compile_xfail is set by the .x script (if present)
341 if [info exists torture_compile_xfail] {
342 setup_xfail $torture_compile_xfail
345 # torture_execute_before_compile is set by the .x script (if present)
346 if [info exists torture_eval_before_compile] {
347 set ignore_me [eval $torture_eval_before_compile]
350 go-torture-compile $src "$option $options"
355 # add-ieee-options -- add options necessary for 100% ieee conformance.
357 proc add-ieee-options { } {
358 # Ensure that excess precision does not cause problems.
359 if { [istarget "i?86-*-*"]
360 || [istarget "m68k-*-*"] } then {
361 uplevel 1 lappend additional_flags "-ffloat-store"
364 # Enable full IEEE compliance mode.
365 if { [istarget "alpha*-*-*"]
366 || [istarget "sh*-*-*"] } then {
367 uplevel 1 lappend additional_flags "-mieee"