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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [lib/] [go-torture.exp] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 701 jeremybenn
# Copyright (C) 2009, 2011, 2012 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 Ian Lance Taylor  based on
21
# fortran-torture.exp by Steven Bosscher and Rob Savoye.
22
 
23
load_lib target-supports.exp
24
 
25
# The default option list can be overridden by
26
# TORTURE_OPTIONS="{ { list1 } ... { listN } }"
27
 
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 }]
36
}
37
 
38
 
39
#
40
# go-torture-compile -- compile a go.go-torture testcase.
41
#
42
# SRC is the full pathname of the testcase.
43
# OPTION is the specific compiler flag we're testing (eg: -O2).
44
#
45
proc go-torture-compile { src option } {
46
    global output
47
    global srcdir tmpdir
48
    global host_triplet
49
 
50
    set output "$tmpdir/[file tail [file rootname $src]].o"
51
 
52
    regsub "(?q)$srcdir/" $src "" testcase
53
 
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]"
60
    }
61
 
62
    verbose "Testing $testcase, $option" 1
63
 
64
    # Run the compiler and get results in comp_output.
65
    set options ""
66
    lappend options "additional_flags=-w $option"
67
 
68
    set comp_output [go_target_compile "$src" "$output" object $options]
69
 
70
    # See if we got something bad.
71
    set fatal_signal "*go*: Internal compiler error: program*got fatal signal"
72
 
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
77
    }
78
 
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
83
    }
84
 
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
89
    }
90
 
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
98
    }
99
 
100
    # Prune warnings we know are unwanted.
101
    set comp_output [prune_warnings $comp_output]
102
 
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
109
    }
110
 
111
    # remove any leftover LF/CR to make sure any output is legit
112
    regsub -all -- "\[\r\n\]*" $comp_output "" comp_output
113
 
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
119
    }
120
 
121
    go_pass $testcase $option
122
    catch { remote_file build delete $output }
123
}
124
 
125
 
126
#
127
# go-torture-execute -- compile and execute a testcase.
128
#
129
# SRC is the full pathname of the testcase.
130
#
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.
134
#
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_compile_args
142
    global go_execute_args
143
 
144
    # Check for alternate driver.
145
    set additional_flags ""
146
    if [file exists [file rootname $src].x] {
147
        verbose "Using alternate driver [file rootname [file tail $src]].x" 2
148
        set done_p 0
149
        catch "set done_p \[source [file rootname $src].x\]"
150
        if { $done_p } {
151
            return
152
        }
153
    }
154
 
155
    # Setup the options for the testcase run.
156
    set option_list $TORTURE_OPTIONS
157
    set executable $tmpdir/[file tail [file rootname $src].x]
158
    regsub "(?q)$srcdir/" $src "" testcase
159
 
160
    if { ! [info exists go_compile_args] } {
161
        set go_compile_args ""
162
    }
163
    if { ! [info exists go_execute_args] } {
164
        set go_execute_args ""
165
    }
166
 
167
    # If we couldn't rip $srcdir out of `src' then just do the best we can.
168
    # The point is to reduce the unnecessary noise in the logs.  Don't strip
169
    # out too much because different testcases with the same name can confuse
170
    # `test-tool'.
171
    if [string match "/*" $testcase] {
172
        set testcase "[file tail [file dirname $src]]/[file tail $src]"
173
    }
174
 
175
    # Walk the list of options and copmile and run the testcase for all
176
    # options that are not explicitly disabled by the .x script (if present).
