OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [lib/] [fortran-torture.exp] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
# Copyright (C) 2003, 2007 Free Software Foundation, Inc.
2
 
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.
12
#
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
# .
16
 
17
# Please email any bugs, comments, and/or additions to this file to
18
# the author.
19
 
20
# This file was written by Steven Bosscher (s.bosscher@student.tudelft.nl)
21
# based on f-torture.exp, which was written by Rob Savoye.
22
 
23
# The biggest change from g77 is that we always test all testcases with
24
# loop options, because it is much harder to figure out whether a testcase
25
# has loops if you have array syntax, like Fortran 95.  In fact, the whole
26
# point of F95 is arrays, so loops show up in most testcases anyway.
27
 
28
 
29
# The default option list can be overridden by
30
# TORTURE_OPTIONS="{ { list1 } ... { listN } }"
31
 
32
if ![info exists TORTURE_OPTIONS] {
33
    set TORTURE_OPTIONS [list \
34
        { -O0 } { -O1 } { -O2 } \
35
        { -O2 -fomit-frame-pointer -finline-functions } \
36
        { -O2 -fomit-frame-pointer -finline-functions -funroll-loops } \
37
        { -O2 -fbounds-check } \
38
        { -O2 -fno-repack-arrays } \
39
        { -O3 -g } \
40
        { -Os }]
41
}
42
 
43
 
44
#
45
# fortran-torture-compile -- compile a gfortran.fortran-torture testcase.
46
#
47
# SRC is the full pathname of the testcase.
48
# OPTION is the specific compiler flag we're testing (eg: -O2).
49
#
50
proc fortran-torture-compile { src option } {
51
    global output
52
    global srcdir tmpdir
53
    global host_triplet
54
 
55
    set output "$tmpdir/[file tail [file rootname $src]].o"
56
 
57
    regsub "(?q)$srcdir/" $src "" testcase
58
 
59
    # If we couldn't rip $srcdir out of `src' then just do the best we can.
60
    # The point is to reduce the unnecessary noise in the logs.  Don't strip
61
    # out too much because different testcases with the same name can confuse
62
    # `test-tool'.
63
    if [string match "/*" $testcase] {
64
        set testcase "[file tail [file dirname $src]]/[file tail $src]"
65
    }
66
 
67
    verbose "Testing $testcase, $option" 1
68
 
69
    # Run the compiler and get results in comp_output.
70
    set options ""
71
    lappend options "additional_flags=-w $option"
72
 
73
    set comp_output [gfortran_target_compile "$src" "$output" object $options]
74
 
75
    # See if we got something bad.
76
    set fatal_signal "*95*: Internal compiler error: program*got fatal signal"
77
 
78
    if [string match "$fatal_signal 6" $comp_output] then {
79
        gfortran_fail $testcase "Got Signal 6, $option"
80
        catch { remote_file build delete $output }
81
        return
82
    }
83
 
84
    if [string match "$fatal_signal 11" $comp_output] then {
85
        gfortran_fail $testcase "Got Signal 11, $option"
86
        catch { remote_file build delete $output }
87
        return
88
    }
89
 
90
    if [string match "*internal compiler error*" $comp_output] then {
91
        gfortran_fail $testcase "$option (internal compiler error)"
92
        catch { remote_file build delete $output }
93
        return
94
    }
95
 
96
    # We shouldn't get these because of -w, but just in case.
97
    if [string match "*95*:*warning:*" $comp_output] then {
98
        warning "$testcase: (with warnings) $option"
99
        send_log "$comp_output\n"
100
        unresolved "$testcase, $option"
101
        catch { remote_file build delete $output }
102
        return
103
    }
104
 
105
    # Prune warnings we know are unwanted.
106
    set comp_output [prune_warnings $comp_output]
107
 
108
    # Report if the testcase is not supported.
109
    set unsupported_message [gfortran_check_unsupported_p $comp_output]
110
    if { $unsupported_message != "" } {
111
        unsupported "$testcase: $unsupported_message"
112
        catch { remote_file build delete $output }
113
        return
114
    }
115
 
116
    # remove any leftover LF/CR to make sure any output is legit
117
    regsub -all -- "\[\r\n\]*" $comp_output "" comp_output
118
 
119
    # If any message remains, we fail.
120
    if ![string match "" $comp_output] then {
121
        gfortran_fail $testcase $option
122
        catch { remote_file build delete $output }
123
        return
124
    }
125
 
126
    gfortran_pass $testcase $option
127
    catch { remote_file build delete $output }
128
}
129
 
