1 # Copyright
(C
) 2009-2018 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
/>.
17 # Please email
any bugs
, comments
, and
/or additions to this file to
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 load_lib target
-utils.exp
27 # The default option list can be overridden by
28 # TORTURE_OPTIONS
="{ { list1 } ... { listN } }"
30 if ![info exists TORTURE_OPTIONS
] {
31 set TORTURE_OPTIONS
[list \
32 { -O0
} { -O1
} { -O2
} \
33 { -O2
-fomit
-frame
-pointer
-finline
-functions
} \
34 { -O2
-fomit
-frame
-pointer
-finline
-functions
-funroll
-loops
} \
35 { -O2
-fbounds
-check
} \
42 # go
-torture
-compile -- compile a go.go
-torture testcase.
44 # SRC is the full pathname of the testcase.
45 # OPTION is the specific compiler flag we
're testing (eg: -O2).
47 proc go-torture-compile { src option } {
52 set output "$tmpdir/[file tail [file rootname $src]].o"
54 regsub "(?q)$srcdir/" $src "" testcase
56 # If we couldn't rip $srcdir out of `src
' then just do the best we can.
57 # The point is to reduce the unnecessary noise in the logs. Don't
strip
58 # out too much because different testcases with the same
name can confuse
60 if [string match "/*" $testcase] {
61 set testcase "[file tail [file dirname $src]]/[file tail $src]"
64 verbose "Testing $testcase, $option" 1
66 # Run the compiler and get results in comp_output.
68 lappend options "additional_flags=-w $option"
70 set comp_output [go_target_compile "$src" "$output" object $options]
72 # See if we got something bad.
73 set fatal_signal "*go*: Internal compiler error: program*got fatal signal"
75 if [string match "$fatal_signal 6" $comp_output] then {
76 go_fail $testcase "Got Signal 6, $option"
77 catch { remote_file build delete $output }
81 if [string match "$fatal_signal 11" $comp_output] then {
82 go_fail $testcase "Got Signal 11, $option"
83 catch { remote_file build delete $output }
87 if [string match "*internal compiler error*" $comp_output] then {
88 go_fail $testcase "$option (internal compiler error)"
89 catch { remote_file build delete $output }
93 # We shouldn't
get these because of
-w
, but just in case.
94 if [string match
"*go*:*warning:*" $comp_output] then {
95 warning
"$testcase: (with warnings) $option"
96 send_log
"$comp_output\n"
97 unresolved
"$testcase, $option"
98 catch
{ remote_file build
delete $output
}
102 # Prune warnings we know are unwanted.
103 set comp_output
[prune_warnings $comp_output
]
105 #
Report if the testcase is not supported.
106 set unsupported_message
[go_check_unsupported_p $comp_output
]
107 if { $unsupported_message
!= "" } {
108 unsupported
"$testcase: $unsupported_message"
109 catch
{ remote_file build
delete $output
}
113 # remove
any leftover LF
/CR to make sure
any output is legit
114 regsub
-all
-- "\[\r\n\]*" $comp_output "" comp_output
116 #
If any message remains
, we fail.
117 if ![string match
"" $comp_output] then {
118 go_fail $testcase $option
119 catch
{ remote_file build
delete $output
}
123 go_pass $testcase $option
124 catch
{ remote_file build
delete $output
}
129 # go
-torture
-execute -- compile and
execute a testcase.
131 # SRC is the full pathname of the testcase.
133 #
If the testcase has an associated .x file
, we source that to run the
134 # test instead. We use .x so that we don
't lengthen the existing filename
135 # to more than 14 chars.
137 proc go-torture-execute { src } {
141 global compiler_conditional_xfail_data
142 global TORTURE_OPTIONS
143 global go_compile_args
144 global go_execute_args
146 # Check for alternate driver.
147 set additional_flags ""
148 if [file exists [file rootname $src].x] {
149 verbose "Using alternate driver [file rootname [file tail $src]].x" 2
151 catch "set done_p \[source [file rootname $src].x\]"
157 # Setup the options for the testcase run.
158 set option_list $TORTURE_OPTIONS
159 set executable $tmpdir/[file tail [file rootname $src].x]
160 regsub "(?q)$srcdir/" $src "" testcase
162 if { ! [info exists go_compile_args] } {
163 set go_compile_args ""
165 if { ! [info exists go_execute_args] } {
166 set go_execute_args ""
169 # If we couldn't rip $srcdir out of `src
' then just do the best we can.
170 # The point is to reduce the unnecessary noise in the logs. Don't
strip
171 # out too much because different testcases with the same
name can confuse
173 if [string match "/*" $testcase] {
174 set testcase "[file tail [file dirname $src]]/[file tail $src]"
177 # Walk the list of options and copmile and run the testcase for all
178 # options that are not explicitly disabled by the .x script (if present).
179 foreach option $option_list {
181 # Torture_{compile,execute}_xfail are set by the .x script.
182 if [info exists torture_compile_xfail] {
183 setup_xfail $torture_compile_xfail
186 # Torture_execute_before_{compile,execute} can be set by the .x script.
187 if [info exists torture_eval_before_compile] {
188 set ignore_me [eval $torture_eval_before_compile]
191 # FIXME: We should make sure that the modules required by this testcase
192 # exist. If not, the testcase should XFAIL.
194 # Compile the testcase.
195 catch { remote_file build delete $executable }
196 verbose "Testing $testcase, $option" 1
199 lappend options "additional_flags=-w $option"
200 if { $additional_flags != "" } {
201 lappend options "additional_flags=$additional_flags"
203 if { $go_compile_args != "" } {
204 lappend options "additional_flags=$go_compile_args"
206 set comp_output [go_target_compile "$src" "$executable" executable $options]
208 # See if we got something bad.
209 set fatal_signal "*go*: Internal compiler error: program*got fatal signal"
211 if [string match "$fatal_signal 6" $comp_output] then {
212 go_fail $testcase "Got Signal 6, $option"
213 catch { remote_file build delete $executable }
217 if [string match "$fatal_signal 11" $comp_output] then {
218 go_fail $testcase "Got Signal 11, $option"
219 catch { remote_file build delete $executable }
223 if [string match "*internal compiler error*" $comp_output] then {
224 go_fail $testcase "$option (internal compiler error)"
225 catch { remote_file build delete $executable }
229 # We shouldn't
get these because of
-w
, but just in case.
230 if [string match
"*go*:*warning:*" $comp_output] then {
231 warning
"$testcase: (with warnings) $option"
232 send_log
"$comp_output\n"
233 unresolved
"$testcase, $option"
234 catch
{ remote_file build
delete $executable
}
238 # Prune warnings we know are unwanted.
239 set comp_output
[prune_warnings $comp_output
]
241 #
Report if the testcase is not supported.
242 set unsupported_message
[go_check_unsupported_p $comp_output
]
243 if { $unsupported_message
!= "" } {
244 unsupported
"$testcase: $unsupported_message"
246 } elseif
![file
exists $executable
] {
248 fail
"$testcase compilation, $option"
249 untested
"$testcase execution, $option"
252 # FIXME
: since we can
't test for the existence of a remote
253 # file without short of doing an remote file list, we assume
254 # that since we got no output, it must have compiled.
255 pass "$testcase compilation, $option"
258 pass "$testcase compilation, $option"
261 if [info exists torture_execute_xfail] {
262 setup_xfail $torture_execute_xfail
265 if [info exists torture_eval_before_execute] {
266 set ignore_me [eval $torture_eval_before_execute]
269 # Run the testcase, and analyse the output.
270 set result [go_load "$executable" "$go_execute_args" ""]
271 set status [lindex $result 0]
272 set output [lindex $result 1]
274 # In order to cooperate nicely with the master Go testsuite,
275 # if the output contains the string BUG, we treat the test as
277 if [ string match "*BUG*" $output ] {
281 if { $status == "pass" } {
282 catch { remote_file build delete $executable }
284 $status "$testcase execution, $option"
290 # search_for_re -- looks for a string match in a file
292 proc search_for_re { file pattern } {
293 set fd [open $file r]
294 while { [gets $fd cur_line]>=0 } {
295 set lower [string tolower $cur_line]
296 if [regexp "$pattern" $lower] then {
307 # go-torture -- the go-torture testcase source file processor
309 # This runs compilation only tests (no execute tests).
311 # SRC is the full pathname of the testcase, or just a file name in which
312 # case we prepend $srcdir/$subdir.
314 # If the testcase has an associated .x file, we source that to run the
315 # test instead. We use .x so that we don't lengthen the existing filename
316 # to more than
14 chars.
318 proc go
-torture
{ args } {
320 global compiler_conditional_xfail_data
321 global TORTURE_OPTIONS
323 set src
[lindex $
args 0]
324 if { [llength $
args] > 1 } {
325 set options
[lindex $
args 1]
330 # Prepend $srdir
/$subdir
if missing.
331 if ![string match
"*/*" $src] {
332 set src
"$srcdir/$subdir/$src"
335 # Check
for alternate driver.
336 if [file
exists [file rootname $src
].x
] {
337 verbose
"Using alternate driver [file rootname [file tail $src]].x" 2
339 catch
"set done_p \[source [file rootname $src].x\]"
345 # loop through all the options
346 set option_list $TORTURE_OPTIONS
347 foreach option $option_list
{
349 # torture_compile_xfail is
set by the .x script
(if present
)
350 if [info exists torture_compile_xfail
] {
351 setup_xfail $torture_compile_xfail
354 # torture_execute_before_compile is
set by the .x script
(if present
)
355 if [info exists torture_eval_before_compile
] {
356 set ignore_me
[eval $torture_eval_before_compile
]
359 go
-torture
-compile $src
"$option $options"
364 # add
-ieee
-options
-- add options necessary
for 100% ieee conformance.
366 proc add
-ieee
-options
{ } {
367 # Ensure that excess precision does not cause problems.
368 if { [istarget i?
86-*-*]
369 ||
[istarget m68k
-*-*] } then {
370 uplevel
1 lappend additional_flags
"-ffloat-store"
373 # Enable full IEEE compliance
mode.
374 if { [istarget alpha
*-*-*]
375 ||
[istarget sh
*-*-*] } then {
376 uplevel
1 lappend additional_flags
"-mieee"