From f795c49463234dc347ddd9a1b07ee5b506295b96 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 15 Dec 2017 17:08:56 +1030 Subject: [PATCH] Test binutils_assemble return value This is a followup to "binutils nm testsuite tidy". Since the perror in binutils_assemble has been removed, we need to take more care in failure paths. The patch also fixed a number of .exp files that have multiple tests, where an assembly failure returns from the .exp file. In most cases it is nicer to attempt all tests. * testsuite/binutils-all/ar.exp (unique_symbol): Don't run AR if assembly fails. * testsuite/binutils-all/arc/objdump.exp (check_assembly): If objfile is empty, fail test. * testsuite/binutils-all/arm/objdump.exp: Don't return if assembly fails for a test, continue on to other tests. * testsuite/binutils-all/bfin/objdump.exp: Likewise. * testsuite/binutils-all/hppa/objdump.exp: Likewise. * testsuite/binutils-all/m68k/objdump.exp: Likewise. * testsuite/binutils-all/vax/objdump.exp: Likewise. * testsuite/binutils-all/size.exp: Likewise. * testsuite/binutils-all/nm.exp: Likewise. Move PR12753 test. * testsuite/binutils-all/objcopy.exp: Don't perror on assembly fail. * testsuite/binutils-all/objdump.exp: Report assembly fails. --- binutils/ChangeLog | 17 ++ binutils/testsuite/binutils-all/ar.exp | 1 + .../testsuite/binutils-all/arc/objdump.exp | 4 + .../testsuite/binutils-all/arm/objdump.exp | 101 ++++---- .../testsuite/binutils-all/bfin/objdump.exp | 29 +-- .../testsuite/binutils-all/hppa/objdump.exp | 66 +++--- .../testsuite/binutils-all/m68k/objdump.exp | 58 ++--- binutils/testsuite/binutils-all/nm.exp | 222 +++++++++--------- binutils/testsuite/binutils-all/objcopy.exp | 1 - binutils/testsuite/binutils-all/objdump.exp | 2 + binutils/testsuite/binutils-all/size.exp | 63 ++--- .../testsuite/binutils-all/vax/objdump.exp | 49 ++-- 12 files changed, 323 insertions(+), 290 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index ee53c3a877..f83aa5ca79 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,20 @@ +2017-12-19 Alan Modra + + * testsuite/binutils-all/ar.exp (unique_symbol): Don't run AR + if assembly fails. + * testsuite/binutils-all/arc/objdump.exp (check_assembly): If + objfile is empty, fail test. + * testsuite/binutils-all/arm/objdump.exp: Don't return if assembly + fails for a test, continue on to other tests. + * testsuite/binutils-all/bfin/objdump.exp: Likewise. + * testsuite/binutils-all/hppa/objdump.exp: Likewise. + * testsuite/binutils-all/m68k/objdump.exp: Likewise. + * testsuite/binutils-all/vax/objdump.exp: Likewise. + * testsuite/binutils-all/size.exp: Likewise. + * testsuite/binutils-all/nm.exp: Likewise. Move PR12753 test. + * testsuite/binutils-all/objcopy.exp: Don't perror on assembly fail. + * testsuite/binutils-all/objdump.exp: Report assembly fails. + 2017-12-18 Nick Clifton PR 22532 diff --git a/binutils/testsuite/binutils-all/ar.exp b/binutils/testsuite/binutils-all/ar.exp index 7b93cc6e40..ca422d12c6 100644 --- a/binutils/testsuite/binutils-all/ar.exp +++ b/binutils/testsuite/binutils-all/ar.exp @@ -449,6 +449,7 @@ proc unique_symbol { } { if ![binutils_assemble $srcdir/$subdir/unique.s tmpdir/unique.o] { unresolved $testname + return } if [is_remote host] { diff --git a/binutils/testsuite/binutils-all/arc/objdump.exp b/binutils/testsuite/binutils-all/arc/objdump.exp index a4e6ef05b6..9748d4ac6a 100644 --- a/binutils/testsuite/binutils-all/arc/objdump.exp +++ b/binutils/testsuite/binutils-all/arc/objdump.exp @@ -52,6 +52,10 @@ proc check_assembly { testname objfile expected { disas_flags "" } } { global OBJDUMP global OBJDUMPFLAGS + if [string equal "" $objfile] then { + fail $testname + return + } set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $disas_flags \ $objfile"] diff --git a/binutils/testsuite/binutils-all/arm/objdump.exp b/binutils/testsuite/binutils-all/arm/objdump.exp index 0e74ebbe36..3485d3aa46 100644 --- a/binutils/testsuite/binutils-all/arm/objdump.exp +++ b/binutils/testsuite/binutils-all/arm/objdump.exp @@ -34,35 +34,36 @@ send_user "Version [binutil_version $OBJDUMP]" ########################### if {![binutils_assemble $srcdir/$subdir/thumb2-cond.s tmpdir/thumb2-cond.o]} then { - return -} - -if [is_remote host] { - set objfile [remote_download host tmpdir/thumb2-cond.o] + fail "thumb2-cond (assembling)" } else { - set objfile tmpdir/thumb2-cond.o -} -# Make sure that conditional instructions are correctly decoded. + if [is_remote host] { + set objfile [remote_download host tmpdir/thumb2-cond.o] + } else { + set objfile tmpdir/thumb2-cond.o + } -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --start-address=6 $objfile"] + # Make sure that conditional instructions are correctly decoded. -set want "bcc.w\[ \t\]*e12.*bx\[ \t\]*lr" + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --start-address=6 $objfile"] -if [regexp $want $got] then { - pass "thumb2-cond test1" -} else { - fail "thumb2-cond test1" -} + set want "bcc.w\[ \t\]*e12.*bx\[ \t\]*lr" -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --start-address=10 $objfile"] + if [regexp $want $got] then { + pass "thumb2-cond test1" + } else { + fail "thumb2-cond test1" + } -set want "bx\[ \t\]*lr" + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --start-address=10 $objfile"] -if [regexp $want $got] then { - pass "thumb2-cond test2" -} else { - fail "thumb2-cond test2" + set want "bx\[ \t\]*lr" + + if [regexp $want $got] then { + pass "thumb2-cond test2" + } else { + fail "thumb2-cond test2" + } } ########################### @@ -70,45 +71,47 @@ if [regexp $want $got] then { ########################### if {![binutils_assemble $srcdir/$subdir/simple.s tmpdir/simple.o]} then { - return -} - -if [is_remote host] { - set objfile [remote_download host tmpdir/simple.o] + fail "multiple input files" } else { - set objfile tmpdir/simple.o -} -# Make sure multiple disassemblies come out the same + if [is_remote host] { + set objfile [remote_download host tmpdir/simple.o] + } else { + set objfile tmpdir/simple.o + } -set got [binutils_run $OBJDUMP "-dr $objfile $objfile"] + # Make sure multiple disassemblies come out the same -set want "$objfile:\[ \]*file format.*$objfile:\[ \]*file format.*push.*add.*sub.*str.*add.*ldmfd" + set got [binutils_run $OBJDUMP "-dr $objfile $objfile"] -if [regexp $want $got] then { - pass "multiple input files" -} else { - fail "multiple input files" -} + set want "$objfile:\[ \]*file format.*$objfile:\[ \]*file format.*push.*add.*sub.*str.*add.*ldmfd" -if {![binutils_assemble $srcdir/$subdir/rvct_symbol.s tmpdir/rvct_symbol.o]} then { - return + if [regexp $want $got] then { + pass "multiple input files" + } else { + fail "multiple input files" + } } -if [is_remote host] { - set objfile [remote_download host tmpdir/rvct_symbol.o] +if {![binutils_assemble $srcdir/$subdir/rvct_symbol.s tmpdir/rvct_symbol.o]} then { + fail "skip rvct symbol" } else { - set objfile tmpdir/rvct_symbol.o -} -# Make sure multiple disassemblies come out the same + if [is_remote host] { + set objfile [remote_download host tmpdir/rvct_symbol.o] + } else { + set objfile tmpdir/rvct_symbol.o + } -set got [binutils_run $OBJDUMP "-D $objfile $objfile"] + # Make sure multiple disassemblies come out the same -set want "foo.*global_a.*global_b" + set got [binutils_run $OBJDUMP "-D $objfile $objfile"] -if [regexp $want $got] then { - pass "skip rvct symbol" -} else { - fail "skip rvct symbol" + set want "foo.*global_a.*global_b" + + if [regexp $want $got] then { + pass "skip rvct symbol" + } else { + fail "skip rvct symbol" + } } diff --git a/binutils/testsuite/binutils-all/bfin/objdump.exp b/binutils/testsuite/binutils-all/bfin/objdump.exp index 13305fc273..e063a624ff 100644 --- a/binutils/testsuite/binutils-all/bfin/objdump.exp +++ b/binutils/testsuite/binutils-all/bfin/objdump.exp @@ -30,23 +30,24 @@ send_user "Version [binutil_version $OBJDUMP]" ################################### if {![binutils_assemble $srcdir/$subdir/unknown-mode.s tmpdir/unknown-mode.o]} then { - return -} - -if [is_remote host] { - set objfile [remote_download host tmpdir/unknown-mode.o] + fail "unknown mode test (assembling)" } else { - set objfile tmpdir/unknown-mode.o -} -# Make sure that the unknown mode does not cause abort. + if [is_remote host] { + set objfile [remote_download host tmpdir/unknown-mode.o] + } else { + set objfile tmpdir/unknown-mode.o + } -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -D $objfile"] + # Make sure that the unknown mode does not cause abort. -set want "e1 c1\[ \t\]*ILLEGAL.*34 98 .*\[\r\n\]" + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -D $objfile"] -if [regexp $want $got] then { - pass "unknown mode test" -} else { - fail "unknown mode test" + set want "e1 c1\[ \t\]*ILLEGAL.*34 98 .*\[\r\n\]" + + if [regexp $want $got] then { + pass "unknown mode test" + } else { + fail "unknown mode test" + } } diff --git a/binutils/testsuite/binutils-all/hppa/objdump.exp b/binutils/testsuite/binutils-all/hppa/objdump.exp index b834a22f9c..3f69f34a3f 100644 --- a/binutils/testsuite/binutils-all/hppa/objdump.exp +++ b/binutils/testsuite/binutils-all/hppa/objdump.exp @@ -42,30 +42,31 @@ if {[which $OBJDUMP] == 0} then { send_user "Version [binutil_version $OBJDUMP]" if {![binutils_assemble $srcdir/$subdir/addendbug.s tmpdir/addendbug.o]} then { - return -} - -if [is_remote host] { - set objfile [remote_download host tmpdir/addendbug.o] + fail "addendbug test (assembling)" } else { - set objfile tmpdir/addendbug.o -} -# Make sure the SOM BFD code sign extends constants in R_DATA_OVERRIDE fixups. + if [is_remote host] { + set objfile [remote_download host tmpdir/addendbug.o] + } else { + set objfile tmpdir/addendbug.o + } -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $objfile"] + # Make sure the SOM BFD code sign extends constants in + # R_DATA_OVERRIDE fixups. -if [istarget hppa*-*-*elf*] then { - set want "00000000 R_PARISC_DPREL21L\[ \]+is_idchar-0x00000020.*" -} else { - set want "00000000 R_DP_RELATIVE\[ \]+is_idchar-0x00000020.*" -} + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $objfile"] + if [istarget hppa*-*-*elf*] then { + set want "00000000 R_PARISC_DPREL21L\[ \]+is_idchar-0x00000020.*" + } else { + set want "00000000 R_DP_RELATIVE\[ \]+is_idchar-0x00000020.*" + } -if [regexp $want $got] then { - pass "addendbug test" -} else { - fail "addendbug test" + if [regexp $want $got] then { + pass "addendbug test" + } else { + fail "addendbug test" + } } ########################### @@ -73,23 +74,24 @@ if [regexp $want $got] then { ########################### if {![binutils_assemble $srcdir/$subdir/freg.s tmpdir/freg.o]} then { - return -} - -if [is_remote host] { - set objfile [remote_download host tmpdir/freg.o] + fail "freg test (assembling)" } else { - set objfile tmpdir/freg.o -} -# Make sure that we get R float regs like we're supposed to + if [is_remote host] { + set objfile [remote_download host tmpdir/freg.o] + } else { + set objfile tmpdir/freg.o + } -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"] + # Make sure that we get R float regs like we're supposed to -set want "fmpyfadd,sgl fr4,fr4R,fr5R,fr5" + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"] -if [regexp $want $got] then { - pass "freg test" -} else { - fail "freg test" + set want "fmpyfadd,sgl fr4,fr4R,fr5R,fr5" + + if [regexp $want $got] then { + pass "freg test" + } else { + fail "freg test" + } } diff --git a/binutils/testsuite/binutils-all/m68k/objdump.exp b/binutils/testsuite/binutils-all/m68k/objdump.exp index f1f53dd755..10872525d7 100644 --- a/binutils/testsuite/binutils-all/m68k/objdump.exp +++ b/binutils/testsuite/binutils-all/m68k/objdump.exp @@ -30,25 +30,26 @@ send_user "Version [binutil_version $OBJDUMP]" ########################### if {![binutils_assemble $srcdir/$subdir/movem.s tmpdir/movem.o]} then { - return -} - -if [is_remote host] { - set objfile [remote_download host tmpdir/movem.o] + fail "movem test" } else { - set objfile tmpdir/movem.o -} -# Make sure that the movem is correctly decoded. + if [is_remote host] { + set objfile [remote_download host tmpdir/movem.o] + } else { + set objfile tmpdir/movem.o + } -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"] + # Make sure that the movem is correctly decoded. -set want "moveml %d0-%d3,%sp@-.*moveml %d0-%d3,%sp@\[\r\n\]" + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"] -if [regexp $want $got] then { - pass "movem test" -} else { - fail "movem test" + set want "moveml %d0-%d3,%sp@-.*moveml %d0-%d3,%sp@\[\r\n\]" + + if [regexp $want $got] then { + pass "movem test" + } else { + fail "movem test" + } } ########################### @@ -56,23 +57,24 @@ if [regexp $want $got] then { ########################### if {![binutils_assemble $srcdir/$subdir/fnop.s tmpdir/fnop.o]} then { - return -} - -if [is_remote host] { - set objfile [remote_download host tmpdir/fnop.o] + fail "fnop test" } else { - set objfile tmpdir/fnop.o -} -# Make sure that fnop is decoded as fnop, not fbf. + if [is_remote host] { + set objfile [remote_download host tmpdir/fnop.o] + } else { + set objfile tmpdir/fnop.o + } -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"] + # Make sure that fnop is decoded as fnop, not fbf. -set want "fnop *\[\r\n\]" + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"] -if [regexp $want $got] then { - pass "fnop test" -} else { - fail "fnop test" + set want "fnop *\[\r\n\]" + + if [regexp $want $got] then { + pass "fnop test" + } else { + fail "fnop test" + } } diff --git a/binutils/testsuite/binutils-all/nm.exp b/binutils/testsuite/binutils-all/nm.exp index e60e061ee6..8cdd3d1ea0 100644 --- a/binutils/testsuite/binutils-all/nm.exp +++ b/binutils/testsuite/binutils-all/nm.exp @@ -31,119 +31,94 @@ send_user "Version [binutil_version $NM]" if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then { - return -} - -if [is_remote host] { - set tempfile [remote_download host tmpdir/bintest.o] + fail "nm (assembling)" } else { - set tempfile tmpdir/bintest.o -} -# Test nm with no arguments. + if [is_remote host] { + set tempfile [remote_download host tmpdir/bintest.o] + } else { + set tempfile tmpdir/bintest.o + } -# This test does not work correctly on ECOFF targets, because ECOFF -# stores most symbols twice, which messes up the nm output. -setup_xfail "alpha*-*-osf*" "alpha*-*-netware*" -setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*" -setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*" + # Test nm with no arguments. -# This test does not work correctly on XCOFF targets, because XCOFF -# does not enter static symbols in the symbol table. -setup_xfail "*-*-aix*" + # This test does not work correctly on ECOFF targets, because ECOFF + # stores most symbols twice, which messes up the nm output. + setup_xfail "alpha*-*-osf*" "alpha*-*-netware*" + setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*" + setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*" -set got [binutils_run $NM "$NMFLAGS $tempfile"] + # This test does not work correctly on XCOFF targets, because XCOFF + # does not enter static symbols in the symbol table. + setup_xfail "*-*-aix*" -if [info exists vars] then { unset vars } -while {[regexp "(\[a-zA-Z\]) (\[a-z_\]*_symbol)(.*)" $got all type symbol rest]} { - set vars($symbol) $type - set got $rest -} + set got [binutils_run $NM "$NMFLAGS $tempfile"] -if {![info exists vars(text_symbol)] \ - || $vars(text_symbol) != "T" \ - || ![info exists vars(data_symbol)] \ - || $vars(data_symbol) != "D" \ - || ![info exists vars(common_symbol)] \ - || $vars(common_symbol) != "C" \ - || ![info exists vars(external_symbol)] \ - || $vars(external_symbol) != "U" \ - || ![info exists vars(static_text_symbol)] \ - || $vars(static_text_symbol) != "t" \ - || ![info exists vars(static_data_symbol)] \ - || $vars(static_data_symbol) != "d"} { - fail "nm (no arguments)" -} else { - pass "nm (no arguments)" -} + if [info exists vars] then { unset vars } + while {[regexp "(\[a-zA-Z\]) (\[a-z_\]*_symbol)(.*)" $got all type symbol rest]} { + set vars($symbol) $type + set got $rest + } -# Test nm -g + if {![info exists vars(text_symbol)] \ + || $vars(text_symbol) != "T" \ + || ![info exists vars(data_symbol)] \ + || $vars(data_symbol) != "D" \ + || ![info exists vars(common_symbol)] \ + || $vars(common_symbol) != "C" \ + || ![info exists vars(external_symbol)] \ + || $vars(external_symbol) != "U" \ + || ![info exists vars(static_text_symbol)] \ + || $vars(static_text_symbol) != "t" \ + || ![info exists vars(static_data_symbol)] \ + || $vars(static_data_symbol) != "d"} { + fail "nm (no arguments)" + } else { + pass "nm (no arguments)" + } -set got [binutils_run $NM "$NMFLAGS -g $tempfile"] + # Test nm -g -if [info exists vars] then { unset vars } -while {[regexp "(\[a-z_\]*_symbol)(.*)" $got all symbol rest]} { - set vars($symbol) 1 - set got $rest -} + set got [binutils_run $NM "$NMFLAGS -g $tempfile"] -if {![info exists vars(text_symbol)] \ - || ![info exists vars(data_symbol)] \ - || ![info exists vars(common_symbol)] \ - || ![info exists vars(external_symbol)] \ - || [info exists vars(static_text_symbol)] \ - || [info exists vars(static_data_symbol)]} { - fail "nm -g" -} else { - pass "nm -g" -} + if [info exists vars] then { unset vars } + while {[regexp "(\[a-z_\]*_symbol)(.*)" $got all symbol rest]} { + set vars($symbol) 1 + set got $rest + } -if [is_elf_format] { - # PR binutils/12753 - # Test nm -g on a unique global symbol. - if {![binutils_assemble $srcdir/$subdir/unique.s tmpdir/unique.o]} then { - unsupported "nm -g on unique symbols" + if {![info exists vars(text_symbol)] \ + || ![info exists vars(data_symbol)] \ + || ![info exists vars(common_symbol)] \ + || ![info exists vars(external_symbol)] \ + || [info exists vars(static_text_symbol)] \ + || [info exists vars(static_data_symbol)]} { + fail "nm -g" } else { - if [is_remote host] { - set tmpfile [remote_download host tmpdir/unique.o] - } else { - set tmpfile tmpdir/unique.o - } - - set got [binutils_run $NM "$NMFLAGS -g $tmpfile"] - - if [regexp "u foo" $got] then { - pass "nm -g on unique symbols" - } else { - fail "nm -g on unique symbols" - } - - if { $verbose < 1 } { - remote_file host delete "tmpdir/unique.o" - } + pass "nm -g" } -} -# Test nm -P + # Test nm -P -# This test does not work correctly on ECOFF targets, because ECOFF -# stores most symbols twice, which messes up the nm output. -setup_xfail "alpha*-*-osf*" "alpha*-*-netware*" -setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*" -setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*" + # This test does not work correctly on ECOFF targets, because ECOFF + # stores most symbols twice, which messes up the nm output. + setup_xfail "alpha*-*-osf*" "alpha*-*-netware*" + setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*" + setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*" -# This test does not work correctly on XCOFF targets, because XCOFF -# does not enter static symbols in the symbol table. -setup_xfail "*-*-aix*" + # This test does not work correctly on XCOFF targets, because XCOFF + # does not enter static symbols in the symbol table. + setup_xfail "*-*-aix*" -set got [binutils_run $NM "$NMFLAGS -P $tempfile"] + set got [binutils_run $NM "$NMFLAGS -P $tempfile"] -set want "common_symbol C \[0\]*4.*data_symbol D \[0-9a-fA-F\]*.*external_symbol U.*static_data_symbol d \[0-9a-fA-F\]*.*static_text_symbol t \[0-9a-fA-F\]*.*text_symbol T \[0-9a-fA-F\]*" + set want "common_symbol C \[0\]*4.*data_symbol D \[0-9a-fA-F\]*.*external_symbol U.*static_data_symbol d \[0-9a-fA-F\]*.*static_text_symbol t \[0-9a-fA-F\]*.*text_symbol T \[0-9a-fA-F\]*" -if [regexp $want $got] then { - pass "nm -P" -} else { - fail "nm -P" + if [regexp $want $got] then { + pass "nm -P" + } else { + fail "nm -P" + } } # Test nm --size-sort @@ -174,32 +149,57 @@ if { [is_elf_format] } if {![binutils_assemble $srcdir/$subdir/$nm_1_src tmpdir/nm-1.o]} then { - return -} - -if [is_remote host] { - set tempfile [remote_download host tmpdir/nm-1.o] + fail "nm --size-sort (assembling)" } else { - set tempfile tmpdir/nm-1.o -} -# This test does not work correctly on ECOFF targets, because ECOFF -# stores most symbols twice, which messes up the nm output. -setup_xfail "alpha*-*-osf*" "alpha*-*-netware*" -setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*" -setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*" + if [is_remote host] { + set tempfile [remote_download host tmpdir/nm-1.o] + } else { + set tempfile tmpdir/nm-1.o + } -set got [binutils_run $NM "$NMFLAGS --size-sort $tempfile"] + # This test does not work correctly on ECOFF targets, because ECOFF + # stores most symbols twice, which messes up the nm output. + setup_xfail "alpha*-*-osf*" "alpha*-*-netware*" + setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*" + setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*" -set want "0*4 T text_symbol3.*0*8 T text_symbol2.*0*c T text_symbol1" + set got [binutils_run $NM "$NMFLAGS --size-sort $tempfile"] -if [regexp $want $got] then { - pass "nm --size-sort" -} else { - fail "nm --size-sort" + set want "0*4 T text_symbol3.*0*8 T text_symbol2.*0*c T text_symbol1" + + if [regexp $want $got] then { + pass "nm --size-sort" + } else { + fail "nm --size-sort" + } } if [is_elf_format] { + # PR binutils/12753 + # Test nm -g on a unique global symbol. + if {![binutils_assemble $srcdir/$subdir/unique.s tmpdir/unique.o]} then { + unsupported "nm -g on unique symbols" + } else { + if [is_remote host] { + set tmpfile [remote_download host tmpdir/unique.o] + } else { + set tmpfile tmpdir/unique.o + } + + set got [binutils_run $NM "$NMFLAGS -g $tmpfile"] + + if [regexp "u foo" $got] then { + pass "nm -g on unique symbols" + } else { + fail "nm -g on unique symbols" + } + + if { $verbose < 1 } { + remote_file host delete "tmpdir/unique.o" + } + } + # PR binutils/20751 # Test nm --with-symbol-versions diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index ef62edfe5d..4695724659 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -47,7 +47,6 @@ proc objcopy_test {testname srcfile} { global copyfile if {![binutils_assemble $srcdir/$subdir/${srcfile} $tempfile]} then { - perror "unresolved $testname" unresolved "objcopy ($testname)" remote_file host delete $tempfile return diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp index 8ee350ff89..e780bb5fa9 100644 --- a/binutils/testsuite/binutils-all/objdump.exp +++ b/binutils/testsuite/binutils-all/objdump.exp @@ -62,9 +62,11 @@ if [regexp $want $got] then { if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then { + fail "objdump (assembling)" return } if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest2.o]} then { + fail "objdump (assembling)" return } if [is_remote host] { diff --git a/binutils/testsuite/binutils-all/size.exp b/binutils/testsuite/binutils-all/size.exp index 81dacab15e..a01b3686d6 100644 --- a/binutils/testsuite/binutils-all/size.exp +++ b/binutils/testsuite/binutils-all/size.exp @@ -31,51 +31,52 @@ send_user "Version [binutil_version $SIZE]" if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then { - return -} - -if [is_remote host] { - set testfile [remote_download host tmpdir/bintest.o] + fail "size (assembling)" } else { - set testfile tmpdir/bintest.o -} -set dec "\[0-9\]+" -set hex "\[0-9a-fA-F\]+" + if [is_remote host] { + set testfile [remote_download host tmpdir/bintest.o] + } else { + set testfile tmpdir/bintest.o + } -# Test size with no arguments + set dec "\[0-9\]+" + set hex "\[0-9a-fA-F\]+" -set got [binutils_run $SIZE "$SIZEFLAGS $testfile"] + # Test size with no arguments -set want "($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($hex)\[ \]+${testfile}" + set got [binutils_run $SIZE "$SIZEFLAGS $testfile"] -if ![regexp $want $got all text data bss dtot hextot] then { - fail "size (no arguments)" -} else { - if {$text < 8 || $data < 4} then { - # The z80-coff port defaults to a "binary" like output - # file format which does not include a data section. - setup_xfail "z80-*-coff" + set want "($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($hex)\[ \]+${testfile}" + + if ![regexp $want $got all text data bss dtot hextot] then { fail "size (no arguments)" } else { - pass "size (no arguments)" + if {$text < 8 || $data < 4} then { + # The z80-coff port defaults to a "binary" like output + # file format which does not include a data section. + setup_xfail "z80-*-coff" + fail "size (no arguments)" + } else { + pass "size (no arguments)" + } } -} -# Test size -A + # Test size -A -set got [binutils_run $SIZE "$SIZEFLAGS -A ${testfile}"] + set got [binutils_run $SIZE "$SIZEFLAGS -A ${testfile}"] -set want "${testfile}.*(text|TEXT|P)\[^\n\r\]*\[ \]($dec)\[ \]+$dec.*(\\.data|DATA|D_1)\[^\n\r\]*\[ \]($dec)\[ \]+$dec" + set want "${testfile}.*(text|TEXT|P)\[^\n\r\]*\[ \]($dec)\[ \]+$dec.*(\\.data|DATA|D_1)\[^\n\r\]*\[ \]($dec)\[ \]+$dec" -if ![regexp $want $got all textname textsize dataname datasize] then { - fail "size -A" -} else { - verbose "text size: $textsize" - verbose "data size: $datasize" - if {$textsize < 8 || $datasize < 4} then { + if ![regexp $want $got all textname textsize dataname datasize] then { fail "size -A" } else { - pass "size -A" + verbose "text size: $textsize" + verbose "data size: $datasize" + if {$textsize < 8 || $datasize < 4} then { + fail "size -A" + } else { + pass "size -A" + } } } diff --git a/binutils/testsuite/binutils-all/vax/objdump.exp b/binutils/testsuite/binutils-all/vax/objdump.exp index 5f9b54712c..b3d09f8f13 100644 --- a/binutils/testsuite/binutils-all/vax/objdump.exp +++ b/binutils/testsuite/binutils-all/vax/objdump.exp @@ -34,30 +34,31 @@ if {[which $OBJDUMP] == 0} then { send_user "Version [binutil_version $OBJDUMP]" if {![binutils_assemble $srcdir/$subdir/entrymask.s tmpdir/entrymask.o]} then { - return -} - -if [is_remote host] { - set objfile [remote_download host tmpdir/entrymask.o] + fail "entrymask test (assembling)" } else { - set objfile tmpdir/entrymask.o -} -# -# We check both function entry points. The second one at offset 2 will -# show up automatically on ELF targets, but needs to be set on a.out -# targets. -# -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -d -M entry:0x0 -M entry:2 $objfile"] -set want1 "\[ \]+0:\[ \]+10 01\[ \]+\\.word 0x0110.\*r8 r4" -set want2 "\[ \]+2:\[ \]+24 02\[ \]+\\.word 0x0224.\*r9 r5 r2" -if [regexp $want1 $got] then { - pass "entrymask test 1" -} else { - fail "entrymask test 1" -} -if [regexp $want2 $got] then { - pass "entrymask test 2" -} else { - fail "entrymask test 2" + if [is_remote host] { + set objfile [remote_download host tmpdir/entrymask.o] + } else { + set objfile tmpdir/entrymask.o + } + + # + # We check both function entry points. The second one at offset 2 will + # show up automatically on ELF targets, but needs to be set on a.out + # targets. + # + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -d -M entry:0x0 -M entry:2 $objfile"] + set want1 "\[ \]+0:\[ \]+10 01\[ \]+\\.word 0x0110.\*r8 r4" + set want2 "\[ \]+2:\[ \]+24 02\[ \]+\\.word 0x0224.\*r9 r5 r2" + if [regexp $want1 $got] then { + pass "entrymask test 1" + } else { + fail "entrymask test 1" + } + if [regexp $want2 $got] then { + pass "entrymask test 2" + } else { + fail "entrymask test 2" + } } -- 2.34.1