Remove perror from ld_assemble, ld_compile and ld_nm
authorAlan Modra <amodra@gmail.com>
Sat, 20 Jun 2020 06:23:37 +0000 (15:53 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 20 Jun 2020 06:23:37 +0000 (15:53 +0930)
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.

21 files changed:
ld/ChangeLog
ld/testsuite/ld-elf/exclude.exp
ld/testsuite/ld-elfweak/elfweak.exp
ld/testsuite/ld-fastcall/fastcall.exp
ld/testsuite/ld-gc/gc.exp
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-ia64/line.exp
ld/testsuite/ld-mep/mep.exp
ld/testsuite/ld-mips-elf/mips-elf-flags.exp
ld/testsuite/ld-nios2/nios2.exp
ld/testsuite/ld-scripts/alignof.exp
ld/testsuite/ld-scripts/defined.exp
ld/testsuite/ld-scripts/extern.exp
ld/testsuite/ld-scripts/log2.exp
ld/testsuite/ld-scripts/script.exp
ld/testsuite/ld-scripts/sizeof.exp
ld/testsuite/ld-selective/selective.exp
ld/testsuite/ld-tic6x/tic6x.exp
ld/testsuite/ld-x86-64/line.exp
ld/testsuite/ld-x86-64/x86-64.exp
ld/testsuite/lib/ld-lib.exp

index f9e4a43ce1e4e386d02a16f3dbb19e2497d52c7f..b089073dacd01bae5493dd3d66b9af514ac57a60 100644 (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.
index b9d24c2d4aad8e1fed59a95f3a983817088fd47d..af57509acd355d67cc764578780cea3a8ec5bdb1 100644 (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
index dbc0c0321b8af45bad487854d709d02fe3e11550..1d5c438aa34729a3c2ba8789c1bf81313b69a3ab 100644 (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
index dd38889dd7030090068281a1d36915d27829d9b2..06139cf20240e977d04f9d87ef8cfc3e6b4b8674 100644 (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
 }
 
index 97ccf6a7a9be658793c7af9e5d99564992e3e05a..ea3316887e3df0cb6b3d38db9eeab6b30b22292e 100644 (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)] \
index 891ebce772593f2daf6389ccf268a186cadcd852..d71b9781648329f7d74028eeec84224a98f92bd0 100644 (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
     }
 
index b8698787cb46d30dcf56ca12f524511ca3b363fd..bc7c7abacbc3e8b63d4c56182130989439992eab 100644 (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
 }
 
index fbabd03dc9fe86ca33446db188da33d5d74b341c..29e004418f5a9cf051a527edcf5464a3558a9607 100644 (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 {
index 5160d67d2437b35f67721182965b71aaf1937f13..1b5e3506a7c5d4beb792c7c982917a894a8072f8 100644 (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
index 1af0c9212e23a29a133945afa8f53ba8bec6dd44..c7860a4680015d785af63c67e7a3376f3b5f9611 100644 (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
 }
 
index 5bcf1bc13a3bdfd5684c6b361641635eb9acb3f4..9bb0421dbbd60039684d0b896cba4797a7cc8498 100644 (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
 }
 
index 404333fb8c2530f9eac25ce2f2c11e4207bd07cc..6889f04c167a30d53b7a46ca362d29699c5e4cb9 100644 (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"
index 1955b5c50d795214b5cd9eaeb716e0b9a33e147a..d6faef811fcae886e15b33229aaea149593647e3 100644 (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
 }
 
index 5045e4567dcd2316653493b3e08c054643569fc0..d67504b4b068f9791bd6c30cf4d71c8244827b60 100644 (file)
 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
 }
index eaa4f53b034dfbf5c77f9a3bd4b737e518a03e11..42bd452d6a1d1a64f723c4ddc866d3b43ff24aec 100644 (file)
@@ -32,7 +32,7 @@ proc check_script { } {
     global nm_output
 
     if ![ld_nm $nm "" tmpdir/script] {
-       unresolved $testname
+       fail $testname
        return
     } 
 
index 84fd464b13b582d2191dbacca13453e113c7dedb..4381573f8994112543b474182517840bd06a240b 100644 (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
 }
 
index bb16140ef2bfea8e8b1ad06739be2d4c759dd712..ce66dc88e2f6f994257ce89b5ac46b5b7b46731c 100644 (file)
@@ -151,7 +151,7 @@ foreach testitem $seltests {
     }
 
     if ![ld_nm $nm --demangle $ldfile] {
-       unresolved $testname
+       fail $testname
        continue
     }
 
index a4d9ee8287657af8c37558bbd96b357a09a51b95..c4b1d8ac037cc2a2bf9da8453cdb360bd46c89f1 100644 (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
 }
 
index 21f04b87dcdab80e92bd9791ccefd8d90c0fa81e..7eb6cf732aba53fe24bf62311d65e2f31fc2de19 100644 (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
 }
 
index 69548f27b5164c186b6927c4dfb12fdd36f24971..6bd1f123317ee1299e848e306988ba65b8368df8 100644 (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
 }
 
index 0a256c2395faa1df515e253c8a3b90f48ce2f702..8d851a94b710e310e759fdd2398c26ddb0d06d2d 100644 (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
This page took 0.040883 seconds and 4 git commands to generate.