From: Alan Modra Date: Sat, 20 Jun 2020 06:23:37 +0000 (+0930) Subject: Remove perror from ld_assemble, ld_compile and ld_nm X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=348fe36b1d64f12c60e08f6313520b3191663063;p=deliverable%2Fbinutils-gdb.git Remove perror from ld_assemble, ld_compile and ld_nm ERROR should really be reserved for errors in the testsuite framework, not just normal errors from the tools under test. Removing use of perror has been suggested before but without action, over concerns that some test failures might be missed. This patch removes uses of perror in ld_assemble, ld_compile and ld_nm, and updates numerous places that ignored the result of these functions by inappropriately returning an "unresolved" test status. Net result over my large set of targets look good, in some cases improving the diagnostics, eg: i386-msdos -ERROR: tmpdir/script: nm failed i386-msdos -ERROR: tmpdir/script: nm failed i386-msdos -ERROR: tmpdir/script: nm failed i386-msdos -ERROR: tmpdir/script: nm failed i386-msdos +FAIL: script i386-msdos +FAIL: MRI script i386-msdos +FAIL: MEMORY i386-msdos +FAIL: MEMORY with symbols * testsuite/lib/ld-lib.exp (default_ld_compile): Don't perror on a compiler error. (default_ld_assemble): Similarly for an assembler error. (default_ld_nm): Similarly for an nm error. (run_ld_link_tests): Report ld_assemble errors as a fail. (check_as_cfi): Remove now unnecessary perror substitution. * testsuite/ld-elf/exclude.exp: Report ld_nm error return as test fails rather then unresolved. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-scripts/alignof.exp: Likewise. * testsuite/ld-scripts/defined.exp: Likewise. * testsuite/ld-scripts/script.exp: Likewise. * testsuite/ld-scripts/sizeof.exp: Likewise. * testsuite/ld-selective/selective.exp: Likewise. * testsuite/ld-scripts/extern.exp: Likewise. Return on ld_link failure. * testsuite/ld-elfweak/elfweak.exp: Report compiler errors as test unresolved. * testsuite/ld-fastcall/fastcall.exp: Report assember errors as test fails. * testsuite/ld-i386/i386.exp (iamcu_tests): Likewise. * testsuite/ld-ia64/line.exp: Likewise. * testsuite/ld-mep/mep.exp: Likewise. * testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise. * testsuite/ld-nios2/nios2.exp: Likewise. * testsuite/ld-scripts/alignof.exp: Likewise. * testsuite/ld-x86-64/line.exp: Likewise. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-scripts/log2.exp: Formatting. * testsuite/ld-tic6x/tic6x.exp: Report ld_link errors as a test fail. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index f9e4a43ce1..b089073dac 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,36 @@ +2020-06-20 Alan Modra + + * testsuite/lib/ld-lib.exp (default_ld_compile): Don't perror on + a compiler error. + (default_ld_assemble): Similarly for an assembler error. + (default_ld_nm): Similarly for an nm error. + (run_ld_link_tests): Report ld_assemble errors as a fail. + (check_as_cfi): Remove now unnecessary perror substitution. + * testsuite/ld-elf/exclude.exp: Report ld_nm error return as test + fails rather then unresolved. + * testsuite/ld-gc/gc.exp: Likewise. + * testsuite/ld-scripts/alignof.exp: Likewise. + * testsuite/ld-scripts/defined.exp: Likewise. + * testsuite/ld-scripts/script.exp: Likewise. + * testsuite/ld-scripts/sizeof.exp: Likewise. + * testsuite/ld-selective/selective.exp: Likewise. + * testsuite/ld-scripts/extern.exp: Likewise. Return on ld_link + failure. + * testsuite/ld-elfweak/elfweak.exp: Report compiler errors as + test unresolved. + * testsuite/ld-fastcall/fastcall.exp: Report assember errors as + test fails. + * testsuite/ld-i386/i386.exp (iamcu_tests): Likewise. + * testsuite/ld-ia64/line.exp: Likewise. + * testsuite/ld-mep/mep.exp: Likewise. + * testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise. + * testsuite/ld-nios2/nios2.exp: Likewise. + * testsuite/ld-scripts/alignof.exp: Likewise. + * testsuite/ld-x86-64/line.exp: Likewise. + * testsuite/ld-x86-64/x86-64.exp: Likewise. + * testsuite/ld-scripts/log2.exp: Formatting. + * testsuite/ld-tic6x/tic6x.exp: Report ld_link errors as a test fail. + 2020-06-20 Alan Modra * testsuite/ld-alpha/alpha.exp: Exclude *ecoff targets. diff --git a/ld/testsuite/ld-elf/exclude.exp b/ld/testsuite/ld-elf/exclude.exp index b9d24c2d4a..af57509acd 100644 --- a/ld/testsuite/ld-elf/exclude.exp +++ b/ld/testsuite/ld-elf/exclude.exp @@ -75,10 +75,9 @@ if { [ld_link $ld tmpdir/exclude.so "--shared tmpdir/exclude1.o -Ltmpdir -lexclu return } -if ![ld_nm $nm "-D" tmpdir/exclude.so] { - unresolved $test2 -} elseif { [info exists nm_output(exclude_common)] - && [info exists nm_output(exclude_sym)] } { +if { [ld_nm $nm "-D" tmpdir/exclude.so] + && [info exists nm_output(exclude_common)] + && [info exists nm_output(exclude_sym)] } { pass $test2 } else { fail $test2 @@ -92,10 +91,9 @@ if { [ld_link $ld tmpdir/exclude.so "--exclude-libs libexclude --shared tmpdir/e fail $test3 } -if ![ld_nm $nm "-D" tmpdir/exclude.so] { - unresolved $test4 -} elseif { ! [info exists nm_output(exclude_common)] - && ! [info exists nm_output(exclude_sym)] } { +if { [ld_nm $nm "-D" tmpdir/exclude.so] + && ! [info exists nm_output(exclude_common)] + && ! [info exists nm_output(exclude_sym)] } { pass $test4 } else { fail $test4 diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp index dbc0c0321b..1d5c438aa3 100644 --- a/ld/testsuite/ld-elfweak/elfweak.exp +++ b/ld/testsuite/ld-elfweak/elfweak.exp @@ -392,10 +392,11 @@ if {![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/foo.c $tmpdir/foo.o] || ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/bar1a.c $tmpdir/bar1a.o] || ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/bar1b.c $tmpdir/bar1b.o] || ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/bar1c.c $tmpdir/bar1c.o] - || ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/main1.c $tmpdir/main1.o] - || ![ld_link $CC $tmpdir/libfoo1a.so "$shared $tmpdir/foo1a.o"] - || ![ld_link $CC $tmpdir/libfoo1b.so "$shared $tmpdir/foo1b.o"] - || ![ld_link $CC $tmpdir/libbar1a.so "$shared $tmpdir/bar1a.o $tmpdir/libfoo1a.so"]} then { + || ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/main1.c $tmpdir/main1.o]} then { + unresolved "ELF weak" +} elseif {![ld_link $CC $tmpdir/libfoo1a.so "$shared $tmpdir/foo1a.o"] + || ![ld_link $CC $tmpdir/libfoo1b.so "$shared $tmpdir/foo1b.o"] + || ![ld_link $CC $tmpdir/libbar1a.so "$shared $tmpdir/bar1a.o $tmpdir/libfoo1a.so"]} then { fail "ELF weak" } else { build_lib "ELF DSO weak func first" libfoo "foo.o bar.o" dso.dsym diff --git a/ld/testsuite/ld-fastcall/fastcall.exp b/ld/testsuite/ld-fastcall/fastcall.exp index dd38889dd7..06139cf202 100644 --- a/ld/testsuite/ld-fastcall/fastcall.exp +++ b/ld/testsuite/ld-fastcall/fastcall.exp @@ -35,13 +35,13 @@ set ldflags "" if ![ld_assemble $as $srcdir/$subdir/export.s tmpdir/export.o] { verbose "Unable to assemble test file!" 1 - unresolved $testname + fail $testname return } if ![ld_assemble $as $srcdir/$subdir/import.s tmpdir/import.o] { verbose "Unable to assemble test file!" 1 - unresolved $testname + fail $testname return } diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp index 97ccf6a7a9..ea3316887e 100644 --- a/ld/testsuite/ld-gc/gc.exp +++ b/ld/testsuite/ld-gc/gc.exp @@ -61,7 +61,7 @@ proc test_gc { testname filename linker ldflags} { return } if ![ld_nm $nm "" $outfile] { - unresolved $testname + fail $testname return } if {![info exists nm_output(used_func)] \ diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index 891ebce772..d71b978164 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -277,22 +277,22 @@ proc iamcu_tests {} { global subdir if ![ld_assemble $as "--32 -march=iamcu $srcdir/$subdir/start.s" tmpdir/startiamcu.o] { - unresolved "Build Intel MCU start.o" + fail "Build Intel MCU start.o" return } if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] { - unresolved "Build ia32 start.o" + fail "Build ia32 start.o" return } if ![ld_assemble $as "--32 -march=iamcu $srcdir/$subdir/foo.s" tmpdir/fooiamcu.o] { - unresolved "Build Intel MCU foo.o" + fail "Build Intel MCU foo.o" return } if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] { - unresolved "Build ia32 foo.o" + fail "Build ia32 foo.o" return } diff --git a/ld/testsuite/ld-ia64/line.exp b/ld/testsuite/ld-ia64/line.exp index b8698787cb..bc7c7abacb 100644 --- a/ld/testsuite/ld-ia64/line.exp +++ b/ld/testsuite/ld-ia64/line.exp @@ -28,7 +28,7 @@ set testline "undefined line" if ![ld_assemble $as "-x $srcdir/$subdir/undefined.s" tmpdir/undefined.o] { verbose "Unable to assemble test file!" 1 - unresolved $testline + fail $testline return } diff --git a/ld/testsuite/ld-mep/mep.exp b/ld/testsuite/ld-mep/mep.exp index fbabd03dc9..29e004418f 100644 --- a/ld/testsuite/ld-mep/mep.exp +++ b/ld/testsuite/ld-mep/mep.exp @@ -30,7 +30,7 @@ if ![istarget mep*-*-*] { set testbsrweak "MeP bsr to undefined weak function" if ![ld_assemble $as "$srcdir/$subdir/mep1.s" tmpdir/mep1.o] { - unresolved $testbsrweak + fail $testbsrweak } else { if ![ld_link $ld tmpdir/mep1 "-T$srcdir/$subdir/mep1.ld tmpdir/mep1.o"] { fail $testbsrweak } else { diff --git a/ld/testsuite/ld-mips-elf/mips-elf-flags.exp b/ld/testsuite/ld-mips-elf/mips-elf-flags.exp index 5160d67d24..1b5e3506a7 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf-flags.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf-flags.exp @@ -103,7 +103,7 @@ proc good_combination {arglist flags args} { } if {$objs == ""} { - unresolved $testname + fail $testname } elseif {![ld_link "$ld $ldemul" $finalobj "-r $objs"]} { fail $testname } else { @@ -201,7 +201,7 @@ proc bad_combination {arglist message} { } if {$objs == ""} { - unresolved $testname + fail $testname } elseif {[ld_link "$ld $ldemul" $finalobj "-r $objs"] || [string first $message $link_output] < 0} { fail $testname diff --git a/ld/testsuite/ld-nios2/nios2.exp b/ld/testsuite/ld-nios2/nios2.exp index 1af0c9212e..c7860a4680 100644 --- a/ld/testsuite/ld-nios2/nios2.exp +++ b/ld/testsuite/ld-nios2/nios2.exp @@ -10,12 +10,12 @@ set test_name "NIOS2 Mixed R1 and R2 objects" set test mixed1 if ![ld_assemble $as "-march=r1 $srcdir/$subdir/${test}a.s" tmpdir/${test}a.o] { - unresolved "Build mixed1a.o" + fail "Build mixed1a.o" return } if ![ld_assemble $as "-march=r2 $srcdir/$subdir/${test}b.s" tmpdir/${test}b.o] { - unresolved "Build mixed1b.o" + fail "Build mixed1b.o" return } diff --git a/ld/testsuite/ld-scripts/alignof.exp b/ld/testsuite/ld-scripts/alignof.exp index 5bcf1bc13a..9bb0421dbb 100644 --- a/ld/testsuite/ld-scripts/alignof.exp +++ b/ld/testsuite/ld-scripts/alignof.exp @@ -28,7 +28,7 @@ if {![is_elf_format] && ![is_pecoff_format]} { set testname "ALIGNOF" if ![ld_assemble $as $srcdir/$subdir/alignof.s tmpdir/alignof.o] { - unresolved $testname + fail $testname return } @@ -38,7 +38,7 @@ if ![ld_link $ld tmpdir/alignof "-T $srcdir/$subdir/alignof.t tmpdir/alignof.o"] } if ![ld_nm $nm "" tmpdir/alignof] { - unresolved $testname + fail $testname return } diff --git a/ld/testsuite/ld-scripts/defined.exp b/ld/testsuite/ld-scripts/defined.exp index 404333fb8c..6889f04c16 100644 --- a/ld/testsuite/ld-scripts/defined.exp +++ b/ld/testsuite/ld-scripts/defined.exp @@ -32,33 +32,25 @@ if [istarget "x86_64-*-mingw*"] then { set LDFLAGS "$LDFLAGS --image-base 0" } -if ![ld_link $ld tmpdir/def "$LDFLAGS -T $srcdir/$subdir/defined.t tmpdir/def.o"] { +if { ![ld_link $ld tmpdir/def "$LDFLAGS -T $srcdir/$subdir/defined.t tmpdir/def.o"] } { + fail $testname +} elseif { ![ld_nm $nm "" tmpdir/def] } { + fail $testname +} elseif { ![info exists nm_output(value1)] + || ![info exists nm_output(value2)]} { + send_log "bad output from nm\n" + verbose "bad output from nm" + fail $testname +} elseif {$nm_output(value1) != 1} { + send_log "value1 == $nm_output(value1)\n" + verbose "value1 == $nm_output(value1)" + fail $testname +} elseif {$nm_output(value2) != 2} { + send_log "value2 == $nm_output(value2)\n" + verbose "value2 == $nm_output(value2)" fail $testname } else { - if ![ld_nm $nm "" tmpdir/def] { - unresolved $testname - } else { - if {![info exists nm_output(value1)] \ - || ![info exists nm_output(value2)]} { - send_log "bad output from nm\n" - verbose "bad output from nm" - fail $testname - } else { - if {$nm_output(value1) != 1} { - send_log "value1 == $nm_output(value1)\n" - verbose "value1 == $nm_output(value1)" - fail $testname - } else { - if {$nm_output(value2) != 2} { - send_log "value2 == $nm_output(value2)\n" - verbose "value2 == $nm_output(value2)" - fail $testname - } else { - pass $testname - } - } - } - } + pass $testname } set saved_ASFLAGS "$ASFLAGS" diff --git a/ld/testsuite/ld-scripts/extern.exp b/ld/testsuite/ld-scripts/extern.exp index 1955b5c50d..d6faef811f 100644 --- a/ld/testsuite/ld-scripts/extern.exp +++ b/ld/testsuite/ld-scripts/extern.exp @@ -28,10 +28,11 @@ if ![ld_assemble $as $srcdir/$subdir/extern.s tmpdir/extern.o] { if ![ld_link $ld tmpdir/extern "-T $srcdir/$subdir/extern.t tmpdir/extern.o"] { fail $testname + return } if ![ld_nm $nm "" tmpdir/extern] { - unresolved $testname + fail $testname return } diff --git a/ld/testsuite/ld-scripts/log2.exp b/ld/testsuite/ld-scripts/log2.exp index 5045e4567d..d67504b4b0 100644 --- a/ld/testsuite/ld-scripts/log2.exp +++ b/ld/testsuite/ld-scripts/log2.exp @@ -22,12 +22,12 @@ set testname "binary logarithm" if {![ld_assemble $as $srcdir/$subdir/log2.s tmpdir/log2.o]} { - unresolved $testname - return + unresolved $testname + return } if {![ld_link $ld tmpdir/log2 "-T $srcdir/$subdir/log2.t tmpdir/log2.o"]} { - fail $testname + fail $testname } else { - pass $testname + pass $testname } diff --git a/ld/testsuite/ld-scripts/script.exp b/ld/testsuite/ld-scripts/script.exp index eaa4f53b03..42bd452d6a 100644 --- a/ld/testsuite/ld-scripts/script.exp +++ b/ld/testsuite/ld-scripts/script.exp @@ -32,7 +32,7 @@ proc check_script { } { global nm_output if ![ld_nm $nm "" tmpdir/script] { - unresolved $testname + fail $testname return } diff --git a/ld/testsuite/ld-scripts/sizeof.exp b/ld/testsuite/ld-scripts/sizeof.exp index 84fd464b13..4381573f89 100644 --- a/ld/testsuite/ld-scripts/sizeof.exp +++ b/ld/testsuite/ld-scripts/sizeof.exp @@ -33,7 +33,7 @@ if ![ld_link $ld tmpdir/sizeof "-T $srcdir/$subdir/sizeof.t tmpdir/sizeof.o"] { } if ![ld_nm $nm "" tmpdir/sizeof] { - unresolved $testname + fail $testname return } diff --git a/ld/testsuite/ld-selective/selective.exp b/ld/testsuite/ld-selective/selective.exp index bb16140ef2..ce66dc88e2 100644 --- a/ld/testsuite/ld-selective/selective.exp +++ b/ld/testsuite/ld-selective/selective.exp @@ -151,7 +151,7 @@ foreach testitem $seltests { } if ![ld_nm $nm --demangle $ldfile] { - unresolved $testname + fail $testname continue } diff --git a/ld/testsuite/ld-tic6x/tic6x.exp b/ld/testsuite/ld-tic6x/tic6x.exp index a4d9ee8287..c4b1d8ac03 100644 --- a/ld/testsuite/ld-tic6x/tic6x.exp +++ b/ld/testsuite/ld-tic6x/tic6x.exp @@ -154,7 +154,7 @@ if { ![ld_assemble_flags $as "-mpic -mpid=near" $srcdir/$subdir/shlib-1.s tmpdir || ![ld_link $ld tmpdir/shlibb.o "-r -EB tmpdir/shlib-1b.o tmpdir/shlib-2b.o"] || ![ld_link $ld tmpdir/dynapp-1 "tmpdir/libtest.so tmpdir/shlib-app-1.o"] || ![ld_link $ld tmpdir/dynapp-1b "-EB tmpdir/libtestb.so tmpdir/shlib-app-1b.o"] } { - unresolved "TIC6X OSABI tests" + fail "TIC6X OSABI tests" return } diff --git a/ld/testsuite/ld-x86-64/line.exp b/ld/testsuite/ld-x86-64/line.exp index 21f04b87dc..7eb6cf732a 100644 --- a/ld/testsuite/ld-x86-64/line.exp +++ b/ld/testsuite/ld-x86-64/line.exp @@ -35,7 +35,7 @@ set testline "undefined line" if ![ld_assemble $as "--64 $srcdir/$subdir/undefined.s" tmpdir/undefined.o] { verbose "Unable to assemble test file!" 1 - unresolved $testline + fail $testline return } diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 69548f27b5..6bd1f12331 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -475,32 +475,32 @@ if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} { } if ![ld_assemble $as "--x32 $srcdir/$subdir/start.s" tmpdir/startx32.o] { - unresolved "Build ILP32 start.o" + fail "Build ILP32 start.o" return } if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] { - unresolved "Build ia32 start.o" + fail "Build ia32 start.o" return } if ![ld_assemble $as "--64 $srcdir/$subdir/start.s" tmpdir/start64.o] { - unresolved "Build LP64 start.o" + fail "Build LP64 start.o" return } if ![ld_assemble $as "--x32 $srcdir/$subdir/foo.s" tmpdir/foox32.o] { - unresolved "Build ILP32 foo.o" + fail "Build ILP32 foo.o" return } if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] { - unresolved "Build ia32 foo.o" + fail "Build ia32 foo.o" return } if ![ld_assemble $as "--64 $srcdir/$subdir/foo.s" tmpdir/foo64.o] { - unresolved "Build LP64 foo.o" + fail "Build LP64 foo.o" return } diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 0a256c2395..8d851a94b7 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -289,7 +289,6 @@ proc default_ld_compile { cc source object } { return 1 } else { verbose -log "$exec_output" - perror "$source: compilation failed" return 0 } } @@ -310,7 +309,6 @@ proc default_ld_assemble { as in_flags source object } { if [string match "" $exec_output] then { return 1 } else { - perror "$source: assembly failed" return 0 } } @@ -361,7 +359,6 @@ proc default_ld_nm { nm nmflags object } { return 1 } else { verbose -log "$exec_output" - perror "$object: nm failed" return 0 } } @@ -520,12 +517,17 @@ proc run_ld_link_tests { ldtests args } { set as_file "$srcdir/$subdir/$src_file" } if ![ld_assemble $as "$as_options $as_file" $objfile] { - set is_unresolved 1 + set failed 1 break } } # Catch assembler errors. + if { $failed } { + fail $testname + continue + } + # Catch compiler errors. if { $is_unresolved } { unresolved $testname continue @@ -1367,11 +1369,7 @@ proc check_as_cfi { } { close $as_fh remote_download host $as_file verbose -log "Checking CFI support:" - rename "perror" "check_as_cfi_perror" - proc perror { args } { } set success [ld_assemble $as $as_file "/dev/null"] - rename "perror" "" - rename "check_as_cfi_perror" "perror" #remote_file host delete $as_file set check_as_cfi_result $success return $success