X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;ds=sidebyside;f=binutils%2Ftestsuite%2Flib%2Futils-lib.exp;fp=binutils%2Ftestsuite%2Flib%2Futils-lib.exp;h=b96043b4d76d58d857d9b3d884bf14fe6b122adf;hb=cbad6d5ba66a94967eaf14df64463a4abca700d6;hp=66a97a4cab70591e28cbb1bb4f1f3654d4b3b2d4;hpb=b110964dfb2d0779466e4e604983d3afa83993a4;p=pf3gnuchains%2Fpf3gnuchains4x.git diff --git a/binutils/testsuite/lib/utils-lib.exp b/binutils/testsuite/lib/utils-lib.exp index 66a97a4cab..b96043b4d7 100644 --- a/binutils/testsuite/lib/utils-lib.exp +++ b/binutils/testsuite/lib/utils-lib.exp @@ -1,5 +1,5 @@ # Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2003, 2004, 2006, 2007, -# 2009 Free Software Foundation, Inc. +# 2009, 2010 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,6 +21,12 @@ # This file was written by Rob Savoye # and extended by Ian Lance Taylor +proc load_common_lib { name } { + load_lib $name +} + +load_common_lib binutils-common.exp + proc binutil_version { prog } { if ![is_remote host] { set path [which $prog] @@ -84,10 +90,10 @@ proc default_binutils_run { prog progargs } { } # -# default_binutils_assemble +# default_binutils_assemble_flags # assemble a file # -proc default_binutils_assemble { source object } { +proc default_binutils_assemble_flags { source object asflags } { global srcdir global host_triplet @@ -105,7 +111,7 @@ proc default_binutils_assemble { source object } { set source asm.s } - set exec_output [target_assemble $source $object ""] + set exec_output [target_assemble $source $object $asflags] set exec_output [prune_warnings $exec_output] if [string match "" $exec_output] { @@ -119,44 +125,6 @@ proc default_binutils_assemble { source object } { } # -# is_elf_format -# true if the object format is known to be ELF -# -proc is_elf_format {} { - if { ![istarget *-*-sysv4*] \ - && ![istarget *-*-unixware*] \ - && ![istarget *-*-elf*] \ - && ![istarget *-*-eabi*] \ - && ![istarget hppa*64*-*-hpux*] \ - && ![istarget ia64-*-hpux*] \ - && ![istarget *-*-linux*] \ - && ![istarget *-*-irix5*] \ - && ![istarget *-*-irix6*] \ - && ![istarget *-*-netbsd*] \ - && ![istarget *-*-solaris2*] } { - return 0 - } - - if { [istarget *-*-linux*aout*] \ - || [istarget *-*-linux*oldld*] } { - return 0 - } - - if { ![istarget *-*-netbsdelf*] \ - && ([istarget *-*-netbsd*aout*] \ - || [istarget *-*-netbsdpe*] \ - || [istarget arm*-*-netbsd*] \ - || [istarget sparc-*-netbsd*] \ - || [istarget i*86-*-netbsd*] \ - || [istarget m68*-*-netbsd*] \ - || [istarget vax-*-netbsd*] \ - || [istarget ns32k-*-netbsd*]) } { - return 0 - } - return 1 -} - -# # exe_ext # Returns target executable extension, if any. # @@ -274,8 +242,8 @@ proc exe_ext {} { # # After the option lines come regexp lines. `run_dump_test' calls # `regexp_diff' to compare the output of the dumping tool against the -# regexps in FILE.d. `regexp_diff' is defined later in this file; see -# further comments there. +# regexps in FILE.d. `regexp_diff' is defined in binutils-common.exp; +# see further comments there. proc run_dump_test { name {extra_options {}} } { global subdir srcdir @@ -301,6 +269,7 @@ proc run_dump_test { name {extra_options {}} } { } set opts(addr2line) {} set opts(ar) {} + set opts(as) {} set opts(nm) {} set opts(objcopy) {} set opts(objdump) {} @@ -385,6 +354,7 @@ proc run_dump_test { name {extra_options {}} } { } strings { set program strings } elfedit { set program elfedit } + nm { set program nm } default { perror "unrecognized program option $opts(PROG) in $file.d" unresolved $testname @@ -475,7 +445,7 @@ proc run_dump_test { name {extra_options {}} } { set srcfile $srcdir/$subdir/$opts(source) } - set exec_output [binutils_assemble ${srcfile} $tempfile] + set exec_output [binutils_assemble_flags ${srcfile} $tempfile $opts(as)] if [string match "" $exec_output] then { send_log "$exec_output\n" verbose "$exec_output" @@ -569,110 +539,6 @@ proc slurp_options { file } { return $opt_array } -# regexp_diff, based on simple_diff taken from ld test suite -# compares two files line-by-line -# file1 contains strings, file2 contains regexps and #-comments -# blank lines are ignored in either file -# returns non-zero if differences exist -# -proc regexp_diff { file_1 file_2 } { - - set eof -1 - set end_1 0 - set end_2 0 - set differences 0 - set diff_pass 0 - - if [file exists $file_1] then { - set file_a [open $file_1 r] - } else { - perror "$file_1 doesn't exist" - return 1 - } - - if [file exists $file_2] then { - set file_b [open $file_2 r] - } else { - perror "$file_2 doesn't exist" - close $file_a - return 1 - } - - verbose " Regexp-diff'ing: $file_1 $file_2" 2 - - while { 1 } { - set line_a "" - set line_b "" - while { [string length $line_a] == 0 } { - if { [gets $file_a line_a] == $eof } { - set end_1 1 - break - } - } - while { [string length $line_b] == 0 || [string match "#*" $line_b] } { - if [ string match "#pass" $line_b ] { - set end_2 1 - set diff_pass 1 - break - } elseif [ string match "#..." $line_b ] { - if { [gets $file_b line_b] == $eof } { - set end_2 1 - set diff_pass 1 - break - } - verbose "looking for \"^$line_b$\"" 3 - while { ![regexp "^$line_b$" "$line_a"] } { - verbose "skipping \"$line_a\"" 3 - if { [gets $file_a line_a] == $eof } { - set end_1 1 - break - } - } - break - } - if { [gets $file_b line_b] == $eof } { - set end_2 1 - break - } - } - - if { $diff_pass } { - break - } elseif { $end_1 && $end_2 } { - break - } elseif { $end_1 } { - send_log "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1\n" - verbose "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1" 3 - set differences 1 - break - } elseif { $end_2 } { - send_log "extra lines in $file_1 starting with \"^$line_a$\"\nEOF from $file_2\n" - verbose "extra lines in $file_1 starting with \"^$line_a$\"\nEOF from $file_2\n" 3 - set differences 1 - break - } else { - verbose "regexp \"^$line_b$\"\nline \"$line_a\"" 3 - if ![regexp "^$line_b$" "$line_a"] { - send_log "regexp_diff match failure\n" - send_log "regexp \"^$line_b$\"\nline \"$line_a\"\n" - verbose "regexp_diff match failure\n" 3 - set differences 1 - } - } - } - - if { $differences == 0 && !$diff_pass && [eof $file_a] != [eof $file_b] } { - send_log "$file_1 and $file_2 are different lengths\n" - verbose "$file_1 and $file_2 are different lengths" 3 - set differences 1 - } - - close $file_a - close $file_b - - return $differences -} - proc file_contents { filename } { set file [open $filename r] set contents [read $file]