From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125327 invoked by alias); 18 Dec 2017 22:12:45 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 125287 invoked by uid 89); 18 Dec 2017 22:12:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=simples, som X-HELO: mail-pg0-f41.google.com Received: from mail-pg0-f41.google.com (HELO mail-pg0-f41.google.com) (74.125.83.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Dec 2017 22:12:41 +0000 Received: by mail-pg0-f41.google.com with SMTP id g7so9726555pgs.0 for ; Mon, 18 Dec 2017 14:12:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=e0Ip80KH+b6RwuKZtNR5Iw6VaCMeOgkwkIjqgCSZF54=; b=M7sckf9cL3557m0Gzn0JGZsoMC6CG9asRPWoWHTozYOMxT8Z8UCf7e1C0/8bXDfZcW e4TSEdfokYM6ZwSlRH4Wf8FZo4mhEz8iDqPyXyN6Tmm1bH0ZIKtTjxeRm2q5PrKtAPJB YsJQld3Ek+DsU5ODwzjMvPrvjkVd/W4YibTJSFtuirVirpIW3wXbEulMzLTP0f/YRVcn mpOv2/4h4g0G8Awn2IXwcOTHMUHEiUI/PhIGlUrRjaHkHt4TBJhYU3rEuIuz6SfJdNt1 ADpN4s/h2g+0UrsXrSiBJS9DVvRJOqKQYvcOoBkpiypQaL5k7PQHKUqBSILA550tTt+C crwg== X-Gm-Message-State: AKGB3mJYxTURUls+ECCsHox8+YOBLrxPRUzBQCA03JJht5PEr+hSgTTp UeIZgqd3afle1Umpf9ccaF7cbQ== X-Google-Smtp-Source: ACJfBosdKGBIvw1h6M3hLlQp8p68G/6UoCOcq+kovomutO7YRdCEGFObXCmZXWEm2BaWQOrJOgGGVw== X-Received: by 10.99.47.134 with SMTP id v128mr1020175pgv.232.1513635158983; Mon, 18 Dec 2017 14:12:38 -0800 (PST) Received: from bubble.grove.modra.org (CPE-58-175-244-173.hdcz1.win.bigpond.net.au. [58.175.244.173]) by smtp.gmail.com with ESMTPSA id p87sm27700027pfi.95.2017.12.18.14.12.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 14:12:37 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id A2678C18D0; Tue, 19 Dec 2017 08:42:33 +1030 (ACDT) Date: Mon, 18 Dec 2017 22:12:00 -0000 From: Alan Modra To: binutils@sourceware.org Subject: Test binutils_assemble return value Message-ID: <20171218221233.GC3289@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg00157.txt.bz2 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. diff --git a/binutils/testsuite/binutils-all/ar.exp b/binutils/testsuite/binutils-all/ar.exp index 7b93cc6..ca422d1 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 a4e6ef0..9748d4a 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 0e74ebb..3485d3a 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 13305fc..e063a62 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 b834a22..3f69f34 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 f1f53dd..1087252 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 e60e061..8cdd3d1 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 ef62edf..4695724 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 8ee350f..e780bb5 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 81dacab..a01b368 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 5f9b547..b3d09f8 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" + } } -- Alan Modra Australia Development Lab, IBM