130
 
131
#
132
# fortran-torture-execute -- compile and execute a testcase.
133
#
134
# SRC is the full pathname of the testcase.
135
#
136
# If the testcase has an associated .x file, we source that to run the
137
# test instead.  We use .x so that we don't lengthen the existing filename
138
# to more than 14 chars.
139
#
140
proc fortran-torture-execute { src } {
141
    global output
142
    global srcdir tmpdir
143
    global tool
144
    global compiler_conditional_xfail_data
145
    global TORTURE_OPTIONS
146
 
147
    # Check for alternate driver.
148
    set additional_flags ""
149
    if [file exists [file rootname $src].x] {
150
        verbose "Using alternate driver [file rootname [file tail $src]].x" 2
151
        set done_p 0
152
        catch "set done_p \[source [file rootname $src].x\]"
153
        if { $done_p } {
154
            return
155
        }
156
    }
157
 
158
    # Setup the options for the testcase run.
159
    set option_list $TORTURE_OPTIONS
160
    set executable $tmpdir/[file tail [file rootname $src].x]
161
    regsub "(?q)$srcdir/" $src "" testcase
162
 
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]"
169
    }
170
 
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 {
174
 
175
        # Torture_{compile,execute}_xfail are set by the .x script.
176
        if [info exists torture_compile_xfail] {
177
            setup_xfail $torture_compile_xfail
178
        }
179
 
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]
183
        }
184
 
185
        # FIXME: We should make sure that the modules required by this testcase
186
        # exist.  If not, the testcase should XFAIL.
187
 
188
        # Compile the testcase.
189
        catch { remote_file build delete $executable }
190
        verbose "Testing $testcase, $option" 1
191
 
192
        set options ""
193
        lappend options "additional_flags=-w $option"
194
        if { $additional_flags != "" } {
195
            lappend options "additional_flags=$additional_flags"
196
        }
197
        set comp_output [gfortran_target_compile "$src" "$executable" executable $options]
198
 
199
        # See if we got something bad.
200
        set fatal_signal "*95*: Internal compiler error: program*got fatal signal"
201
 
202
        if [string match "$fatal_signal 6" $comp_output] then {
203
            gfortran_fail $testcase "Got Signal 6, $option"
204
            catch { remote_file build delete $executable }
205
            continue
206
        }
207
 
208
        if [string match "$fatal_signal 11" $comp_output] then {
209
            gfortran_fail $testcase "Got Signal 11, $option"
210
            catch { remote_file build delete $executable }
211
            continue
212
        }
213
 
214
        if [string match "*internal compiler error*" $comp_output] then {
215
            gfortran_fail $testcase "$option (internal compiler error)"
216
            catch { remote_file build delete $executable }
217
            continue
218
        }
219
 
220
        # We shouldn't get these because of -w, but just in case.
221
        if [string match "*95*:*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
227
        }
228
 
229
        # Prune warnings we know are unwanted.
230
        set comp_output [prune_warnings $comp_output]
231
 
232
        # Report if the testcase is not supported.
233
        set unsupported_message [gfortran_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 existance 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"
247
            }
248
        } else {
249
            pass "$testcase compilation, $option"
250
        }
251
 
252
        # See if this source file uses INTEGER(KIND=8) types, if it does, and
253
        # no_long_long is set, skip execution of the test.
254
        # FIXME: We should also look for F95 style "_8" or select_int_kind()
255
        # integers, but that is obviously much harder than just regexping this.
