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.
This commit is contained in:
Alan Modra 2020-06-20 15:53:37 +09:30
parent b0ee49d21b
commit 348fe36b1d
21 changed files with 99 additions and 76 deletions

View File

@ -1,3 +1,36 @@
2020-06-20 Alan Modra <amodra@gmail.com>
* 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 <amodra@gmail.com>
* testsuite/ld-alpha/alpha.exp: Exclude *ecoff targets.

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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)] \

View File

@ -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
}

View File

@ -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
}

View File

@ -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 {

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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"

View File

@ -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
}

View File

@ -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
}

View File

@ -32,7 +32,7 @@ proc check_script { } {
global nm_output
if ![ld_nm $nm "" tmpdir/script] {
unresolved $testname
fail $testname
return
}

View File

@ -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
}

View File

@ -151,7 +151,7 @@ foreach testitem $seltests {
}
if ![ld_nm $nm --demangle $ldfile] {
unresolved $testname
fail $testname
continue
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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