1 # Expect script for ld-d10v tests
2 # Copyright 2002 Free Software Foundation, Inc.
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # Written by Tom Rix, trix@redhat.com
23 if ![istarget d10v-*-*] {
28 # Copied from run_dump_test, with the dumping part removed.
30 # Assemble a .s file, then run some utility on it and check the output.
32 # There should be an assembly language file named FILE.s in the test
33 # suite directory. `run_link_test' will assemble and link FILE.s
35 # The FILE.lt file begins with zero or more option lines, which specify
36 # flags to pass to the assembler, the program to run to dump the
37 # assembler's output, and the options it wants. The option lines have
42 # OPTION is the name of some option, like "name" or "ld", and
43 # VALUE is OPTION's value. The valid options are described below.
44 # Whitespace is ignored everywhere, except within VALUE. The option
45 # list ends with the first line that doesn't match the above syntax
46 # (hmm, not great for error detection).
48 # The interesting options are:
51 # The name of this test, passed to DejaGNU's `pass' and `fail'
52 # commands. If omitted, this defaults to FILE, the root of the
53 # .s and .d files' names.
56 # When assembling, pass FLAGS to the assembler.
57 # If assembling several files, you can pass different assembler
58 # options in the "source" directives. See below.
61 # Link assembled files using FLAGS, in the order of the "source"
62 # directives, when using multiple files.
64 # source: SOURCE [FLAGS]
65 # Assemble the file SOURCE.s using the flags in the "as" directive
66 # and the (optional) FLAGS. If omitted, the source defaults to
68 # This is useful if several .x files want to share a .s file.
69 # More than one "source" directive can be given, which is useful
70 # when testing linking.
73 # The test is expected to fail on TARGET. This may occur more than
77 # Only run the test for TARGET. This may occur more than once; the
78 # target being tested must match at least one.
81 # Do not run the test for TARGET. This may occur more than once;
82 # the target being tested must not match any of them.
84 # Each option may occur at most once unless otherwise mentioned.
87 proc run_link_test { name } {
90 global ASFLAGS LDFLAGS
91 global host_triplet runtests
93 if [string match "*/*" $name] {
95 set name [file tail $name]
97 set file "$srcdir/$subdir/$name"
100 if ![runtest_file_p $runtests $name] then {
104 set opt_array [slurp_options "${file}.lt"]
105 if { $opt_array == -1 } {
106 perror "error reading options from $file.lt"
107 unresolved $subdir/$name
110 set dumpfile tmpdir/dump.out
116 set opts(notarget) {}
119 set asflags(${file}.s) {}
121 foreach i $opt_array {
122 set opt_name [lindex $i 0]
123 set opt_val [lindex $i 1]
124 if ![info exists opts($opt_name)] {
125 perror "unknown option $opt_name in file $file.lt"
126 unresolved $subdir/$name
130 switch -- $opt_name {
135 # Move any source-specific as-flags to a separate array to
136 # simplify processing.
137 if { [llength $opt_val] > 1 } {
138 set asflags([lindex $opt_val 0]) [lrange $opt_val 1 end]
139 set opt_val [lindex $opt_val 0]
141 set asflags($opt_val) {}
145 if [string length $opts($opt_name)] {
146 perror "option $opt_name multiply set in $file.lt"
147 unresolved $subdir/$name
152 set opts($opt_name) [concat $opts($opt_name) $opt_val]
155 # Decide early whether we should run the test for this target.
156 if { [llength $opts(target)] > 0 } {
158 foreach targ $opts(target) {
159 if [istarget $targ] {
164 if { $targmatch == 0 } {
168 foreach targ $opts(notarget) {
169 if [istarget $targ] {
174 if { $opts(name) == "" } {
175 set testname "$subdir/$name"
177 set testname $opts(name)
180 if { $opts(source) == "" } {
181 set sourcefiles [list ${file}.s]
184 foreach sf $opts(source) {
185 lappend sourcefiles "$srcdir/$subdir/$sf"
186 # Must have asflags indexed on source name.
187 set asflags($srcdir/$subdir/$sf) $asflags($sf)
191 # Time to setup xfailures.
192 foreach targ $opts(xfail) {
196 # Assemble each file.
198 for { set i 0 } { $i < [llength $sourcefiles] } { incr i } {
199 set sourcefile [lindex $sourcefiles $i]
201 set objfile "tmpdir/dump$i.o"
202 lappend objfiles $objfile
203 set cmd "$AS $ASFLAGS $opts(as) $asflags($sourcefile) -o $objfile $sourcefile"
206 set cmdret [catch "exec $cmd" comp_output]
207 set comp_output [prune_warnings $comp_output]
209 # We accept errors at assembly stage too, unless we're supposed to
211 if { $cmdret != 0 || ![string match "" $comp_output] } then {
212 send_log "$comp_output\n"
213 verbose "$comp_output" 3
220 set objfile "tmpdir/dump"
221 set cmd "$LD $LDFLAGS $opts(ld) -o $objfile $objfiles"
224 set cmdret [catch "exec $cmd" comp_output]
225 set comp_output [prune_warnings $comp_output]
227 if { $cmdret != 0 || ![string match "" $comp_output] } then {
229 send_log "$comp_output\n"
230 verbose "$comp_output" 3
238 set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
239 foreach test $test_list {
240 # We need to strip the ".d", but can leave the dirname.
241 verbose [file rootname $test]
242 run_dump_test [file rootname $test]
245 set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.lt]]
246 foreach test $test_list {
247 # We need to strip the ".lt", but can leave the dirname.
248 verbose [file rootname $test]
249 run_link_test [file rootname $test]