177
    foreach option $option_list {
178
 
179
        # Torture_{compile,execute}_xfail are set by the .x script.
180
        if [info exists torture_compile_xfail] {
181
            setup_xfail $torture_compile_xfail
182
        }
183
 
184
        # Torture_execute_before_{compile,execute} can be set by the .x script.
185
        if [info exists torture_eval_before_compile] {
186
            set ignore_me [eval $torture_eval_before_compile]
187
        }
188
 
189
        # FIXME: We should make sure that the modules required by this testcase
190
        # exist.  If not, the testcase should XFAIL.
191
 
192
        # Compile the testcase.
193
        catch { remote_file build delete $executable }
194
        verbose "Testing $testcase, $option" 1
195
 
196
        set options ""
197
        lappend options "additional_flags=-w $option"
198
        if { $additional_flags != "" } {
199
            lappend options "additional_flags=$additional_flags"
200
        }
201
        if { $go_compile_args != "" } {
202
            lappend options "additional_flags=$go_compile_args"
203
        }
204
        set comp_output [go_target_compile "$src" "$executable" executable $options]
205
 
206
        # See if we got something bad.
207
        set fatal_signal "*go*: Internal compiler error: program*got fatal signal"
208
 
209
        if [string match "$fatal_signal 6" $comp_output] then {
210
            go_fail $testcase "Got Signal 6, $option"
211
            catch { remote_file build delete $executable }
212
            continue
213
        }
214
 
215
        if [string match "$fatal_signal 11" $comp_output] then {
216
            go_fail $testcase "Got Signal 11, $option"
217
            catch { remote_file build delete $executable }
218
            continue
219
        }
220
 
221
        if [string match "*internal compiler error*" $comp_output] then {
222
            go_fail $testcase "$option (internal compiler error)"
223
            catch { remote_file build delete $executable }
224
            continue
225
        }
226
 
227
        # We shouldn't get these because of -w, but just in case.
228
        if [string match "*go*:*warning:*" $comp_output] then {
229
            warning "$testcase: (with warnings) $option"
230
            send_log "$comp_output\n"
231
            unresolved "$testcase, $option"
232
            catch { remote_file build delete $executable }
233
            continue
234
        }
235
 
236
        # Prune warnings we know are unwanted.
237
        set comp_output [prune_warnings $comp_output]
238
 
239
        # Report if the testcase is not supported.
240
        set unsupported_message [go_check_unsupported_p $comp_output]
241
        if { $unsupported_message != "" } {
242
            unsupported "$testcase: $unsupported_message"
243
            continue
244
        } elseif ![file exists $executable] {
245
            if ![is3way] {
246
                fail "$testcase compilation, $option"
247
                untested "$testcase execution, $option"
248
                continue
249
            } else {
250
                # FIXME: since we can't test for the existence of a remote
251
                # file without short of doing an remote file list, we assume
252
                # that since we got no output, it must have compiled.
253
                pass "$testcase compilation, $option"
254
            }
255
        } else {
256
            pass "$testcase compilation, $option"
257
        }
258
 
259
        if [info exists torture_execute_xfail] {
260
            setup_xfail $torture_execute_xfail
261
        }
262
 
263
        if [info exists torture_eval_before_execute] {
264
            set ignore_me [eval $torture_eval_before_execute]
265
        }
266
 
267
        # Run the testcase, and analyse the output.
268
        set result [go_load "$executable" "$go_execute_args" ""]
269
        set status [lindex $result 0]
270
        set output [lindex $result 1]
271
 
272
        # In order to cooperate nicely with the master Go testsuite,
273
        # if the output contains the string BUG, we treat the test as
274
        # failing.
275
        if [ string match "*BUG*" $output ] {
276
            set status "fail"
277
        }
278
 
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
# go-torture -- the go-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 go-torture { args } {
317
    global srcdir subdir
318
    global compiler_conditional_xfail_data
319
    global TORTURE_OPTIONS
320
 
321
    set src [lindex $args 0]
322
    if { [llength $args] > 1 } {
323
        set options [lindex $args 1]
324
    } else {
325
        set options ""
326
    }
327
 
328
    # Prepend $srdir/$subdir if missing.
329
    if ![string match "*/*" $src] {
330
        set src "$srcdir/$subdir/$src"
331
    }
332
 
333
    # Check for alternate driver.
334
    if [file exists [file rootname $src].x] {
335
        verbose "Using alternate driver [file rootname [file tail $src]].x" 2
336
        set done_p 0
337
        catch "set done_p \[source [file rootname $src].x\]"
338
        if { $done_p } {
339
            return
340
        }
341
    }
342
 
343
    # loop through all the options
344
    set option_list $TORTURE_OPTIONS
345
    foreach option $option_list {
346
 
347
        # torture_compile_xfail is set by the .x script (if present)
348
        if [info exists torture_compile_xfail] {
349
            setup_xfail $torture_compile_xfail
350
        }
351
 
352
        # torture_execute_before_compile is set by the .x script (if present)
353
        if [info exists torture_eval_before_compile] {
354
            set ignore_me [eval $torture_eval_before_compile]
355
        }
356
 
357
        go-torture-compile $src "$option $options"
358
    }
359
}
360
 
361
#
362
# add-ieee-options -- add options necessary for 100% ieee conformance.
363
#
364
proc add-ieee-options { } {
365
    # Ensure that excess precision does not cause problems.
366
    if { [istarget i?86-*-*]
367
         || [istarget m68k-*-*] } then {
368
      uplevel 1 lappend additional_flags "-ffloat-store"
369
    }
370
 
371
    # Enable full IEEE compliance mode.
372
    if { [istarget alpha*-*-*]
373
         || [istarget sh*-*-*] } then {
374
      uplevel 1 lappend additional_flags "-mieee"
375
    }
376
}

powered by: WebSVN 2.1.0

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