[PATCH v3] binutils: testsuite: convert binary symbol tests to run_dump_test
Alan Modra
amodra@gmail.com
Tue Nov 11 04:20:16 GMT 2025
On Mon, Nov 10, 2025 at 02:58:53PM +0100, Jan Beulich wrote:
> On 08.11.2025 11:59, Alon Bar-Lev wrote:
> > - pass $test
> > + # as always runs, not critical as we do not check the content
> > + run_dump_test "binary-symbol-${tag}" [list [list objcopy "-B $arch -O $target" ] ]
>
> Sadly it only now occurred to me what the comment means (last time round iirc I
> simply didn't know how to parse the first part, as I took the initial "as" for
> a normal word, not a reference to gas). Problem being - "always runs" isn't true.
> There are very few targets (amdgcn being one of them iirc) where no gas is being
> built, and hence an attempt to use it will cause testcases to fail. IOW you're
> effectively introducing two testcase regressions here for every one such target.
> Whether we could consider this acceptable (given that for such targets various
> other tests also fail) I don't know. Nick, Alan - opinions?
I think we should drop the idea of using run_dump_test here. I'll
give the following a try.
===
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.
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index e6fcf5f7f12..3c47ab0bbc4 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -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 s [list "start" "end" "size"] {
+ set exp "^\[0-9a-fA-F\]+ +\[TtDdA\] +${sym_prefix}_${s}$"
+ 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
--
Alan Modra
More information about the Binutils
mailing list