]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
objcopy binary symbol test
authorAlan Modra <amodra@gmail.com>
Tue, 11 Nov 2025 04:03:57 +0000 (14:33 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 11 Nov 2025 05:19:55 +0000 (15:49 +1030)
A small tidy that allows other symbols or warnings to appear in nm
output, and works around the case problem of windows drive letters
by simply omitting the $srcdir match.

* testsuite/binutils-all/objcopy.exp (binary_symbol): Check
objcopy and nm return status.  Don't repeat prune_warnings
already done in binutils_run.  Match each symbol separately,
reporting which match failed on a failure.  Don't match
$srcdir in implicit test.

binutils/testsuite/binutils-all/objcopy.exp

index e6fcf5f7f12d03eeaa3aa8f15b9c4a5ea314e01a..43814ac5a70f5d875185f093e85cdb5cdce9f4b8 100644 (file)
@@ -1605,10 +1605,11 @@ objcopy_tek2bin
 
 # Test objcopy -I binary and --binary-symbol-prefix
 
-proc binary_symbol {name file args symbol} {
+proc binary_symbol {name file args sym_prefix} {
     global OBJCOPY
     global NM
     global NMFLAGS
+    global binutils_run_status
 
     set test "binary symbol ($name)"
 
@@ -1619,25 +1620,28 @@ proc binary_symbol {name file args symbol} {
 
     set out tmpdir/binary_${name}.o
     set got [binutils_run $OBJCOPY "-I binary -B $arch -O $target $args $file $out"]
-
-    set expected [list "${symbol}_end" "${symbol}_size" "${symbol}_start"]
-
-    set exec_output [binutils_run $NM "-a $NMFLAGS $out"]
-    set exec_output [prune_warnings $exec_output]
-    set actual {}
-    while {[regexp {^[0-9a-fA-F]+?[ ]+[TtDdA] ([0-9a-zA-Z_]+)[\r\n]+(.*)$} ${exec_output} all s rest]} {
-       set actual [concat $actual $s]
-       set exec_output $rest
+    if { $binutils_run_status != 0 || ![string equal "" $got] } {
+       fail $test
+       return
     }
 
-    if {[lsort $expected] ne [lsort $actual]} {
-       send_log "expected: $expected, actual: $actual\n"
+    set got [binutils_run $NM "-a $NMFLAGS $out"]
+    if { $binutils_run_status != 0 } {
        fail $test
        return
     }
 
+    foreach sym [list "start" "end" "size"] {
+       set exp "^\[0-9a-fA-F\]+ +\[TtDdA\] +${sym_prefix}_${sym}$"
+       if ![regexp -line $exp $got] {
+           send_log "failed to match: $exp\n"
+           fail $test
+           return
+       }
+    }
+
     pass $test
 }
 
-binary_symbol implicit $srcdir/$subdir/version.s "" _binary_[regsub -all {[^0-9a-zA-Z]} $srcdir/$subdir/version.s _]
+binary_symbol implicit $srcdir/$subdir/version.s "" _binary_.*[regsub -all {[^0-9a-zA-Z]} $subdir/version.s _]
 binary_symbol explicit $srcdir/$subdir/version.s "--binary-symbol-prefix symbol1" symbol1