Commit | Line | Data |
---|---|---|
ba7f26d2 | 1 | # Copyright (C) 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
5940a93c | 2 | # 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
252b5132 RH |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
ec2655a6 | 6 | # the Free Software Foundation; either version 3 of the License, or |
252b5132 | 7 | # (at your option) any later version. |
139e4a70 | 8 | # |
252b5132 RH |
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. | |
139e4a70 | 13 | # |
252b5132 RH |
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 | |
ec2655a6 NC |
16 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
17 | # MA 02110-1301, USA. | |
252b5132 RH |
18 | |
19 | # Please email any bugs, comments, and/or additions to this file to: | |
fc697c14 | 20 | # dejagnu@gnu.org |
252b5132 RH |
21 | |
22 | # This file was written by Ken Raeburn (raeburn@cygnus.com). | |
23 | ||
24 | proc gas_version {} { | |
25 | global AS | |
7f6a71ff JM |
26 | if [is_remote host] then { |
27 | remote_exec host "$AS -version < /dev/null" "" "" "gas.version" | |
28 | remote_exec host "which $AS" "" "" "gas.which" | |
29 | ||
30 | remote_upload host "gas.version" | |
31 | remote_upload host "gas.which" | |
32 | ||
33 | set which_as [file_contents "gas.which"] | |
34 | set tmp [file_contents "gas.version"] | |
35 | ||
36 | remote_file build delete "gas.version" | |
37 | remote_file build delete "gas.which" | |
38 | remote_file host delete "gas.version" | |
39 | remote_file host delete "gas.which" | |
40 | } else { | |
41 | set which_as [which $AS] | |
42 | catch "exec $AS -version < /dev/null" tmp | |
43 | } | |
44 | ||
252b5132 RH |
45 | # Should find a way to discard constant parts, keep whatever's |
46 | # left, so the version string could be almost anything at all... | |
47 | regexp "\[^\n\]* (cygnus-|)(\[-0-9.a-zA-Z-\]+)\[\r\n\].*" $tmp version cyg number | |
48 | if ![info exists number] then { | |
7f6a71ff | 49 | return "$which_as (no version number)\n" |
252b5132 | 50 | } |
7f6a71ff | 51 | clone_output "$which_as $number\n" |
252b5132 RH |
52 | unset version |
53 | } | |
54 | ||
7f6a71ff JM |
55 | proc gas_host_run { cmd redir } { |
56 | verbose "Executing $cmd $redir" | |
57 | set return_contents_of "" | |
58 | if [regexp ">& */dev/null" $redir] then { | |
59 | set output_file "" | |
60 | set command "$cmd $redir" | |
61 | } elseif [regexp "> */dev/null" $redir] then { | |
62 | set output_file "" | |
63 | set command "$cmd 2>gas.stderr" | |
64 | set return_contents_of "gas.stderr" | |
65 | } elseif [regexp ">&.*" $redir] then { | |
9396508d NC |
66 | # See PR 5322 for why the following line is used. |
67 | regsub ">&" $redir "" output_file | |
7f6a71ff JM |
68 | set command "$cmd 2>&1" |
69 | } elseif [regexp "2>.*" $redir] then { | |
70 | set output_file "gas.out" | |
71 | set command "$cmd $redir" | |
72 | set return_contents_of "gas.out" | |
73 | } elseif [regexp ">.*" $redir] then { | |
74 | set output_file "" | |
75 | set command "$cmd $redir 2>gas.stderr" | |
76 | set return_contents_of "gas.stderr" | |
77 | } elseif { "$redir" == "" } then { | |
78 | set output_file "gas.out" | |
79 | set command "$cmd 2>&1" | |
80 | set return_contents_of "gas.out" | |
81 | } else { | |
82 | fail "gas_host_run: unknown form of redirection string" | |
83 | } | |
84 | ||
85 | set status [remote_exec host [concat sh -c [list $command]] "" "/dev/null" "$output_file"] | |
86 | set to_return "" | |
87 | if { "$return_contents_of" != "" } then { | |
88 | remote_upload host "$return_contents_of" | |
89 | set to_return [file_contents "$return_contents_of"] | |
90 | regsub "\n$" $to_return "" to_return | |
91 | } | |
92 | ||
93 | if { [lindex $status 0] == 0 && "$output_file" != "" | |
94 | && "$output_file" != "$return_contents_of" } then { | |
95 | remote_upload host "$output_file" | |
96 | } | |
97 | ||
98 | return [list [lindex $status 0] "$to_return"] | |
99 | } | |
100 | ||
252b5132 RH |
101 | proc gas_run { prog as_opts redir } { |
102 | global AS | |
103 | global ASFLAGS | |
104 | global comp_output | |
105 | global srcdir | |
106 | global subdir | |
107 | global host_triplet | |
108 | ||
7f6a71ff JM |
109 | set status [gas_host_run "$AS $ASFLAGS $as_opts $srcdir/$subdir/$prog" "$redir"] |
110 | set comp_output [lindex $status 1] | |
111 | if { [lindex $status 0] != 0 && [regexp "2>.*" $redir] } then { | |
112 | append comp_output "child process exited abnormally" | |
113 | } | |
252b5132 RH |
114 | set comp_output [prune_warnings $comp_output] |
115 | verbose "output was $comp_output" | |
c0b22597 | 116 | return [list $comp_output ""] |
252b5132 RH |
117 | } |
118 | ||
cea10409 L |
119 | proc gas_run_stdin { prog as_opts redir } { |
120 | global AS | |
121 | global ASFLAGS | |
122 | global comp_output | |
123 | global srcdir | |
124 | global subdir | |
125 | global host_triplet | |
126 | ||
127 | set status [gas_host_run "$AS $ASFLAGS $as_opts < $srcdir/$subdir/$prog" "$redir"] | |
128 | set comp_output [lindex $status 1] | |
129 | if { [lindex $status 0] != 0 && [regexp "2>.*" $redir] } then { | |
130 | append comp_output "child process exited abnormally" | |
131 | } | |
132 | set comp_output [prune_warnings $comp_output] | |
133 | verbose "output was $comp_output" | |
134 | return [list $comp_output ""] | |
135 | } | |
136 | ||
252b5132 RH |
137 | proc all_ones { args } { |
138 | foreach x $args { if [expr $x!=1] { return 0 } } | |
139 | return 1 | |
140 | } | |
141 | ||
412cc54e L |
142 | # ${tool}_finish (gas_finish) will be called by runtest.exp. But |
143 | # gas_finish should only be used with gas_start. We use gas_started | |
144 | # to tell gas_finish if gas_start has been called so that runtest.exp | |
145 | # can call gas_finish without closing the wrong fd. | |
146 | set gas_started 0 | |
147 | ||
252b5132 RH |
148 | proc gas_start { prog as_opts } { |
149 | global AS | |
150 | global ASFLAGS | |
151 | global srcdir | |
152 | global subdir | |
153 | global spawn_id | |
412cc54e L |
154 | global gas_started |
155 | ||
156 | set gas_started 1 | |
252b5132 | 157 | |
04248055 | 158 | verbose -log "Starting $AS $ASFLAGS $as_opts $prog" 2 |
7f6a71ff JM |
159 | set status [gas_host_run "$AS $ASFLAGS $as_opts $srcdir/$subdir/$prog" ">&gas.out"] |
160 | spawn -noecho -nottycopy cat gas.out | |
252b5132 RH |
161 | } |
162 | ||
163 | proc gas_finish { } { | |
164 | global spawn_id | |
412cc54e | 165 | global gas_started |
252b5132 | 166 | |
412cc54e L |
167 | if { $gas_started == 1 } { |
168 | catch "close" | |
169 | catch "wait" | |
170 | set gas_started 0 | |
171 | } | |
252b5132 RH |
172 | } |
173 | ||
174 | proc want_no_output { testname } { | |
175 | global comp_output | |
176 | ||
177 | if ![string match "" $comp_output] then { | |
178 | send_log "$comp_output\n" | |
179 | verbose "$comp_output" 3 | |
180 | } | |
181 | if [string match "" $comp_output] then { | |
182 | pass "$testname" | |
183 | return 1 | |
184 | } else { | |
185 | fail "$testname" | |
186 | return 0 | |
187 | } | |
188 | } | |
189 | ||
190 | proc gas_test_old { file as_opts testname } { | |
191 | gas_run $file $as_opts "" | |
192 | return [want_no_output $testname] | |
193 | } | |
194 | ||
195 | proc gas_test { file as_opts var_opts testname } { | |
196 | global comp_output | |
197 | ||
198 | set i 0 | |
199 | foreach word $var_opts { | |
200 | set ignore_stdout($i) [string match "*>" $word] | |
201 | set opt($i) [string trim $word {>}] | |
202 | incr i | |
203 | } | |
204 | set max [expr 1<<$i] | |
205 | for {set i 0} {[expr $i<$max]} {incr i} { | |
206 | set maybe_ignore_stdout "" | |
207 | set extra_opts "" | |
208 | for {set bit 0} {(1<<$bit)<$max} {incr bit} { | |
209 | set num [expr 1<<$bit] | |
210 | if [expr $i&$num] then { | |
211 | set extra_opts "$extra_opts $opt($bit)" | |
212 | if $ignore_stdout($bit) then { | |
213 | set maybe_ignore_stdout ">/dev/null" | |
214 | } | |
215 | } | |
216 | } | |
217 | set extra_opts [string trim $extra_opts] | |
218 | gas_run $file "$as_opts $extra_opts" $maybe_ignore_stdout | |
219 | ||
220 | # Should I be able to use a conditional expression here? | |
221 | if [string match "" $extra_opts] then { | |
222 | want_no_output $testname | |
223 | } else { | |
224 | want_no_output "$testname ($extra_opts)" | |
225 | } | |
226 | } | |
227 | if [info exists errorInfo] then { | |
228 | unset errorInfo | |
229 | } | |
230 | } | |
231 | ||
232 | proc gas_test_ignore_stdout { file as_opts testname } { | |
233 | global comp_output | |
234 | ||
235 | gas_run $file $as_opts ">/dev/null" | |
236 | want_no_output $testname | |
237 | } | |
238 | ||
239 | proc gas_test_error { file as_opts testname } { | |
240 | global comp_output | |
241 | ||
242 | gas_run $file $as_opts ">/dev/null" | |
943fef64 MR |
243 | send_log "$comp_output\n" |
244 | verbose "$comp_output" 3 | |
245 | if { ![string match "" $comp_output] | |
246 | && ![string match "*Assertion failure*" $comp_output] | |
247 | && ![string match "*Internal error*" $comp_output] } then { | |
252b5132 | 248 | pass "$testname" |
943fef64 MR |
249 | } else { |
250 | fail "$testname" | |
252b5132 RH |
251 | } |
252 | } | |
253 | ||
254 | proc gas_exit {} {} | |
255 | ||
256 | proc gas_init { args } { | |
257 | global target_cpu | |
258 | global target_cpu_family | |
259 | global target_family | |
260 | global target_vendor | |
261 | global target_os | |
262 | global stdoptlist | |
263 | ||
264 | case "$target_cpu" in { | |
265 | "m68???" { set target_cpu_family m68k } | |
80c7c40a | 266 | "i[3-7]86" { set target_cpu_family i386 } |
252b5132 RH |
267 | default { set target_cpu_family $target_cpu } |
268 | } | |
269 | ||
270 | set target_family "$target_cpu_family-$target_vendor-$target_os" | |
271 | set stdoptlist "-a>" | |
272 | ||
273 | if ![istarget "*-*-*"] { | |
274 | perror "Target name [istarget] is not a triple." | |
275 | } | |
276 | # Need to return an empty string. | |
277 | return | |
278 | } | |
279 | ||
d6203a0e | 280 | # True if the object format is known to be ELF. |
d04428bd AM |
281 | # |
282 | proc is_elf_format {} { | |
d6203a0e AM |
283 | if { ![istarget *-*-sysv4*] |
284 | && ![istarget *-*-unixware*] | |
285 | && ![istarget *-*-elf*] | |
286 | && ![istarget *-*-eabi*] | |
287 | && ![istarget *-*-rtems*] | |
288 | && ![istarget hppa*64*-*-hpux*] | |
289 | && ![istarget ia64-*-hpux*] | |
290 | && ![istarget *-*-linux*] | |
5940a93c | 291 | && ![istarget *-*-gnu*] |
d6203a0e AM |
292 | && ![istarget frv-*-uclinux*] |
293 | && ![istarget bfin-*-uclinux] | |
294 | && ![istarget sh*-*-uclinux*] | |
295 | && ![istarget *-*-irix5*] | |
296 | && ![istarget *-*-irix6*] | |
297 | && ![istarget *-*-netbsd*] | |
298 | && ![istarget *-*-openbsd*] | |
d04428bd AM |
299 | && ![istarget *-*-solaris2*] } { |
300 | return 0 | |
301 | } | |
302 | ||
d6203a0e AM |
303 | if { [istarget *-*-linux*aout*] |
304 | || [istarget *-*-linux*oldld*] | |
305 | || [istarget h8500-*-rtems*] | |
306 | || [istarget i960-*-rtems*] | |
307 | || [istarget *-*-rtemscoff*] } { | |
d04428bd AM |
308 | return 0 |
309 | } | |
310 | ||
d6203a0e AM |
311 | if { ![istarget *-*-netbsdelf*] |
312 | && ([istarget *-*-netbsd*aout*] | |
313 | || [istarget *-*-netbsdpe*] | |
314 | || [istarget arm*-*-netbsd*] | |
315 | || [istarget sparc-*-netbsd*] | |
316 | || [istarget i*86-*-netbsd*] | |
317 | || [istarget m68*-*-netbsd*] | |
318 | || [istarget vax-*-netbsd*] | |
d04428bd AM |
319 | || [istarget ns32k-*-netbsd*]) } { |
320 | return 0 | |
321 | } | |
d9943e50 | 322 | |
d6203a0e AM |
323 | if { [istarget arm-*-openbsd*] |
324 | || [istarget i386-*-openbsd\[0-2\].*] | |
325 | || [istarget i386-*-openbsd3.\[0-2\]] | |
326 | || [istarget m68*-*-openbsd*] | |
327 | || [istarget ns32k-*-openbsd*] | |
328 | || [istarget sparc-*-openbsd\[0-2\].*] | |
329 | || [istarget sparc-*-openbsd3.\[0-1\]] | |
d9943e50 MK |
330 | || [istarget vax-*-openbsd*] } { |
331 | return 0 | |
332 | } | |
333 | ||
d04428bd AM |
334 | return 1 |
335 | } | |
336 | ||
d6203a0e AM |
337 | # True if the object format is known to be a.out. |
338 | # | |
339 | proc is_aout_format {} { | |
340 | if { [istarget *-*-netbsdelf] | |
341 | || [istarget sparc64-*-netbsd*] | |
342 | || [istarget sparc64-*-openbsd*] } { | |
343 | return 0 | |
344 | } | |
345 | if { [istarget *-*-*\[ab\]out*] | |
346 | || [istarget *-*-linux*oldld*] | |
347 | || [istarget *-*-bsd*] | |
348 | || [istarget *-*-msdos*] | |
349 | || [istarget arm-*-netbsd*] | |
350 | || [istarget arm-*-openbsd*] | |
351 | || [istarget arm-*-riscix*] | |
352 | || [istarget i?86-*-freebsd\[12\]*] | |
353 | || [istarget i?86-*-netbsd*] | |
354 | || [istarget i?86-*-openbsd\[0-2\]*] | |
355 | || [istarget i?86-*-openbsd3.\[0-2\]*] | |
356 | || [istarget i?86-*-vsta] | |
357 | || [istarget i?86-*-mach*] | |
358 | || [istarget m68*-*-netbsd*] | |
359 | || [istarget m68*-*-openbsd*] | |
360 | || [istarget ns32k-*-*] | |
361 | || [istarget pdp11-*-*] | |
362 | || [istarget sparc*-*-sunos4*] | |
363 | || [istarget sparc*-*-netbsd*] | |
364 | || [istarget sparc*-*-openbsd\[0-2\]*] | |
365 | || [istarget sparc*-*-openbsd3.\[0-1\]*] | |
366 | || [istarget sparc*-fujitsu-none] | |
367 | || [istarget vax-dec-ultrix*] | |
368 | || [istarget vax-*-netbsd] } { | |
369 | return 1 | |
370 | } | |
371 | return 0 | |
372 | } | |
373 | ||
c1711530 DK |
374 | # True if the object format is known to be PE COFF. |
375 | # | |
376 | proc is_pecoff_format {} { | |
d6203a0e AM |
377 | if { ![istarget *-*-mingw*] |
378 | && ![istarget *-*-cygwin*] | |
379 | && ![istarget *-*-cegcc*] | |
c1711530 DK |
380 | && ![istarget *-*-pe*] } { |
381 | return 0 | |
382 | } | |
383 | ||
384 | return 1 | |
385 | } | |
386 | ||
b27423bb TG |
387 | # Internal procedure: return the names of the standard sections |
388 | # | |
389 | proc get_standard_section_names {} { | |
390 | if [istarget "rx-*-*"] { | |
391 | return { "P" "D_1" "B_1" } | |
392 | } | |
393 | return | |
394 | } | |
395 | ||
9a5c4b9e PB |
396 | # run_dump_tests TESTCASES EXTRA_OPTIONS |
397 | # Wrapper for run_dump_test, which is suitable for invoking as | |
398 | # run_dump_tests [lsort [glob -nocomplain $srcdir/$subdir/*.d]] | |
399 | # EXTRA_OPTIONS are passed down to run_dump_test. Honors runtest_file_p. | |
400 | # Body cribbed from dg-runtest. | |
401 | ||
402 | proc run_dump_tests { testcases {extra_options {}} } { | |
403 | global runtests | |
404 | ||
405 | foreach testcase $testcases { | |
406 | # If testing specific files and this isn't one of them, skip it. | |
407 | if ![runtest_file_p $runtests $testcase] { | |
408 | continue | |
409 | } | |
410 | run_dump_test [file rootname [file tail $testcase]] $extra_options | |
411 | } | |
412 | } | |
413 | ||
252b5132 | 414 | |
e8119602 | 415 | # run_dump_test FILE (optional:) EXTRA_OPTIONS |
252b5132 RH |
416 | # |
417 | # Assemble a .s file, then run some utility on it and check the output. | |
139e4a70 | 418 | # |
252b5132 RH |
419 | # There should be an assembly language file named FILE.s in the test |
420 | # suite directory, and a pattern file called FILE.d. `run_dump_test' | |
421 | # will assemble FILE.s, run some tool like `objdump', `objcopy', or | |
422 | # `nm' on the .o file to produce textual output, and then analyze that | |
423 | # with regexps. The FILE.d file specifies what program to run, and | |
424 | # what to expect in its output. | |
425 | # | |
426 | # The FILE.d file begins with zero or more option lines, which specify | |
427 | # flags to pass to the assembler, the program to run to dump the | |
428 | # assembler's output, and the options it wants. The option lines have | |
429 | # the syntax: | |
139e4a70 | 430 | # |
252b5132 | 431 | # # OPTION: VALUE |
139e4a70 | 432 | # |
252b5132 RH |
433 | # OPTION is the name of some option, like "name" or "objdump", and |
434 | # VALUE is OPTION's value. The valid options are described below. | |
435 | # Whitespace is ignored everywhere, except within VALUE. The option | |
9a5c4b9e PB |
436 | # list ends with the first line that doesn't match the above syntax. |
437 | # However, a line within the options that begins with a #, but doesn't | |
438 | # have a recognizable option name followed by a colon, is considered a | |
439 | # comment and entirely ignored. | |
252b5132 | 440 | # |
e8119602 CD |
441 | # The optional EXTRA_OPTIONS argument to `run_dump_test' is a list of |
442 | # two-element lists. The first element of each is an option name, and | |
443 | # the second additional arguments to be added on to the end of the | |
444 | # option list as given in FILE.d. (If omitted, no additional options | |
445 | # are added.) | |
446 | # | |
252b5132 | 447 | # The interesting options are: |
139e4a70 | 448 | # |
252b5132 RH |
449 | # name: TEST-NAME |
450 | # The name of this test, passed to DejaGNU's `pass' and `fail' | |
451 | # commands. If omitted, this defaults to FILE, the root of the | |
452 | # .s and .d files' names. | |
139e4a70 | 453 | # |
252b5132 RH |
454 | # as: FLAGS |
455 | # When assembling FILE.s, pass FLAGS to the assembler. | |
139e4a70 | 456 | # |
368886ac | 457 | # addr2line: FLAGS |
252b5132 RH |
458 | # nm: FLAGS |
459 | # objcopy: FLAGS | |
23fce1e3 NC |
460 | # objdump: FLAGS |
461 | # readelf: FLAGS | |
252b5132 | 462 | # Use the specified program to analyze the .o file, and pass it |
139e4a70 AM |
463 | # FLAGS, in addition to the .o file name. Note that they are run |
464 | # with LC_ALL=C in the environment to give consistent sorting | |
23fce1e3 | 465 | # of symbols. If no FLAGS are needed then use: |
368886ac | 466 | # PROG: [nm objcopy objdump readelf addr2line] |
23fce1e3 | 467 | # instead. |
b27423bb TG |
468 | # Note: for objdump, we automatically replaces the standard section |
469 | # names (.text, .data and .bss) by target ones if any (eg. rx-elf | |
470 | # uses "P" instead of .text). The substition is done for both | |
471 | # the objdump options (eg: "-j .text" is replaced by "-j P") and the | |
472 | # reference file. | |
252b5132 RH |
473 | # |
474 | # source: SOURCE | |
475 | # Assemble the file SOURCE.s. If omitted, this defaults to FILE.s. | |
476 | # This is useful if several .d files want to share a .s file. | |
477 | # | |
89210bdc MR |
478 | # dump: DUMP |
479 | # Match against DUMP.d. If omitted, this defaults to FILE.d. This | |
480 | # is useful if several .d files differ by options only. Options are | |
481 | # always read from FILE.d. | |
482 | # | |
9a5c4b9e PB |
483 | # target: GLOBS... |
484 | # Run this test only on a specified list of targets. More precisely, | |
485 | # each glob in the space-separated list is passed to "istarget"; if | |
486 | # it evaluates true for any of them, the test will be run, otherwise | |
487 | # it will be marked unsupported. | |
488 | # | |
489 | # not-target: GLOBS... | |
490 | # Do not run this test on a specified list of targets. Again, | |
491 | # the each glob in the space-separated list is passed to | |
492 | # "istarget", and the test is run if it evaluates *false* for | |
493 | # *all* of them. Otherwise it will be marked unsupported. | |
494 | # | |
495 | # skip: GLOBS... | |
496 | # not-skip: GLOBS... | |
497 | # These are exactly the same as "not-target" and "target", | |
498 | # respectively, except that they do nothing at all if the check | |
499 | # fails. They should only be used in groups, to construct a single | |
500 | # test which is run on all targets but with variant options or | |
501 | # expected output on some targets. (For example, see | |
502 | # gas/arm/inst.d and gas/arm/wince_inst.d.) | |
503 | # | |
8c2784a5 TR |
504 | # error: REGEX |
505 | # An error with message matching REGEX must be emitted for the test | |
506 | # to pass. The PROG, objdump, nm and objcopy options have no | |
507 | # meaning and need not supplied if this is present. | |
508 | # | |
cfdf4aaa HPN |
509 | # warning: REGEX |
510 | # Expect a gas warning matching REGEX. It is an error to issue | |
511 | # both "error" and "warning". | |
512 | # | |
9a5c4b9e PB |
513 | # stderr: FILE |
514 | # FILE contains regexp lines to be matched against the diagnostic | |
515 | # output of the assembler. This does not preclude the use of | |
516 | # PROG, nm, objdump, or objcopy. | |
517 | # | |
518 | # error-output: FILE | |
519 | # Means the same as 'stderr', but also indicates that the assembler | |
520 | # is expected to exit unsuccessfully (therefore PROG, objdump, nm, | |
521 | # and objcopy have no meaning and should not be supplied). | |
522 | # | |
b27423bb TG |
523 | # section-subst: no |
524 | # Means that the section substitution for objdump is disabled. | |
525 | # | |
252b5132 RH |
526 | # Each option may occur at most once. |
527 | # | |
528 | # After the option lines come regexp lines. `run_dump_test' calls | |
529 | # `regexp_diff' to compare the output of the dumping tool against the | |
530 | # regexps in FILE.d. `regexp_diff' is defined later in this file; see | |
531 | # further comments there. | |
532 | ||
e8119602 | 533 | proc run_dump_test { name {extra_options {}} } { |
252b5132 | 534 | global subdir srcdir |
4b0d96c2 HPN |
535 | global OBJDUMP NM AS OBJCOPY READELF |
536 | global OBJDUMPFLAGS NMFLAGS ASFLAGS OBJCOPYFLAGS READELFFLAGS | |
368886ac | 537 | global ADDR2LINE ADDR2LINEFLAGS |
252b5132 | 538 | global host_triplet |
139e4a70 | 539 | global env |
252b5132 RH |
540 | |
541 | if [string match "*/*" $name] { | |
542 | set file $name | |
543 | set name [file tail $name] | |
544 | } else { | |
545 | set file "$srcdir/$subdir/$name" | |
546 | } | |
547 | set opt_array [slurp_options "${file}.d"] | |
548 | if { $opt_array == -1 } { | |
61feeec2 | 549 | perror "error reading options from $file.d" |
252b5132 RH |
550 | unresolved $subdir/$name |
551 | return | |
552 | } | |
368886ac | 553 | set opts(addr2line) {} |
252b5132 RH |
554 | set opts(as) {} |
555 | set opts(objdump) {} | |
556 | set opts(nm) {} | |
557 | set opts(objcopy) {} | |
4b0d96c2 | 558 | set opts(readelf) {} |
252b5132 RH |
559 | set opts(name) {} |
560 | set opts(PROG) {} | |
561 | set opts(source) {} | |
89210bdc | 562 | set opts(dump) {} |
ff970196 | 563 | set opts(stderr) {} |
8c2784a5 | 564 | set opts(error) {} |
9a5c4b9e | 565 | set opts(error-output) {} |
cfdf4aaa | 566 | set opts(warning) {} |
9a5c4b9e PB |
567 | set opts(target) {} |
568 | set opts(not-target) {} | |
569 | set opts(skip) {} | |
570 | set opts(not-skip) {} | |
b27423bb | 571 | set opts(section-subst) {} |
252b5132 RH |
572 | |
573 | foreach i $opt_array { | |
574 | set opt_name [lindex $i 0] | |
575 | set opt_val [lindex $i 1] | |
576 | if ![info exists opts($opt_name)] { | |
577 | perror "unknown option $opt_name in file $file.d" | |
578 | unresolved $subdir/$name | |
579 | return | |
580 | } | |
581 | if [string length $opts($opt_name)] { | |
582 | perror "option $opt_name multiply set in $file.d" | |
583 | unresolved $subdir/$name | |
584 | return | |
585 | } | |
7f6a71ff JM |
586 | if { $opt_name == "as" } { |
587 | set opt_val [subst $opt_val] | |
588 | } | |
252b5132 RH |
589 | set opts($opt_name) $opt_val |
590 | } | |
591 | ||
e8119602 CD |
592 | foreach i $extra_options { |
593 | set opt_name [lindex $i 0] | |
594 | set opt_val [lindex $i 1] | |
595 | if ![info exists opts($opt_name)] { | |
596 | perror "unknown option $opt_name given in extra_opts" | |
597 | unresolved $subdir/$name | |
598 | return | |
599 | } | |
600 | # add extra option to end of existing option, adding space | |
601 | # if necessary. | |
602 | if [string length $opts($opt_name)] { | |
603 | append opts($opt_name) " " | |
604 | } | |
605 | append opts($opt_name) $opt_val | |
606 | } | |
607 | ||
9a5c4b9e PB |
608 | if { $opts(name) == "" } { |
609 | set testname "$subdir/$name" | |
610 | } else { | |
611 | set testname $opts(name) | |
612 | } | |
613 | verbose "Testing $testname" | |
614 | ||
ba7f26d2 | 615 | if { (($opts(warning) != "") && ($opts(error) != "")) \ |
9a5c4b9e PB |
616 | || (($opts(warning) != "") && ($opts(stderr) != "")) \ |
617 | || (($opts(error-output) != "") && ($opts(stderr) != "")) \ | |
618 | || (($opts(error-output) != "") && ($opts(error) != "")) \ | |
619 | || (($opts(error-output) != "") && ($opts(warning) != "")) } { | |
620 | perror "$testname: bad mix of stderr, error-output, error, and warning test-directives" | |
621 | unresolved $testname | |
ba7f26d2 AM |
622 | return |
623 | } | |
9a5c4b9e PB |
624 | if { $opts(error-output) != "" } then { |
625 | set opts(stderr) $opts(error-output) | |
626 | } | |
ba7f26d2 AM |
627 | |
628 | set program "" | |
629 | # It's meaningless to require an output-testing method when we | |
630 | # expect an error. | |
9a5c4b9e | 631 | if { $opts(error) == "" && $opts(error-output) == "" } { |
ba7f26d2 AM |
632 | if {$opts(PROG) != ""} { |
633 | switch -- $opts(PROG) { | |
368886ac | 634 | addr2line { set program addr2line } |
ba7f26d2 AM |
635 | objdump { set program objdump } |
636 | nm { set program nm } | |
637 | objcopy { set program objcopy } | |
638 | readelf { set program readelf } | |
639 | default { | |
640 | perror "unrecognized program option $opts(PROG) in $file.d" | |
9a5c4b9e | 641 | unresolved $testname |
ba7f26d2 AM |
642 | return } |
643 | } | |
644 | } else { | |
645 | # Guess which program to run, by seeing which option was specified. | |
368886ac | 646 | foreach p {objdump objcopy nm readelf addr2line} { |
ba7f26d2 AM |
647 | if {$opts($p) != ""} { |
648 | if {$program != ""} { | |
649 | perror "ambiguous dump program in $file.d" | |
9a5c4b9e | 650 | unresolved $testname |
ba7f26d2 AM |
651 | return |
652 | } else { | |
653 | set program $p | |
654 | } | |
252b5132 RH |
655 | } |
656 | } | |
657 | } | |
ba7f26d2 | 658 | if { $program == "" && $opts(warning) == "" } { |
252b5132 | 659 | perror "dump program unspecified in $file.d" |
9a5c4b9e | 660 | unresolved $testname |
252b5132 RH |
661 | return |
662 | } | |
663 | } | |
664 | ||
9a5c4b9e PB |
665 | # Handle skipping the test on specified targets. |
666 | # You can have both skip/not-skip and target/not-target, but you can't | |
667 | # have both skip and not-skip, or target and not-target, in the same file. | |
668 | if { $opts(skip) != "" } then { | |
669 | if { $opts(not-skip) != "" } then { | |
670 | perror "$testname: mixing skip and not-skip directives is invalid" | |
671 | unresolved $testname | |
672 | return | |
673 | } | |
674 | foreach glob $opts(skip) { | |
675 | if {[istarget $glob]} { return } | |
676 | } | |
677 | } | |
678 | if { $opts(not-skip) != "" } then { | |
679 | set skip 1 | |
680 | foreach glob $opts(not-skip) { | |
681 | if {[istarget $glob]} { | |
682 | set skip 0 | |
683 | break | |
684 | } | |
685 | } | |
686 | if {$skip} { return } | |
687 | } | |
688 | if { $opts(target) != "" } then { | |
689 | if { $opts(not-target) != "" } then { | |
690 | perror "$testname: mixing target and not-target directives is invalid" | |
691 | unresolved $testname | |
692 | return | |
693 | } | |
694 | set skip 1 | |
695 | foreach glob $opts(target) { | |
696 | if {[istarget $glob]} { | |
697 | set skip 0 | |
698 | break | |
699 | } | |
700 | } | |
701 | if {$skip} { | |
702 | unsupported $testname | |
703 | return | |
704 | } | |
252b5132 | 705 | } |
9a5c4b9e PB |
706 | if { $opts(not-target) != "" } then { |
707 | foreach glob $opts(not-target) { | |
708 | if {[istarget $glob]} { | |
709 | unsupported $testname | |
710 | return | |
711 | } | |
712 | } | |
713 | } | |
714 | ||
252b5132 RH |
715 | |
716 | if { $opts(source) == "" } { | |
717 | set sourcefile ${file}.s | |
718 | } else { | |
719 | set sourcefile $srcdir/$subdir/$opts(source) | |
720 | } | |
721 | ||
89210bdc MR |
722 | if { $opts(dump) == "" } { |
723 | set dumpfile ${file}.d | |
724 | } else { | |
725 | set dumpfile $srcdir/$subdir/$opts(dump) | |
726 | } | |
727 | ||
7f6a71ff | 728 | set cmd "$AS $ASFLAGS $opts(as) -o dump.o $sourcefile" |
cfdf4aaa | 729 | send_log "$cmd\n" |
7f6a71ff JM |
730 | set status [gas_host_run $cmd ""] |
731 | set cmdret [lindex $status 0] | |
732 | set comp_output [prune_warnings [lindex $status 1]] | |
252b5132 | 733 | |
ba7f26d2 AM |
734 | set expmsg $opts(error) |
735 | if { $opts(warning) != "" } { | |
736 | set expmsg $opts(warning) | |
737 | } | |
738 | if { $cmdret != 0 || $comp_output != "" || $expmsg != "" } then { | |
cfdf4aaa HPN |
739 | # If the executed program writes to stderr and stderr is not |
740 | # redirected, exec *always* returns failure, regardless of the | |
741 | # program exit code. Thankfully, we can retrieve the true | |
742 | # return status from a special variable. Redirection would | |
743 | # cause a tcl-specific message to be appended, and we'd rather | |
744 | # not deal with that if we can help it. | |
745 | global errorCode | |
746 | if { $cmdret != 0 && [lindex $errorCode 0] == "NONE" } { | |
747 | set cmdret 0 | |
748 | } | |
749 | ||
750 | set exitstat "succeeded" | |
751 | if { $cmdret != 0 } { set exitstat "failed" } | |
752 | ||
9a5c4b9e PB |
753 | send_log "$comp_output\n" |
754 | verbose "$comp_output" 3 | |
ff970196 | 755 | if { $opts(stderr) == "" } then { |
ba7f26d2 | 756 | if { [regexp $expmsg $comp_output] \ |
cfdf4aaa | 757 | && (($cmdret == 0) == ($opts(warning) != "")) } { |
ba7f26d2 AM |
758 | # We have the expected output from gas. |
759 | # Return if there's nothing more to do. | |
760 | if { $opts(error) != "" || $program == "" } { | |
8c2784a5 TR |
761 | pass $testname |
762 | return | |
763 | } | |
ba7f26d2 AM |
764 | } else { |
765 | verbose -log "$exitstat with: <$comp_output>, expected: <$expmsg>" | |
766 | ||
cfdf4aaa HPN |
767 | fail $testname |
768 | return | |
8c2784a5 | 769 | } |
ff970196 CD |
770 | } else { |
771 | catch {write_file dump.stderr "$comp_output"} write_output | |
772 | if ![string match "" $write_output] then { | |
773 | send_log "error writing dump.stderr: $write_output\n" | |
774 | verbose "error writing dump.stderr: $write_output" 3 | |
775 | send_log "$comp_output\n" | |
776 | verbose "$comp_output" 3 | |
777 | fail $testname | |
778 | return | |
779 | } | |
780 | set stderrfile $srcdir/$subdir/$opts(stderr) | |
ff970196 | 781 | verbose "wrote pruned stderr to dump.stderr" 3 |
b27423bb | 782 | if { [regexp_diff "dump.stderr" "$stderrfile" ""] } then { |
8c2784a5 | 783 | if { $opts(error) != "" } { |
cfdf4aaa | 784 | verbose -log "$exitstat with: <$comp_output>, expected: <$opts(error)>" |
8c2784a5 TR |
785 | if [regexp $opts(error) $comp_output] { |
786 | pass $testname | |
787 | return | |
788 | } | |
789 | } | |
ff970196 CD |
790 | fail $testname |
791 | verbose "pruned stderr is [file_contents "dump.stderr"]" 2 | |
792 | return | |
9a5c4b9e PB |
793 | } elseif { $opts(error-output) != "" } then { |
794 | pass $testname | |
795 | return | |
ff970196 CD |
796 | } |
797 | } | |
cbd3921c NC |
798 | } else { |
799 | if { $opts(error) != "" || $opts(error-output) != "" } { | |
800 | fail $testname | |
801 | } | |
252b5132 RH |
802 | } |
803 | ||
ba7f26d2 AM |
804 | if { $program == "" } { |
805 | return | |
806 | } | |
807 | set progopts1 $opts($program) | |
808 | eval set progopts \$[string toupper $program]FLAGS | |
809 | eval set binary \$[string toupper $program] | |
810 | ||
7f6a71ff | 811 | if { ![is_remote host] && [which $binary] == 0 } { |
252b5132 RH |
812 | untested $testname |
813 | return | |
814 | } | |
815 | ||
b27423bb TG |
816 | # For objdump, automatically translate standard section names to the targets one, |
817 | # if they are different. | |
818 | set sect_names [get_standard_section_names] | |
819 | if { $sect_names != "" && $program == "objdump" && $opts(section-subst) == ""} { | |
820 | regsub -- "-j \\.text" $progopts1 "-j [lindex $sect_names 0]" progopts1 | |
821 | regsub -- "-j \\.data" $progopts1 "-j [lindex $sect_names 1]" progopts1 | |
822 | regsub -- "-j \\.bss" $progopts1 "-j [lindex $sect_names 2]" progopts1 | |
823 | } | |
824 | ||
252b5132 RH |
825 | if { $progopts1 == "" } { set $progopts1 "-r" } |
826 | verbose "running $binary $progopts $progopts1" 3 | |
827 | ||
828 | # Objcopy, unlike the other two, won't send its output to stdout, | |
829 | # so we have to run it specially. | |
7f6a71ff JM |
830 | set cmd "$binary $progopts $progopts1 dump.o" |
831 | set redir ">dump.out" | |
252b5132 | 832 | if { $program == "objcopy" } { |
139e4a70 | 833 | set cmd "$binary $progopts $progopts1 dump.o dump.out" |
7f6a71ff | 834 | set redir "" |
139e4a70 AM |
835 | } |
836 | ||
837 | # Ensure consistent sorting of symbols | |
838 | if {[info exists env(LC_ALL)]} { | |
839 | set old_lc_all $env(LC_ALL) | |
840 | } | |
841 | set env(LC_ALL) "C" | |
842 | send_log "$cmd\n" | |
7f6a71ff JM |
843 | set status [gas_host_run "$cmd" "$redir"] |
844 | set comp_output [prune_warnings [lindex $status 1]] | |
139e4a70 AM |
845 | if {[info exists old_lc_all]} { |
846 | set env(LC_ALL) $old_lc_all | |
252b5132 | 847 | } else { |
139e4a70 AM |
848 | unset env(LC_ALL) |
849 | } | |
850 | set comp_output [prune_warnings $comp_output] | |
851 | if ![string match "" $comp_output] then { | |
852 | send_log "$comp_output\n" | |
853 | fail $testname | |
854 | return | |
252b5132 RH |
855 | } |
856 | ||
b27423bb TG |
857 | # Create the substition list only for objdump reference. |
858 | if { $sect_names != "" && $program == "objdump" } { | |
859 | # Some testcases use ".text" while others use "\.text". | |
860 | set regexp_subst [list "\\\\?\\.text" [lindex $sect_names 0] \ | |
861 | "\\\\?\\.data" [lindex $sect_names 1] \ | |
862 | "\\\\?\\.bss" [lindex $sect_names 2] ] | |
863 | } else { | |
864 | set regexp_subst "" | |
865 | } | |
866 | ||
252b5132 | 867 | verbose_eval {[file_contents "dump.out"]} 3 |
b27423bb | 868 | if { [regexp_diff "dump.out" "${dumpfile}" $regexp_subst] } then { |
252b5132 RH |
869 | fail $testname |
870 | verbose "output is [file_contents "dump.out"]" 2 | |
871 | return | |
872 | } | |
873 | ||
874 | pass $testname | |
875 | } | |
876 | ||
877 | proc slurp_options { file } { | |
878 | if [catch { set f [open $file r] } x] { | |
879 | #perror "couldn't open `$file': $x" | |
880 | perror "$x" | |
881 | return -1 | |
882 | } | |
883 | set opt_array {} | |
884 | # whitespace expression | |
885 | set ws {[ ]*} | |
886 | set nws {[^ ]*} | |
887 | # whitespace is ignored anywhere except within the options list; | |
9a5c4b9e | 888 | # option names are alphabetic plus dash |
368886ac | 889 | set pat "^#${ws}(\[a-zA-Z0-9-\]*)$ws:${ws}(.*)$ws\$" |
252b5132 RH |
890 | while { [gets $f line] != -1 } { |
891 | set line [string trim $line] | |
892 | # Whitespace here is space-tab. | |
893 | if [regexp $pat $line xxx opt_name opt_val] { | |
894 | # match! | |
895 | lappend opt_array [list $opt_name $opt_val] | |
9a5c4b9e | 896 | } elseif {![regexp "^#" $line ]} { |
252b5132 RH |
897 | break |
898 | } | |
899 | } | |
900 | close $f | |
901 | return $opt_array | |
902 | } | |
903 | ||
904 | proc objdump { opts } { | |
905 | global OBJDUMP | |
906 | global comp_output | |
907 | global host_triplet | |
908 | ||
7f6a71ff JM |
909 | set status [gas_host_run "$OBJDUMP $opts" ""] |
910 | set comp_output [prune_warnings [lindex $status 1]] | |
252b5132 RH |
911 | verbose "objdump output=$comp_output\n" 3 |
912 | } | |
913 | ||
914 | proc objdump_start_no_subdir { prog opts } { | |
915 | global OBJDUMP | |
916 | global srcdir | |
917 | global spawn_id | |
918 | ||
919 | verbose "Starting $OBJDUMP $opts $prog" 2 | |
7f6a71ff JM |
920 | set status [gas_host_run "$OBJDUMP $opts $prog" ">&gas.out"] |
921 | spawn -noecho -nottycopy cat gas.out | |
252b5132 RH |
922 | } |
923 | ||
924 | proc objdump_finish { } { | |
925 | global spawn_id | |
926 | ||
927 | catch "close" | |
928 | catch "wait" | |
929 | } | |
930 | ||
931 | # Default timeout is 10 seconds, loses on a slow machine. But some | |
932 | # configurations of dejagnu may override it. | |
933 | if {$timeout<120} then { set timeout 120 } | |
934 | ||
935 | expect_after -i { | |
936 | timeout { perror "timeout" } | |
937 | "virtual memory exhausted" { perror "virtual memory exhausted" } | |
938 | buffer_full { perror "buffer full" } | |
939 | eof { perror "eof" } | |
940 | } | |
941 | ||
b27423bb TG |
942 | # regexp_diff, based on simple_diff taken from ld test suite. |
943 | # Compares two files line-by-line. | |
944 | # FILE_1 contains strings, FILE_2 contains regexps and #-comments | |
945 | # Blank lines are ignored in either file. | |
946 | # Subsitutions in REF_SUBST are applied on FILE_2 lines. | |
947 | # Returns non-zero if differences exist. | |
252b5132 | 948 | # |
b27423bb | 949 | proc regexp_diff { file_1 file_2 ref_subst} { |
252b5132 RH |
950 | |
951 | set eof -1 | |
952 | set end_1 0 | |
953 | set end_2 0 | |
954 | set differences 0 | |
955 | set diff_pass 0 | |
956 | ||
957 | if [file exists $file_1] then { | |
958 | set file_a [open $file_1 r] | |
959 | } else { | |
04248055 | 960 | perror "$file_1 doesn't exist" |
252b5132 RH |
961 | return 1 |
962 | } | |
963 | ||
964 | if [file exists $file_2] then { | |
965 | set file_b [open $file_2 r] | |
966 | } else { | |
04248055 | 967 | perror "$file_2 doesn't exist" |
252b5132 RH |
968 | close $file_a |
969 | return 1 | |
970 | } | |
971 | ||
972 | verbose " Regexp-diff'ing: $file_1 $file_2" 2 | |
973 | ||
974 | while { 1 } { | |
975 | set line_a "" | |
976 | set line_b "" | |
977 | while { [string length $line_a] == 0 } { | |
b27423bb | 978 | # Ignore blank line in FILE_1. |
252b5132 RH |
979 | if { [gets $file_a line_a] == $eof } { |
980 | set end_1 1 | |
981 | break | |
982 | } | |
983 | } | |
984 | while { [string length $line_b] == 0 || [string match "#*" $line_b] } { | |
985 | if [ string match "#pass" $line_b ] { | |
986 | set end_2 1 | |
987 | set diff_pass 1 | |
988 | break | |
a6ea59ce GK |
989 | } elseif [ string match "#..." $line_b ] { |
990 | if { [gets $file_b line_b] == $eof } { | |
991 | set end_2 1 | |
5cfd5a0c | 992 | set diff_pass 1 |
a6ea59ce GK |
993 | break |
994 | } | |
b27423bb TG |
995 | # Substitute on the reference. |
996 | foreach {name value} $ref_subst { | |
997 | regsub -- $name $line_b $value line_b | |
998 | } | |
a6ea59ce GK |
999 | verbose "looking for \"^$line_b$\"" 3 |
1000 | while { ![regexp "^$line_b$" "$line_a"] } { | |
1001 | verbose "skipping \"$line_a\"" 3 | |
1002 | if { [gets $file_a line_a] == $eof } { | |
1003 | set end_1 1 | |
1004 | break | |
1005 | } | |
1006 | } | |
1007 | break | |
252b5132 RH |
1008 | } |
1009 | if { [gets $file_b line_b] == $eof } { | |
1010 | set end_2 1 | |
1011 | break | |
1012 | } | |
1013 | } | |
1014 | ||
139e4a70 AM |
1015 | if { $diff_pass } { |
1016 | break | |
1017 | } elseif { $end_1 && $end_2 } { | |
252b5132 RH |
1018 | break |
1019 | } elseif { $end_1 } { | |
1020 | send_log "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1\n" | |
1021 | verbose "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1" 3 | |
1022 | set differences 1 | |
1023 | break | |
1024 | } elseif { $end_2 } { | |
1025 | send_log "extra lines in $file_1 starting with \"^$line_a$\"\nEOF from $file_2\n" | |
1026 | verbose "extra lines in $file_1 starting with \"^$line_a$\"\nEOF from $file_2\n" 3 | |
1027 | set differences 1 | |
1028 | break | |
1029 | } else { | |
b27423bb TG |
1030 | # Substitute on the reference. |
1031 | foreach {name value} $ref_subst { | |
1032 | regsub -- $name $line_b $value line_b | |
1033 | } | |
252b5132 RH |
1034 | verbose "regexp \"^$line_b$\"\nline \"$line_a\"" 3 |
1035 | if ![regexp "^$line_b$" "$line_a"] { | |
1036 | send_log "regexp_diff match failure\n" | |
1037 | send_log "regexp \"^$line_b$\"\nline \"$line_a\"\n" | |
3ad62fc4 | 1038 | verbose "regexp_diff match failure\n" 3 |
252b5132 | 1039 | set differences 1 |
252b5132 RH |
1040 | } |
1041 | } | |
1042 | } | |
1043 | ||
1044 | if { $differences == 0 && !$diff_pass && [eof $file_a] != [eof $file_b] } { | |
1045 | send_log "$file_1 and $file_2 are different lengths\n" | |
1046 | verbose "$file_1 and $file_2 are different lengths" 3 | |
1047 | set differences 1 | |
1048 | } | |
1049 | ||
1050 | close $file_a | |
1051 | close $file_b | |
1052 | ||
1053 | return $differences | |
1054 | } | |
1055 | ||
1056 | proc file_contents { filename } { | |
1057 | set file [open $filename r] | |
1058 | set contents [read $file] | |
1059 | close $file | |
1060 | return $contents | |
1061 | } | |
1062 | ||
ff970196 CD |
1063 | proc write_file { filename contents } { |
1064 | set file [open $filename w] | |
1065 | puts $file "$contents" | |
1066 | close $file | |
1067 | } | |
1068 | ||
252b5132 RH |
1069 | proc verbose_eval { expr { level 1 } } { |
1070 | global verbose | |
1071 | if $verbose>$level then { eval verbose "$expr" $level } | |
1072 | } | |
1073 | ||
1074 | # This definition is taken from an unreleased version of DejaGnu. Once | |
1075 | # that version gets released, and has been out in the world for a few | |
1076 | # months at least, it may be safe to delete this copy. | |
1077 | if ![string length [info proc prune_warnings]] { | |
1078 | # | |
1079 | # prune_warnings -- delete various system verbosities from TEXT. | |
1080 | # | |
1081 | # An example is: | |
1082 | # ld.so: warning: /usr/lib/libc.so.1.8.1 has older revision than expected 9 | |
1083 | # | |
1084 | # Sites with particular verbose os's may wish to override this in site.exp. | |
1085 | # | |
1086 | proc prune_warnings { text } { | |
1087 | # This is from sun4's. Do it for all machines for now. | |
1088 | # The "\\1" is to try to preserve a "\n" but only if necessary. | |
1089 | regsub -all "(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text "\\1" text | |
1090 | ||
1091 | # It might be tempting to get carried away and delete blank lines, etc. | |
1092 | # Just delete *exactly* what we're ask to, and that's it. | |
1093 | return $text | |
1094 | } | |
1095 | } | |
dfeb0666 | 1096 | |
dc89df6a | 1097 | # run_list_test NAME (optional): OPTS TESTNAME |
dfeb0666 | 1098 | # |
6dfe79a3 NC |
1099 | # Assemble the file "NAME.s" with command line options OPTS and |
1100 | # compare the assembler standard error output against the regular | |
dfeb0666 NC |
1101 | # expressions given in the file "NAME.l". If TESTNAME is provided, |
1102 | # it will be used as the name of the test. | |
1103 | ||
dc89df6a | 1104 | proc run_list_test { name {opts {}} {testname {}} } { |
dfeb0666 NC |
1105 | global srcdir subdir |
1106 | if { [string length $testname] == 0 } then { | |
1107 | set testname "[file tail $subdir] $name" | |
1108 | } | |
1109 | set file $srcdir/$subdir/$name | |
1110 | gas_run ${name}.s $opts ">&dump.out" | |
b27423bb | 1111 | if { [regexp_diff "dump.out" "${file}.l" ""] } then { |
dfeb0666 NC |
1112 | fail $testname |
1113 | verbose "output is [file_contents "dump.out"]" 2 | |
1114 | return | |
1115 | } | |
1116 | pass $testname | |
1117 | } | |
cea10409 L |
1118 | |
1119 | # run_list_test_stdin NAME (optional): OPTS TESTNAME | |
1120 | # | |
1121 | # Similar to run_list_test, but use stdin as input. | |
1122 | ||
1123 | proc run_list_test_stdin { name {opts {}} {testname {}} } { | |
1124 | global srcdir subdir | |
1125 | if { [string length $testname] == 0 } then { | |
1126 | set testname "[file tail $subdir] $name" | |
1127 | } | |
1128 | set file $srcdir/$subdir/$name | |
1129 | gas_run_stdin ${name}.s $opts ">&dump.out" | |
b27423bb | 1130 | if { [regexp_diff "dump.out" "${file}.l" ""] } then { |
cea10409 L |
1131 | fail $testname |
1132 | verbose "output is [file_contents "dump.out"]" 2 | |
1133 | return | |
1134 | } | |
1135 | pass $testname | |
1136 | } |