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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [ld/] [testsuite/] [ld-d10v/] [d10v.exp] - Blame information for rev 53

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

Line No. Rev Author Line
1 47 khays
# Expect script for ld-d10v tests
2
# Copyright 2002, 2005, 2007 Free Software Foundation, Inc.
3
#
4
# This file is part of the GNU Binutils.
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19
# MA 02110-1301, USA.
20
#
21
# Written by Tom Rix, trix@redhat.com
22
#
23
 
24
# Test d10v
25
 
26
if ![istarget d10v-*-*] {
27
    return
28
}
29
 
30
# run_link_test FILE
31
# Copied from run_dump_test, with the dumping part removed.
32
#
33
# Assemble a .s file, then run some utility on it and check the output.
34
#
35
# There should be an assembly language file named FILE.s in the test
36
# suite directory.  `run_link_test' will assemble and link FILE.s
37
#
38
# The FILE.lt file begins with zero or more option lines, which specify
39
# flags to pass to the assembler, the program to run to dump the
40
# assembler's output, and the options it wants.  The option lines have
41
# the syntax:
42
#
43
#         # OPTION: VALUE
44
#
45
# OPTION is the name of some option, like "name" or "ld", and
46
# VALUE is OPTION's value.  The valid options are described below.
47
# Whitespace is ignored everywhere, except within VALUE.  The option
48
# list ends with the first line that doesn't match the above syntax
49
# (hmm, not great for error detection).
50
#
51
# The interesting options are:
52
#
53
#   name: TEST-NAME
54
#       The name of this test, passed to DejaGNU's `pass' and `fail'
55
#       commands.  If omitted, this defaults to FILE, the root of the
56
#       .s and .d files' names.
57
#
58
#   as: FLAGS
59
#       When assembling, pass FLAGS to the assembler.
60
#       If assembling several files, you can pass different assembler
61
#       options in the "source" directives.  See below.
62
#
63
#   ld: FLAGS
64
#       Link assembled files using FLAGS, in the order of the "source"
65
#       directives, when using multiple files.
66
#
67
#   source: SOURCE [FLAGS]
68
#       Assemble the file SOURCE.s using the flags in the "as" directive
69
#       and the (optional) FLAGS.  If omitted, the source defaults to
70
#       FILE.s.
71
#       This is useful if several .x files want to share a .s file.
72
#       More than one "source" directive can be given, which is useful
73
#       when testing linking.
74
#
75
#   xfail: TARGET
76
#       The test is expected to fail on TARGET.  This may occur more than
77
#       once.
78
#
79
#   target: TARGET
80
#       Only run the test for TARGET.  This may occur more than once; the
81
#       target being tested must match at least one.
82
#
83
#   notarget: TARGET
84
#       Do not run the test for TARGET.  This may occur more than once;
85
#       the target being tested must not match any of them.
86
#
87
# Each option may occur at most once unless otherwise mentioned.
88
#
89
 
