1 # Expect script for ld-d10v tests
2 # Copyright 2002, 2005, 2007 Free Software Foundation, Inc.
4 # This file is part of the GNU Binutils.
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.
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.
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,
21 # Written by Tom Rix, trix@redhat.com
26 if ![istarget d10v-*-*] {
31 # Copied from run_dump_test, with the dumping part removed.
33 # Assemble a .s file, then run some utility on it and check the output.
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
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
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).
51 # The interesting options are:
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.
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.
64 # Link assembled files using FLAGS, in the order of the "source"
65 # directives, when using multiple files.
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
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.
76 # The test is expected to fail on TARGET. This may occur more than
80 # Only run the test for TARGET. This may occur more than once; the
81 # target being tested must match at least one.
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.
87 # Each option may occur at most once unless otherwise mentioned.
90 proc run_link_test { name } {
93 global ASFLAGS LDFLAGS
94 global host_triplet runtests
96 if [string match "*/*" $name] {
98 set name [file tail $name]
100 set file "$srcdir/$subdir/$name"
103 if ![runtest_file_p $runtests $name] then {
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
113 set dumpfile tmpdir/dump.out
119 set opts(notarget) {}
122 set asflags(${file}.s) {}
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
133 switch -- $opt_name {
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]
144 set asflags($opt_val) {}
148 if [string length $opts($opt_name)] {
149 perror "option $opt_name multiply set in $file.lt"
150 unresolved $subdir/$name
155 set opts($opt_name) [concat $opts($opt_name) $opt_val]
158 # Decide early whether we should run the test for this target.
159 if { [llength $opts(target)] > 0 } {
161 foreach targ $opts(target) {
162 if [istarget $targ] {
167 if { $targmatch == 0 } {
171 foreach targ $opts(notarget) {
172 if [istarget $targ] {
177 if { $opts(name) == "" } {
178 set testname "$subdir/$name"
180 set testname $opts(name)
183 if { $opts(source) == "" } {
184 set sourcefiles [list ${file}.s]
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)
194 # Time to setup xfailures.
195 foreach targ $opts(xfail) {
199 # Assemble each file.
201 for { set i 0 } { $i < [llength $sourcefiles] } { incr i } {
202 set sourcefile [lindex $sourcefiles $i]
204 set objfile "tmpdir/dump$i.o"
205 lappend objfiles $objfile
206 set cmd "$AS $ASFLAGS $opts(as) $asflags($sourcefile) -o $objfile $sourcefile"
209 set cmdret [catch "exec $cmd" comp_output]
210 set comp_output [prune_warnings $comp_output]
212 # We accept errors at assembly stage too, unless we're supposed to
214 if { $cmdret != 0 || ![string match "" $comp_output] } then {
215 send_log "$comp_output\n"
216 verbose "$comp_output" 3
223 set objfile "tmpdir/dump"
224 set cmd "$LD $LDFLAGS $opts(ld) -o $objfile $objfiles"
227 set cmdret [catch "exec $cmd" comp_output]
228 set comp_output [prune_warnings $comp_output]
230 if { $cmdret != 0 || ![string match "" $comp_output] } then {
232 send_log "$comp_output\n"
233 verbose "$comp_output" 3
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]
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]