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.
This commit is contained in:
Alan Modra
2017-12-15 17:08:56 +10:30
parent c54207d326
commit f795c49463
12 changed files with 357 additions and 324 deletions

View File

@ -1,3 +1,20 @@
2017-12-19 Alan Modra <amodra@gmail.com>
* 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 <nickc@redhat.com>
PR 22532

View File

@ -449,6 +449,7 @@ proc unique_symbol { } {
if ![binutils_assemble $srcdir/$subdir/unique.s tmpdir/unique.o] {
unresolved $testname
return
}
if [is_remote host] {

View File

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

View File

@ -34,8 +34,8 @@ send_user "Version [binutil_version $OBJDUMP]"
###########################
if {![binutils_assemble $srcdir/$subdir/thumb2-cond.s tmpdir/thumb2-cond.o]} then {
return
}
fail "thumb2-cond (assembling)"
} else {
if [is_remote host] {
set objfile [remote_download host tmpdir/thumb2-cond.o]
@ -64,14 +64,15 @@ if [regexp $want $got] then {
} else {
fail "thumb2-cond test2"
}
}
###########################
# Set up the test of multiple disassemblies
###########################
if {![binutils_assemble $srcdir/$subdir/simple.s tmpdir/simple.o]} then {
return
}
fail "multiple input files"
} else {
if [is_remote host] {
set objfile [remote_download host tmpdir/simple.o]
@ -90,10 +91,11 @@ if [regexp $want $got] then {
} else {
fail "multiple input files"
}
}
if {![binutils_assemble $srcdir/$subdir/rvct_symbol.s tmpdir/rvct_symbol.o]} then {
return
}
fail "skip rvct symbol"
} else {
if [is_remote host] {
set objfile [remote_download host tmpdir/rvct_symbol.o]
@ -112,3 +114,4 @@ if [regexp $want $got] then {
} else {
fail "skip rvct symbol"
}
}

View File

@ -30,8 +30,8 @@ send_user "Version [binutil_version $OBJDUMP]"
###################################
if {![binutils_assemble $srcdir/$subdir/unknown-mode.s tmpdir/unknown-mode.o]} then {
return
}
fail "unknown mode test (assembling)"
} else {
if [is_remote host] {
set objfile [remote_download host tmpdir/unknown-mode.o]
@ -50,3 +50,4 @@ if [regexp $want $got] then {
} else {
fail "unknown mode test"
}
}

View File

@ -42,8 +42,8 @@ if {[which $OBJDUMP] == 0} then {
send_user "Version [binutil_version $OBJDUMP]"
if {![binutils_assemble $srcdir/$subdir/addendbug.s tmpdir/addendbug.o]} then {
return
}
fail "addendbug test (assembling)"
} else {
if [is_remote host] {
set objfile [remote_download host tmpdir/addendbug.o]
@ -51,7 +51,8 @@ if [is_remote host] {
set objfile tmpdir/addendbug.o
}
# Make sure the SOM BFD code sign extends constants in R_DATA_OVERRIDE fixups.
# Make sure the SOM BFD code sign extends constants in
# R_DATA_OVERRIDE fixups.
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $objfile"]
@ -61,20 +62,20 @@ if [istarget hppa*-*-*elf*] then {
set want "00000000 R_DP_RELATIVE\[ \]+is_idchar-0x00000020.*"
}
if [regexp $want $got] then {
pass "addendbug test"
} else {
fail "addendbug test"
}
}
###########################
# Set up the test of freg.s
###########################
if {![binutils_assemble $srcdir/$subdir/freg.s tmpdir/freg.o]} then {
return
}
fail "freg test (assembling)"
} else {
if [is_remote host] {
set objfile [remote_download host tmpdir/freg.o]
@ -93,3 +94,4 @@ if [regexp $want $got] then {
} else {
fail "freg test"
}
}

View File

@ -30,8 +30,8 @@ send_user "Version [binutil_version $OBJDUMP]"
###########################
if {![binutils_assemble $srcdir/$subdir/movem.s tmpdir/movem.o]} then {
return
}
fail "movem test"
} else {
if [is_remote host] {
set objfile [remote_download host tmpdir/movem.o]
@ -50,14 +50,15 @@ if [regexp $want $got] then {
} else {
fail "movem test"
}
}
###########################
# Set up the test of fnop.s
###########################
if {![binutils_assemble $srcdir/$subdir/fnop.s tmpdir/fnop.o]} then {
return
}
fail "fnop test"
} else {
if [is_remote host] {
set objfile [remote_download host tmpdir/fnop.o]
@ -76,3 +77,4 @@ if [regexp $want $got] then {
} else {
fail "fnop test"
}
}

View File

@ -31,8 +31,8 @@ send_user "Version [binutil_version $NM]"
if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
return
}
fail "nm (assembling)"
} else {
if [is_remote host] {
set tempfile [remote_download host tmpdir/bintest.o]
@ -98,32 +98,6 @@ if {![info exists vars(text_symbol)] \
pass "nm -g"
}
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"
}
}
}
# Test nm -P
# This test does not work correctly on ECOFF targets, because ECOFF
@ -145,6 +119,7 @@ if [regexp $want $got] then {
} else {
fail "nm -P"
}
}
# Test nm --size-sort
@ -174,8 +149,8 @@ if { [is_elf_format]
}
if {![binutils_assemble $srcdir/$subdir/$nm_1_src tmpdir/nm-1.o]} then {
return
}
fail "nm --size-sort (assembling)"
} else {
if [is_remote host] {
set tempfile [remote_download host tmpdir/nm-1.o]
@ -198,8 +173,33 @@ if [regexp $want $got] then {
} 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

View File

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

View File

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

View File

@ -31,8 +31,8 @@ send_user "Version [binutil_version $SIZE]"
if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
return
}
fail "size (assembling)"
} else {
if [is_remote host] {
set testfile [remote_download host tmpdir/bintest.o]
@ -79,3 +79,4 @@ if ![regexp $want $got all textname textsize dataname datasize] then {
pass "size -A"
}
}
}

View File

@ -34,8 +34,8 @@ if {[which $OBJDUMP] == 0} then {
send_user "Version [binutil_version $OBJDUMP]"
if {![binutils_assemble $srcdir/$subdir/entrymask.s tmpdir/entrymask.o]} then {
return
}
fail "entrymask test (assembling)"
} else {
if [is_remote host] {
set objfile [remote_download host tmpdir/entrymask.o]
@ -61,3 +61,4 @@ if [regexp $want2 $got] then {
} else {
fail "entrymask test 2"
}
}