* coffread.c (coff_sym_fns): Add default_symfile_segments.
[binutils.git] / gas / testsuite / lib / gas-defs.exp
blobeabd018add9ee645107317cdadc4449faabb2418
1 # Copyright (C) 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2 # 2004, 2005, 2007 Free Software Foundation, Inc.
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
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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # dejagnu@gnu.org
21 # This file was written by Ken Raeburn (raeburn@cygnus.com).
23 proc gas_version {} {
24 global AS
25 catch "exec $AS -version < /dev/null" tmp
26 # Should find a way to discard constant parts, keep whatever's
27 # left, so the version string could be almost anything at all...
28 regexp "\[^\n\]* (cygnus-|)(\[-0-9.a-zA-Z-\]+)\[\r\n\].*" $tmp version cyg number
29 if ![info exists number] then {
30 return "[which $AS] (no version number)\n"
32 clone_output "[which $AS] $number\n"
33 unset version
36 proc gas_run { prog as_opts redir } {
37 global AS
38 global ASFLAGS
39 global comp_output
40 global srcdir
41 global subdir
42 global host_triplet
44 verbose -log "Executing $srcdir/lib/run $AS $ASFLAGS $as_opts $srcdir/$subdir/$prog $redir"
45 catch "exec $srcdir/lib/run $AS $ASFLAGS $as_opts $srcdir/$subdir/$prog $redir" comp_output
46 set comp_output [prune_warnings $comp_output]
47 verbose "output was $comp_output"
48 return [list $comp_output ""]
51 proc all_ones { args } {
52 foreach x $args { if [expr $x!=1] { return 0 } }
53 return 1
56 # ${tool}_finish (gas_finish) will be called by runtest.exp. But
57 # gas_finish should only be used with gas_start. We use gas_started
58 # to tell gas_finish if gas_start has been called so that runtest.exp
59 # can call gas_finish without closing the wrong fd.
60 set gas_started 0
62 proc gas_start { prog as_opts } {
63 global AS
64 global ASFLAGS
65 global srcdir
66 global subdir
67 global spawn_id
68 global gas_started
70 set gas_started 1
72 verbose -log "Starting $AS $ASFLAGS $as_opts $prog" 2
73 catch {
74 spawn -noecho -nottycopy $srcdir/lib/run $AS $ASFLAGS $as_opts $srcdir/$subdir/$prog
75 } foo
76 if ![regexp {^[0-9]+} $foo] then {
77 perror "Can't run $subdir/$prog: $foo"
81 proc gas_finish { } {
82 global spawn_id
83 global gas_started
85 if { $gas_started == 1 } {
86 catch "close"
87 catch "wait"
88 set gas_started 0
92 proc want_no_output { testname } {
93 global comp_output
95 if ![string match "" $comp_output] then {
96 send_log "$comp_output\n"
97 verbose "$comp_output" 3
99 if [string match "" $comp_output] then {
100 pass "$testname"
101 return 1
102 } else {
103 fail "$testname"
104 return 0
108 proc gas_test_old { file as_opts testname } {
109 gas_run $file $as_opts ""
110 return [want_no_output $testname]
113 proc gas_test { file as_opts var_opts testname } {
114 global comp_output
116 set i 0
117 foreach word $var_opts {
118 set ignore_stdout($i) [string match "*>" $word]
119 set opt($i) [string trim $word {>}]
120 incr i
122 set max [expr 1<<$i]
123 for {set i 0} {[expr $i<$max]} {incr i} {
124 set maybe_ignore_stdout ""
125 set extra_opts ""
126 for {set bit 0} {(1<<$bit)<$max} {incr bit} {
127 set num [expr 1<<$bit]
128 if [expr $i&$num] then {
129 set extra_opts "$extra_opts $opt($bit)"
130 if $ignore_stdout($bit) then {
131 set maybe_ignore_stdout ">/dev/null"
135 set extra_opts [string trim $extra_opts]
136 gas_run $file "$as_opts $extra_opts" $maybe_ignore_stdout
138 # Should I be able to use a conditional expression here?
139 if [string match "" $extra_opts] then {
140 want_no_output $testname
141 } else {
142 want_no_output "$testname ($extra_opts)"
145 if [info exists errorInfo] then {
146 unset errorInfo
150 proc gas_test_ignore_stdout { file as_opts testname } {
151 global comp_output
153 gas_run $file $as_opts ">/dev/null"
154 want_no_output $testname
157 proc gas_test_error { file as_opts testname } {
158 global comp_output
160 gas_run $file $as_opts ">/dev/null"
161 if ![string match "" $comp_output] then {
162 send_log "$comp_output\n"
163 verbose "$comp_output" 3
165 if [string match "" $comp_output] then {
166 fail "$testname"
167 } else {
168 pass "$testname"
172 proc gas_exit {} {}
174 proc gas_init { args } {
175 global target_cpu
176 global target_cpu_family
177 global target_family
178 global target_vendor
179 global target_os
180 global stdoptlist
182 case "$target_cpu" in {
183 "m68???" { set target_cpu_family m68k }
184 "i[3-7]86" { set target_cpu_family i386 }
185 default { set target_cpu_family $target_cpu }
188 set target_family "$target_cpu_family-$target_vendor-$target_os"
189 set stdoptlist "-a>"
191 if ![istarget "*-*-*"] {
192 perror "Target name [istarget] is not a triple."
194 # Need to return an empty string.
195 return
199 # is_elf_format
200 # true if the object format is known to be ELF
202 proc is_elf_format {} {
203 if { ![istarget *-*-sysv4*] \
204 && ![istarget *-*-unixware*] \
205 && ![istarget *-*-elf*] \
206 && ![istarget *-*-eabi*] \
207 && ![istarget hppa*64*-*-hpux*] \
208 && ![istarget *-*-linux*] \
209 && ![istarget frv-*-uclinux*] \
210 && ![istarget *-*-irix5*] \
211 && ![istarget *-*-irix6*] \
212 && ![istarget *-*-netbsd*] \
213 && ![istarget *-*-openbsd*] \
214 && ![istarget *-*-solaris2*] } {
215 return 0
218 if { [istarget *-*-linux*aout*] \
219 || [istarget *-*-linux*oldld*] } {
220 return 0
223 if { ![istarget *-*-netbsdelf*] \
224 && ([istarget *-*-netbsd*aout*] \
225 || [istarget *-*-netbsdpe*] \
226 || [istarget arm*-*-netbsd*] \
227 || [istarget sparc-*-netbsd*] \
228 || [istarget i*86-*-netbsd*] \
229 || [istarget m68*-*-netbsd*] \
230 || [istarget vax-*-netbsd*] \
231 || [istarget ns32k-*-netbsd*]) } {
232 return 0
235 if { [istarget arm-*-openbsd*] \
236 || [istarget i386-*-openbsd\[0-2\].*] \
237 || [istarget i386-*-openbsd3.\[0-3\]] \
238 || [istarget m68*-*-openbsd*] \
239 || [istarget ns32k-*-openbsd*] \
240 || [istarget sparc-*-openbsd\[0-2\].*] \
241 || [istarget sparc-*-openbsd3.\[0-1\]] \
242 || [istarget vax-*-openbsd*] } {
243 return 0
246 return 1
249 # run_dump_tests TESTCASES EXTRA_OPTIONS
250 # Wrapper for run_dump_test, which is suitable for invoking as
251 # run_dump_tests [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
252 # EXTRA_OPTIONS are passed down to run_dump_test. Honors runtest_file_p.
253 # Body cribbed from dg-runtest.
255 proc run_dump_tests { testcases {extra_options {}} } {
256 global runtests
258 foreach testcase $testcases {
259 # If testing specific files and this isn't one of them, skip it.
260 if ![runtest_file_p $runtests $testcase] {
261 continue
263 run_dump_test [file rootname [file tail $testcase]] $extra_options
268 # run_dump_test FILE (optional:) EXTRA_OPTIONS
270 # Assemble a .s file, then run some utility on it and check the output.
272 # There should be an assembly language file named FILE.s in the test
273 # suite directory, and a pattern file called FILE.d. `run_dump_test'
274 # will assemble FILE.s, run some tool like `objdump', `objcopy', or
275 # `nm' on the .o file to produce textual output, and then analyze that
276 # with regexps. The FILE.d file specifies what program to run, and
277 # what to expect in its output.
279 # The FILE.d file begins with zero or more option lines, which specify
280 # flags to pass to the assembler, the program to run to dump the
281 # assembler's output, and the options it wants. The option lines have
282 # the syntax:
284 # # OPTION: VALUE
286 # OPTION is the name of some option, like "name" or "objdump", and
287 # VALUE is OPTION's value. The valid options are described below.
288 # Whitespace is ignored everywhere, except within VALUE. The option
289 # list ends with the first line that doesn't match the above syntax.
290 # However, a line within the options that begins with a #, but doesn't
291 # have a recognizable option name followed by a colon, is considered a
292 # comment and entirely ignored.
294 # The optional EXTRA_OPTIONS argument to `run_dump_test' is a list of
295 # two-element lists. The first element of each is an option name, and
296 # the second additional arguments to be added on to the end of the
297 # option list as given in FILE.d. (If omitted, no additional options
298 # are added.)
300 # The interesting options are:
302 # name: TEST-NAME
303 # The name of this test, passed to DejaGNU's `pass' and `fail'
304 # commands. If omitted, this defaults to FILE, the root of the
305 # .s and .d files' names.
307 # as: FLAGS
308 # When assembling FILE.s, pass FLAGS to the assembler.
310 # PROG: PROGRAM-NAME
311 # The name of the program to run to analyze the .o file produced
312 # by the assembler. This can be omitted; run_dump_test will guess
313 # which program to run by seeing which of the flags options below
314 # is present.
316 # objdump: FLAGS
317 # nm: FLAGS
318 # objcopy: FLAGS
319 # Use the specified program to analyze the .o file, and pass it
320 # FLAGS, in addition to the .o file name. Note that they are run
321 # with LC_ALL=C in the environment to give consistent sorting
322 # of symbols.
324 # source: SOURCE
325 # Assemble the file SOURCE.s. If omitted, this defaults to FILE.s.
326 # This is useful if several .d files want to share a .s file.
328 # target: GLOBS...
329 # Run this test only on a specified list of targets. More precisely,
330 # each glob in the space-separated list is passed to "istarget"; if
331 # it evaluates true for any of them, the test will be run, otherwise
332 # it will be marked unsupported.
334 # not-target: GLOBS...
335 # Do not run this test on a specified list of targets. Again,
336 # the each glob in the space-separated list is passed to
337 # "istarget", and the test is run if it evaluates *false* for
338 # *all* of them. Otherwise it will be marked unsupported.
340 # skip: GLOBS...
341 # not-skip: GLOBS...
342 # These are exactly the same as "not-target" and "target",
343 # respectively, except that they do nothing at all if the check
344 # fails. They should only be used in groups, to construct a single
345 # test which is run on all targets but with variant options or
346 # expected output on some targets. (For example, see
347 # gas/arm/inst.d and gas/arm/wince_inst.d.)
349 # error: REGEX
350 # An error with message matching REGEX must be emitted for the test
351 # to pass. The PROG, objdump, nm and objcopy options have no
352 # meaning and need not supplied if this is present.
354 # warning: REGEX
355 # Expect a gas warning matching REGEX. It is an error to issue
356 # both "error" and "warning".
358 # stderr: FILE
359 # FILE contains regexp lines to be matched against the diagnostic
360 # output of the assembler. This does not preclude the use of
361 # PROG, nm, objdump, or objcopy.
363 # error-output: FILE
364 # Means the same as 'stderr', but also indicates that the assembler
365 # is expected to exit unsuccessfully (therefore PROG, objdump, nm,
366 # and objcopy have no meaning and should not be supplied).
368 # Each option may occur at most once.
370 # After the option lines come regexp lines. `run_dump_test' calls
371 # `regexp_diff' to compare the output of the dumping tool against the
372 # regexps in FILE.d. `regexp_diff' is defined later in this file; see
373 # further comments there.
375 proc run_dump_test { name {extra_options {}} } {
376 global subdir srcdir
377 global OBJDUMP NM AS OBJCOPY READELF
378 global OBJDUMPFLAGS NMFLAGS ASFLAGS OBJCOPYFLAGS READELFFLAGS
379 global host_triplet
380 global env
382 if [string match "*/*" $name] {
383 set file $name
384 set name [file tail $name]
385 } else {
386 set file "$srcdir/$subdir/$name"
388 set opt_array [slurp_options "${file}.d"]
389 if { $opt_array == -1 } {
390 perror "error reading options from $file.d"
391 unresolved $subdir/$name
392 return
394 set opts(as) {}
395 set opts(objdump) {}
396 set opts(nm) {}
397 set opts(objcopy) {}
398 set opts(readelf) {}
399 set opts(name) {}
400 set opts(PROG) {}
401 set opts(source) {}
402 set opts(stderr) {}
403 set opts(error) {}
404 set opts(error-output) {}
405 set opts(warning) {}
406 set opts(target) {}
407 set opts(not-target) {}
408 set opts(skip) {}
409 set opts(not-skip) {}
411 foreach i $opt_array {
412 set opt_name [lindex $i 0]
413 set opt_val [lindex $i 1]
414 if ![info exists opts($opt_name)] {
415 perror "unknown option $opt_name in file $file.d"
416 unresolved $subdir/$name
417 return
419 if [string length $opts($opt_name)] {
420 perror "option $opt_name multiply set in $file.d"
421 unresolved $subdir/$name
422 return
424 set opts($opt_name) $opt_val
427 foreach i $extra_options {
428 set opt_name [lindex $i 0]
429 set opt_val [lindex $i 1]
430 if ![info exists opts($opt_name)] {
431 perror "unknown option $opt_name given in extra_opts"
432 unresolved $subdir/$name
433 return
435 # add extra option to end of existing option, adding space
436 # if necessary.
437 if [string length $opts($opt_name)] {
438 append opts($opt_name) " "
440 append opts($opt_name) $opt_val
443 if { $opts(name) == "" } {
444 set testname "$subdir/$name"
445 } else {
446 set testname $opts(name)
448 verbose "Testing $testname"
450 if { (($opts(warning) != "") && ($opts(error) != "")) \
451 || (($opts(warning) != "") && ($opts(stderr) != "")) \
452 || (($opts(error-output) != "") && ($opts(stderr) != "")) \
453 || (($opts(error-output) != "") && ($opts(error) != "")) \
454 || (($opts(error-output) != "") && ($opts(warning) != "")) } {
455 perror "$testname: bad mix of stderr, error-output, error, and warning test-directives"
456 unresolved $testname
457 return
459 if { $opts(error-output) != "" } then {
460 set opts(stderr) $opts(error-output)
463 set program ""
464 # It's meaningless to require an output-testing method when we
465 # expect an error.
466 if { $opts(error) == "" && $opts(error-output) == "" } {
467 if {$opts(PROG) != ""} {
468 switch -- $opts(PROG) {
469 objdump { set program objdump }
470 nm { set program nm }
471 objcopy { set program objcopy }
472 readelf { set program readelf }
473 default {
474 perror "unrecognized program option $opts(PROG) in $file.d"
475 unresolved $testname
476 return }
478 } else {
479 # Guess which program to run, by seeing which option was specified.
480 foreach p {objdump objcopy nm readelf} {
481 if {$opts($p) != ""} {
482 if {$program != ""} {
483 perror "ambiguous dump program in $file.d"
484 unresolved $testname
485 return
486 } else {
487 set program $p
492 if { $program == "" && $opts(warning) == "" } {
493 perror "dump program unspecified in $file.d"
494 unresolved $testname
495 return
499 # Handle skipping the test on specified targets.
500 # You can have both skip/not-skip and target/not-target, but you can't
501 # have both skip and not-skip, or target and not-target, in the same file.
502 if { $opts(skip) != "" } then {
503 if { $opts(not-skip) != "" } then {
504 perror "$testname: mixing skip and not-skip directives is invalid"
505 unresolved $testname
506 return
508 foreach glob $opts(skip) {
509 if {[istarget $glob]} { return }
512 if { $opts(not-skip) != "" } then {
513 set skip 1
514 foreach glob $opts(not-skip) {
515 if {[istarget $glob]} {
516 set skip 0
517 break
520 if {$skip} { return }
522 if { $opts(target) != "" } then {
523 if { $opts(not-target) != "" } then {
524 perror "$testname: mixing target and not-target directives is invalid"
525 unresolved $testname
526 return
528 set skip 1
529 foreach glob $opts(target) {
530 if {[istarget $glob]} {
531 set skip 0
532 break
535 if {$skip} {
536 unsupported $testname
537 return
540 if { $opts(not-target) != "" } then {
541 foreach glob $opts(not-target) {
542 if {[istarget $glob]} {
543 unsupported $testname
544 return
550 if { $opts(source) == "" } {
551 set sourcefile ${file}.s
552 } else {
553 set sourcefile $srcdir/$subdir/$opts(source)
556 set cmd "$srcdir/lib/run $AS $ASFLAGS $opts(as) -o dump.o $sourcefile"
557 send_log "$cmd\n"
558 set cmdret [catch "exec $cmd" comp_output]
559 set comp_output [prune_warnings $comp_output]
561 set expmsg $opts(error)
562 if { $opts(warning) != "" } {
563 set expmsg $opts(warning)
565 if { $cmdret != 0 || $comp_output != "" || $expmsg != "" } then {
566 # If the executed program writes to stderr and stderr is not
567 # redirected, exec *always* returns failure, regardless of the
568 # program exit code. Thankfully, we can retrieve the true
569 # return status from a special variable. Redirection would
570 # cause a tcl-specific message to be appended, and we'd rather
571 # not deal with that if we can help it.
572 global errorCode
573 if { $cmdret != 0 && [lindex $errorCode 0] == "NONE" } {
574 set cmdret 0
577 set exitstat "succeeded"
578 if { $cmdret != 0 } { set exitstat "failed" }
580 send_log "$comp_output\n"
581 verbose "$comp_output" 3
582 if { $opts(stderr) == "" } then {
583 if { [regexp $expmsg $comp_output] \
584 && (($cmdret == 0) == ($opts(warning) != "")) } {
585 # We have the expected output from gas.
586 # Return if there's nothing more to do.
587 if { $opts(error) != "" || $program == "" } {
588 pass $testname
589 return
591 } else {
592 verbose -log "$exitstat with: <$comp_output>, expected: <$expmsg>"
594 fail $testname
595 return
597 } else {
598 catch {write_file dump.stderr "$comp_output"} write_output
599 if ![string match "" $write_output] then {
600 send_log "error writing dump.stderr: $write_output\n"
601 verbose "error writing dump.stderr: $write_output" 3
602 send_log "$comp_output\n"
603 verbose "$comp_output" 3
604 fail $testname
605 return
607 set stderrfile $srcdir/$subdir/$opts(stderr)
608 verbose "wrote pruned stderr to dump.stderr" 3
609 if { [regexp_diff "dump.stderr" "$stderrfile"] } then {
610 if { $opts(error) != "" } {
611 verbose -log "$exitstat with: <$comp_output>, expected: <$opts(error)>"
612 if [regexp $opts(error) $comp_output] {
613 pass $testname
614 return
617 fail $testname
618 verbose "pruned stderr is [file_contents "dump.stderr"]" 2
619 return
620 } elseif { $opts(error-output) != "" } then {
621 pass $testname
622 return
627 if { $program == "" } {
628 return
630 set progopts1 $opts($program)
631 eval set progopts \$[string toupper $program]FLAGS
632 eval set binary \$[string toupper $program]
634 if { [which $binary] == 0 } {
635 untested $testname
636 return
639 if { $progopts1 == "" } { set $progopts1 "-r" }
640 verbose "running $binary $progopts $progopts1" 3
642 # Objcopy, unlike the other two, won't send its output to stdout,
643 # so we have to run it specially.
644 set cmd "$binary $progopts $progopts1 dump.o > dump.out"
645 if { $program == "objcopy" } {
646 set cmd "$binary $progopts $progopts1 dump.o dump.out"
649 # Ensure consistent sorting of symbols
650 if {[info exists env(LC_ALL)]} {
651 set old_lc_all $env(LC_ALL)
653 set env(LC_ALL) "C"
654 send_log "$cmd\n"
655 catch "exec $cmd" comp_output
656 if {[info exists old_lc_all]} {
657 set env(LC_ALL) $old_lc_all
658 } else {
659 unset env(LC_ALL)
661 set comp_output [prune_warnings $comp_output]
662 if ![string match "" $comp_output] then {
663 send_log "$comp_output\n"
664 fail $testname
665 return
668 verbose_eval {[file_contents "dump.out"]} 3
669 if { [regexp_diff "dump.out" "${file}.d"] } then {
670 fail $testname
671 verbose "output is [file_contents "dump.out"]" 2
672 return
675 pass $testname
678 proc slurp_options { file } {
679 if [catch { set f [open $file r] } x] {
680 #perror "couldn't open `$file': $x"
681 perror "$x"
682 return -1
684 set opt_array {}
685 # whitespace expression
686 set ws {[ ]*}
687 set nws {[^ ]*}
688 # whitespace is ignored anywhere except within the options list;
689 # option names are alphabetic plus dash
690 set pat "^#${ws}(\[a-zA-Z-\]*)$ws:${ws}(.*)$ws\$"
691 while { [gets $f line] != -1 } {
692 set line [string trim $line]
693 # Whitespace here is space-tab.
694 if [regexp $pat $line xxx opt_name opt_val] {
695 # match!
696 lappend opt_array [list $opt_name $opt_val]
697 } elseif {![regexp "^#" $line ]} {
698 break
701 close $f
702 return $opt_array
705 proc objdump { opts } {
706 global OBJDUMP
707 global comp_output
708 global host_triplet
710 catch "exec $OBJDUMP $opts" comp_output
711 set comp_output [prune_warnings $comp_output]
712 verbose "objdump output=$comp_output\n" 3
715 proc objdump_start_no_subdir { prog opts } {
716 global OBJDUMP
717 global srcdir
718 global spawn_id
720 verbose "Starting $OBJDUMP $opts $prog" 2
721 catch {
722 spawn -noecho -nottyinit $srcdir/lib/run $OBJDUMP $opts $prog
723 } foo
724 if ![regexp {^[0-9]+} $foo] then {
725 perror "Can't run $prog: $foo"
729 proc objdump_finish { } {
730 global spawn_id
732 catch "close"
733 catch "wait"
736 # Default timeout is 10 seconds, loses on a slow machine. But some
737 # configurations of dejagnu may override it.
738 if {$timeout<120} then { set timeout 120 }
740 expect_after -i {
741 timeout { perror "timeout" }
742 "virtual memory exhausted" { perror "virtual memory exhausted" }
743 buffer_full { perror "buffer full" }
744 eof { perror "eof" }
747 # regexp_diff, based on simple_diff taken from ld test suite
748 # compares two files line-by-line
749 # file1 contains strings, file2 contains regexps and #-comments
750 # blank lines are ignored in either file
751 # returns non-zero if differences exist
753 proc regexp_diff { file_1 file_2 } {
755 set eof -1
756 set end_1 0
757 set end_2 0
758 set differences 0
759 set diff_pass 0
761 if [file exists $file_1] then {
762 set file_a [open $file_1 r]
763 } else {
764 perror "$file_1 doesn't exist"
765 return 1
768 if [file exists $file_2] then {
769 set file_b [open $file_2 r]
770 } else {
771 perror "$file_2 doesn't exist"
772 close $file_a
773 return 1
776 verbose " Regexp-diff'ing: $file_1 $file_2" 2
778 while { 1 } {
779 set line_a ""
780 set line_b ""
781 while { [string length $line_a] == 0 } {
782 if { [gets $file_a line_a] == $eof } {
783 set end_1 1
784 break
787 while { [string length $line_b] == 0 || [string match "#*" $line_b] } {
788 if [ string match "#pass" $line_b ] {
789 set end_2 1
790 set diff_pass 1
791 break
792 } elseif [ string match "#..." $line_b ] {
793 if { [gets $file_b line_b] == $eof } {
794 set end_2 1
795 set diff_pass 1
796 break
798 verbose "looking for \"^$line_b$\"" 3
799 while { ![regexp "^$line_b$" "$line_a"] } {
800 verbose "skipping \"$line_a\"" 3
801 if { [gets $file_a line_a] == $eof } {
802 set end_1 1
803 break
806 break
808 if { [gets $file_b line_b] == $eof } {
809 set end_2 1
810 break
814 if { $diff_pass } {
815 break
816 } elseif { $end_1 && $end_2 } {
817 break
818 } elseif { $end_1 } {
819 send_log "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1\n"
820 verbose "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1" 3
821 set differences 1
822 break
823 } elseif { $end_2 } {
824 send_log "extra lines in $file_1 starting with \"^$line_a$\"\nEOF from $file_2\n"
825 verbose "extra lines in $file_1 starting with \"^$line_a$\"\nEOF from $file_2\n" 3
826 set differences 1
827 break
828 } else {
829 verbose "regexp \"^$line_b$\"\nline \"$line_a\"" 3
830 if ![regexp "^$line_b$" "$line_a"] {
831 send_log "regexp_diff match failure\n"
832 send_log "regexp \"^$line_b$\"\nline \"$line_a\"\n"
833 verbose "regexp_diff match failure\n" 3
834 set differences 1
839 if { $differences == 0 && !$diff_pass && [eof $file_a] != [eof $file_b] } {
840 send_log "$file_1 and $file_2 are different lengths\n"
841 verbose "$file_1 and $file_2 are different lengths" 3
842 set differences 1
845 close $file_a
846 close $file_b
848 return $differences
851 proc file_contents { filename } {
852 set file [open $filename r]
853 set contents [read $file]
854 close $file
855 return $contents
858 proc write_file { filename contents } {
859 set file [open $filename w]
860 puts $file "$contents"
861 close $file
864 proc verbose_eval { expr { level 1 } } {
865 global verbose
866 if $verbose>$level then { eval verbose "$expr" $level }
869 # This definition is taken from an unreleased version of DejaGnu. Once
870 # that version gets released, and has been out in the world for a few
871 # months at least, it may be safe to delete this copy.
872 if ![string length [info proc prune_warnings]] {
874 # prune_warnings -- delete various system verbosities from TEXT.
876 # An example is:
877 # ld.so: warning: /usr/lib/libc.so.1.8.1 has older revision than expected 9
879 # Sites with particular verbose os's may wish to override this in site.exp.
881 proc prune_warnings { text } {
882 # This is from sun4's. Do it for all machines for now.
883 # The "\\1" is to try to preserve a "\n" but only if necessary.
884 regsub -all "(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text "\\1" text
886 # It might be tempting to get carried away and delete blank lines, etc.
887 # Just delete *exactly* what we're ask to, and that's it.
888 return $text
892 # run_list_test NAME OPTS (optional): TESTNAME
894 # Assemble the file "NAME.d" with command line options OPTS and
895 # compare the assembler standard error output against thee regular
896 # expressions given in the file "NAME.l". If TESTNAME is provided,
897 # it will be used as the name of the test.
899 proc run_list_test { name opts {testname {}} } {
900 global srcdir subdir
901 if { [string length $testname] == 0 } then {
902 set testname "[file tail $subdir] $name"
904 set file $srcdir/$subdir/$name
905 gas_run ${name}.s $opts ">&dump.out"
906 if { [regexp_diff "dump.out" "${file}.l"] } then {
907 fail $testname
908 verbose "output is [file_contents "dump.out"]" 2
909 return
911 pass $testname