256
        # So maybe we should just avoid those in testcases.
257
        if [target_info exists no_long_long] then {
258
            if [expr [search_for_re $src "integer\*8"] \
259
                     +[search_for_re $src "integer *( *8 *)"] \
260
                     +[search_for_re $src "integer *( *kind *= *8 *)"]] \
261
              then {
262
                untested "$testcase execution, $option"
263
                continue
264
            }
265
        }
266
 
267
        if [info exists torture_execute_xfail] {
268
            setup_xfail $torture_execute_xfail
269
        }
270
 
271
        if [info exists torture_eval_before_execute] {
272
            set ignore_me [eval $torture_eval_before_execute]
273
        }
274
 
275
        # Run the testcase, and analyse the output.
276
        set result [gfortran_load "$executable" "" ""]
277
        set status [lindex $result 0]
278
        set output [lindex $result 1]
279
        if { $status == "pass" } {
280
            catch { remote_file build delete $executable }
281
        }
282
        $status "$testcase execution, $option"
283
    }
284
}
285
 
286
 
287
#
288
# search_for_re -- looks for a string match in a file
289
#
290
proc search_for_re { file pattern } {
291
    set fd [open $file r]
292
    while { [gets $fd cur_line]>=0 } {
293
        set lower [string tolower $cur_line]
294
        if [regexp "$pattern" $lower] then {
295
            close $fd
296
            return 1
297
        }
298
    }
299
    close $fd
300
    return 0
301
}
302
 
303
 
304
#
305
# fortran-torture -- the fortran-torture testcase source file processor
306
#
307
# This runs compilation only tests (no execute tests).
308
#
309
# SRC is the full pathname of the testcase, or just a file name in which
310
# case we prepend $srcdir/$subdir.
311
#
312
# If the testcase has an associated .x file, we source that to run the
313
# test instead.  We use .x so that we don't lengthen the existing filename
314
# to more than 14 chars.
315
#
316
proc fortran-torture { args } {
317
    global srcdir subdir
318
    global compiler_conditional_xfail_data
319
 
320
    set src [lindex $args 0]
321
    if { [llength $args] > 1 } {
322
        set options [lindex $args 1]
323
    } else {
324
        set options ""
325
    }
326
 
327
    # Prepend $srdir/$subdir if missing.
328
    if ![string match "*/*" $src] {
329
        set src "$srcdir/$subdir/$src"
330
    }
331
 
332
    # Check for alternate driver.
333
    if [file exists [file rootname $src].x] {
334
        verbose "Using alternate driver [file rootname [file tail $src]].x" 2
335
        set done_p 0
336
        catch "set done_p \[source [file rootname $src].x\]"
337
        if { $done_p } {
338
            return
339
        }
340
    }
341
 
342
    # loop through all the options
343
    set option_list [list { "-O" } ]
344
    foreach option $option_list {
345
 
346
        # torture_compile_xfail is set by the .x script (if present)
347
        if [info exists torture_compile_xfail] {
348
            setup_xfail $torture_compile_xfail
349
        }
350
 
351
        # torture_execute_before_compile is set by the .x script (if present)
352
        if [info exists torture_eval_before_compile] {
353
            set ignore_me [eval $torture_eval_before_compile]
354
        }
355
 
356
        fortran-torture-compile $src "$option $options"
357
    }
358
}
359
 
360
#
361
# add-ieee-options -- add options necessary for 100% ieee conformance.
362
#
363
proc add-ieee-options { } {
364
    # Ensure that excess precision does not cause problems.
365
    if { [istarget "i?86-*-*"]
366
         || [istarget "m68k-*-*"] } then {
367
      uplevel 1 lappend additional_flags "-ffloat-store"
368
    }
369
 
370
    # Enable full IEEE compliance mode.
371
    if { [istarget "alpha*-*-*"]
372
         || [istarget "sh*-*-*"] } then {
373
      uplevel 1 lappend additional_flags "-mieee"
374
    }
375
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.