1 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000 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.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-dejagnu@gnu.org.
20 # This file was written by Rob Savoye. (rob@cygnus.com)
22 # The default option list can be overridden by
23 # TORTURE_OPTIONS="{ { list1 } ... { listN } }"
25 if ![info exists TORTURE_OPTIONS] {
26 set TORTURE_OPTIONS [list \
27 { -O0 } { -O1 } { -O2 } \
28 { -O2 -fomit-frame-pointer -finline-functions } \
29 { -O2 -fomit-frame-pointer -finline-functions -funroll-loops } \
30 { -O2 -fomit-frame-pointer -finline-functions -funroll-all-loops } \
36 # Split TORTURE_OPTIONS into two choices: one for testcases with loops and
37 # one for testcases without loops.
39 set torture_with_loops $TORTURE_OPTIONS
40 set torture_without_loops ""
41 foreach option $TORTURE_OPTIONS {
42 if ![string match "*loop*" $option] {
43 lappend torture_without_loops $option
48 # f-torture-compile -- runs the Tege C-torture test
50 # SRC is the full pathname of the testcase.
51 # OPTION is the specific compiler flag we're testing (eg: -O2).
53 proc f-torture-compile { src option } {
58 set output "$tmpdir/[file tail [file rootname $src]].o"
60 regsub "^$srcdir/?" $src "" testcase
61 # If we couldn't rip $srcdir out of `src' then just do the best we can.
62 # The point is to reduce the unnecessary noise in the logs. Don't strip
63 # out too much because different testcases with the same name can confuse
65 if [string match "/*" $testcase] {
66 set testcase "[file tail [file dirname $src]]/[file tail $src]"
69 verbose "Testing $testcase, $option" 1
71 # Run the compiler and analyze the results.
73 lappend options "additional_flags=-w $option"
75 set comp_output [g77_target_compile "$src" "$output" object $options];
77 # Set a few common compiler messages.
78 set fatal_signal "*77*: Internal compiler error: program*got fatal signal"
80 if [string match "$fatal_signal 6" $comp_output] then {
81 g77_fail $testcase "Got Signal 6, $option"
82 remote_file build delete $output
86 if [string match "$fatal_signal 11" $comp_output] then {
87 g77_fail $testcase "Got Signal 11, $option"
88 remote_file build delete $output
92 # We shouldn't get these because of -w, but just in case.
93 if [string match "*77*:*warning:*" $comp_output] then {
94 warning "$testcase: (with warnings) $option"
95 send_log "$comp_output\n"
96 unresolved "$testcase, $option"
97 remote_file build delete $output
101 set comp_output [prune_warnings $comp_output]
103 set unsupported_message [g77_check_unsupported_p $comp_output]
104 if { $unsupported_message != "" } {
105 unsupported "$testcase: $unsupported_message"
106 remote_file build delete $output
110 # remove any leftover LF/CR to make sure any output is legit
111 regsub -all -- "\[\r\n\]*" $comp_output "" comp_output
112 # If any message remains, we fail.
113 if ![string match "" $comp_output] then {
114 g77_fail $testcase $option
115 remote_file build delete $output
119 g77_pass $testcase $option
120 remote_file build delete $output
124 # f-torture-execute -- utility to compile and execute a testcase
126 # SRC is the full pathname of the testcase.
128 # If the testcase has an associated .x file, we source that to run the
129 # test instead. We use .x so that we don't lengthen the existing filename
130 # to more than 14 chars.
132 proc f-torture-execute { src } {
133 global tmpdir tool srcdir output compiler_conditional_xfail_data
135 # Check for alternate driver.
136 if [file exists [file rootname $src].x] {
137 verbose "Using alternate driver [file rootname [file tail $src]].x" 2
139 catch "set done_p \[source [file rootname $src].x\]"
145 # Look for a loop within the source code - if we don't find one,
146 # don't pass -funroll[-all]-loops.
147 global torture_with_loops torture_without_loops
148 if [expr [search_for $src "do *\[0-9\]"]+[search_for $src "end *do"]] then {
149 set option_list $torture_with_loops
151 set option_list $torture_without_loops
154 set executable $tmpdir/[file tail [file rootname $src].x]
156 regsub "^$srcdir/?" $src "" testcase
157 # If we couldn't rip $srcdir out of `src' then just do the best we can.
158 # The point is to reduce the unnecessary noise in the logs. Don't strip
159 # out too much because different testcases with the same name can confuse
161 if [string match "/*" $testcase] {
162 set testcase "[file tail [file dirname $src]]/[file tail $src]"
165 foreach option $option_list {
166 # torture_{compile,execute}_xfail are set by the .x script
168 if [info exists torture_compile_xfail] {
169 setup_xfail $torture_compile_xfail
172 # torture_execute_before_{compile,execute} can be set by the .x script
174 if [info exists torture_eval_before_compile] {
175 set ignore_me [eval $torture_eval_before_compile]
178 remote_file build delete $executable
179 verbose "Testing $testcase, $option" 1
182 lappend options "additional_flags=-w $option"
183 set comp_output [g77_target_compile "$src" "$executable" executable $options];
185 # Set a few common compiler messages.
186 set fatal_signal "*77*: Internal compiler error: program*got fatal signal"
188 if [string match "$fatal_signal 6" $comp_output] then {
189 g77_fail $testcase "Got Signal 6, $option"
190 remote_file build delete $executable
194 if [string match "$fatal_signal 11" $comp_output] then {
195 g77_fail $testcase "Got Signal 11, $option"
196 remote_file build delete $executable
200 # We shouldn't get these because of -w, but just in case.
201 if [string match "*77*:*warning:*" $comp_output] then {
202 warning "$testcase: (with warnings) $option"
203 send_log "$comp_output\n"
204 unresolved "$testcase, $option"
205 remote_file build delete $executable
209 set comp_output [prune_warnings $comp_output]
211 set unsupported_message [g77_check_unsupported_p $comp_output]
213 if { $unsupported_message != "" } {
214 unsupported "$testcase: $unsupported_message"
216 } elseif ![file exists $executable] {
218 fail "$testcase compilation, $option"
219 untested "$testcase execution, $option"
222 # FIXME: since we can't test for the existance of a remote
223 # file without short of doing an remote file list, we assume
224 # that since we got no output, it must have compiled.
225 pass "$testcase compilation, $option"
228 pass "$testcase compilation, $option"
231 # See if this source file uses "long long" types, if it does, and
232 # no_long_long is set, skip execution of the test.
233 if [target_info exists no_long_long] then {
234 if [expr [search_for $src "integer\*8"]] then {
235 untested "$testcase execution, $option"
240 if [info exists torture_execute_xfail] {
241 setup_xfail $torture_execute_xfail
244 if [info exists torture_eval_before_execute] {
245 set ignore_me [eval $torture_eval_before_execute]
248 set result [g77_load "$executable" "" ""]
249 set status [lindex $result 0];
250 set output [lindex $result 1];
251 if { $status == "pass" } {
252 remote_file build delete $executable
254 $status "$testcase execution, $option"
259 # search_for -- looks for a string match in a file
261 proc search_for { file pattern } {
262 set fd [open $file r]
263 while { [gets $fd cur_line]>=0 } {
264 set lower [string tolower $cur_line]
265 if [regexp "$pattern" $lower] then {
275 # f-torture -- the f-torture testcase source file processor
277 # This runs compilation only tests (no execute tests).
278 # SRC is the full pathname of the testcase, or just a file name in which case
279 # we prepend $srcdir/$subdir.
281 # If the testcase has an associated .x file, we source that to run the
282 # test instead. We use .x so that we don't lengthen the existing filename
283 # to more than 14 chars.
285 proc f-torture { args } {
286 global srcdir subdir compiler_conditional_xfail_data
288 set src [lindex $args 0];
289 if { [llength $args] > 1 } {
290 set options [lindex $args 1];
295 # Prepend $srdir/$subdir if missing.
296 if ![string match "*/*" $src] {
297 set src "$srcdir/$subdir/$src"
300 # Check for alternate driver.
301 if [file exists [file rootname $src].x] {
302 verbose "Using alternate driver [file rootname [file tail $src]].x" 2
304 catch "set done_p \[source [file rootname $src].x\]"
310 # Look for a loop within the source code - if we don't find one,
311 # don't pass -funroll[-all]-loops.
312 global torture_with_loops torture_without_loops
313 if [expr [search_for $src "do *\[0-9\]"]+[search_for $src "end *do"]] then {
314 set option_list $torture_with_loops
316 set option_list $torture_without_loops
319 # loop through all the options
320 foreach option $option_list {
321 # torture_compile_xfail is set by the .x script (if present)
322 if [info exists torture_compile_xfail] {
323 setup_xfail $torture_compile_xfail
326 # torture_execute_before_compile is set by the .x script (if present)
327 if [info exists torture_eval_before_compile] {
328 set ignore_me [eval $torture_eval_before_compile]
331 f-torture-compile $src "$option $options"