90
proc run_link_test { name } {
91
    global subdir srcdir
92
    global AS LD
93
    global ASFLAGS LDFLAGS
94
    global host_triplet runtests
95
 
96
    if [string match "*/*" $name] {
97
        set file $name
98
        set name [file tail $name]
99
    } else {
100
        set file "$srcdir/$subdir/$name"
101
    }
102
 
103
    if ![runtest_file_p $runtests $name] then {
104
        return
105
    }
106
 
107
    set opt_array [slurp_options "${file}.lt"]
108
    if { $opt_array == -1 } {
109
        perror "error reading options from $file.lt"
110
        unresolved $subdir/$name
111
        return
112
    }
113
    set dumpfile tmpdir/dump.out
114
    set run_ld 0
115
    set opts(as) {}
116
    set opts(ld) {}
117
    set opts(xfail) {}
118
    set opts(target) {}
119
    set opts(notarget) {}
120
    set opts(name) {}
121
    set opts(source) {}
122
    set asflags(${file}.s) {}
123
 
124
    foreach i $opt_array {
125
        set opt_name [lindex $i 0]
126
        set opt_val [lindex $i 1]
127
        if ![info exists opts($opt_name)] {
128
            perror "unknown option $opt_name in file $file.lt"
129
            unresolved $subdir/$name
130
            return
131
        }
132
 
133
        switch -- $opt_name {
134
            xfail {}
135
            target {}
136
            notarget {}
137
            source {
138
                # Move any source-specific as-flags to a separate array to
139
                # simplify processing.
140
                if { [llength $opt_val] > 1 } {
141
                    set asflags([lindex $opt_val 0]) [lrange $opt_val 1 end]
142
                    set opt_val [lindex $opt_val 0]
143
                } else {
144
                    set asflags($opt_val) {}
145
                }
146
            }
147
            default {
148
                if [string length $opts($opt_name)] {
149
                    perror "option $opt_name multiply set in $file.lt"
150
                    unresolved $subdir/$name
151
                    return
152
                }
153
            }
154
        }
155
        set opts($opt_name) [concat $opts($opt_name) $opt_val]
156
    }
157
 
158
    # Decide early whether we should run the test for this target.
159
    if { [llength $opts(target)] > 0 } {
160
        set targmatch 0
161
        foreach targ $opts(target) {
162
            if [istarget $targ] {
163
                set targmatch 1
164
                break
165
            }
166
        }
167
        if { $targmatch == 0 } {
168
            return
169
        }
170
    }
171
    foreach targ $opts(notarget) {
172
        if [istarget $targ] {
173
            return
174
        }
175
    }
176
 
177
    if { $opts(name) == "" } {
178
        set testname "$subdir/$name"
179
    } else {
180
        set testname $opts(name)
181
    }
182
 
183
    if { $opts(source) == "" } {
184
        set sourcefiles [list ${file}.s]
185
    } else {
186
        set sourcefiles {}
187
        foreach sf $opts(source) {
188
            lappend sourcefiles "$srcdir/$subdir/$sf"
189
            # Must have asflags indexed on source name.
190
            set asflags($srcdir/$subdir/$sf) $asflags($sf)
191
        }
192
    }
193
 
194
    # Time to setup xfailures.
195
    foreach targ $opts(xfail) {
196
        setup_xfail $targ
197
    }
198
 
199
    # Assemble each file.
200
    set objfiles {}
201
    for { set i 0 } { $i < [llength $sourcefiles] } { incr i } {
202
        set sourcefile [lindex $sourcefiles $i]
203
 
204
        set objfile "tmpdir/dump$i.o"
205
        lappend objfiles $objfile
206
        set cmd "$AS $ASFLAGS $opts(as) $asflags($sourcefile) -o $objfile $sourcefile"
207
 
208
        send_log "$cmd\n"
209
        set cmdret [catch "exec $cmd" comp_output]
210
        set comp_output [prune_warnings $comp_output]
211
 
212
        # We accept errors at assembly stage too, unless we're supposed to
213
        # link something.
214
        if { $cmdret != 0 || ![string match "" $comp_output] } then {
215
            send_log "$comp_output\n"
216
            verbose "$comp_output" 3
217
            fail $testname
218
            return
219
        }
220
    }
221
 
222
    # Link the file(s).
223
    set objfile "tmpdir/dump"
224
    set cmd "$LD $LDFLAGS $opts(ld) -o $objfile $objfiles"
225
 
226
    send_log "$cmd\n"
227
    set cmdret [catch "exec $cmd" comp_output]
228
    set comp_output [prune_warnings $comp_output]
229
 
230
    if { $cmdret != 0 || ![string match "" $comp_output] } then {
231
 
232
        send_log "$comp_output\n"
233
        verbose "$comp_output" 3
234
        fail $testname
235
        return
236
    }
237
    pass $testname
238
}
239
 
240
 
241
set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
242
foreach test $test_list {
243
    # We need to strip the ".d", but can leave the dirname.
244
    verbose [file rootname $test]
245
    run_dump_test [file rootname $test]
246
}
247
 
248
set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.lt]]
249
foreach test $test_list {
250
    # We need to strip the ".lt", but can leave the dirname.
251
    verbose [file rootname $test]
252
    run_link_test [file rootname $test]
253
}

powered by: WebSVN 2.1.0

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