[PATCH] binutils: testsuite: convert binary symbol tests to run_dump_test
Alon Bar-Lev
alon.barlev@gmail.com
Fri Nov 7 16:51:17 GMT 2025
On Fri, 7 Nov 2025 at 12:16, Jan Beulich <jbeulich@suse.com> wrote:
> On 07.11.2025 10:31, Alon Bar-Lev wrote:
> > Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
> > ---
> > .../binutils-all/binary-symbol-explicit.d | 11 ++++++
> > .../binutils-all/binary-symbol-implicit.d | 11 ++++++
> > binutils/testsuite/binutils-all/objcopy.exp | 34 +++----------------
> > 3 files changed, 27 insertions(+), 29 deletions(-)
> > create mode 100644
> binutils/testsuite/binutils-all/binary-symbol-explicit.d
> > create mode 100644
> binutils/testsuite/binutils-all/binary-symbol-implicit.d
>
> First, please send new patches as individual new mails (or threads if it's
> a series), not as replies to earlier mails.
>
OK, I apologize.
>
> > --- /dev/null
> > +++ b/binutils/testsuite/binutils-all/binary-symbol-implicit.d
> > @@ -0,0 +1,11 @@
> > +#name: binary symbols
> > +#PROG: objcopy
> > +#objcopy: -I binary
> > +#source: version.s
> > +#nm: -a
> > +
> > +#...
> > +[0-9a-fA-F]+?[ ]+[TtDdA] .*_version_o_end
> > +[0-9a-fA-F]+?[ ]+[TtDdA] .*_version_o_size
> > +[0-9a-fA-F]+?[ ]+[TtDdA] .*_version_o_start
>
> This is stripping a little too much for my taste; I'd expect at least one
> directory component to also be part of the expectations. Or else please
> have
> a non-empty description justifying your choice.
>
>
I converted this to implicit location based on the behavior of the build
system and current working directory.
I cannot know if this will always be the case, but it works.
> Is A actually necessary to have in the expectations of symbol type?
>
>
As I am not an expert in this, I left it per other examples I've seen in
code, I removed the A, hopefully it won't break other platforms.
The size must be A.
> > --- a/binutils/testsuite/binutils-all/objcopy.exp
> > +++ b/binutils/testsuite/binutils-all/objcopy.exp
> > @@ -1605,39 +1605,15 @@ objcopy_tek2bin
> >
> > # Test objcopy -I binary and --binary-symbol-prefix
> >
> > -proc binary_symbol {name file args symbol} {
> > +proc binary_symbol {} {
> > global OBJCOPY
> > - global NM
> > - global NMFLAGS
> >
> > - set test "binary symbol ($name)"
> > -
> > - # detect a valid target, take the first supported
> > set inf [split [binutils_run $OBJCOPY "--info"] \n]
> > set target [lindex $inf 1]
> > set arch [string trim [lindex $inf 3]]
> > -
> > - 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 {[lsort $expected] ne [lsort $actual]} {
> > - send_log "expected: $expected, actual: $actual\n"
> > - fail $test
> > - return
> > - }
> > -
> > - pass $test
> > + # as always runs, not critical as we do not check the content
> > + run_dump_test "binary-symbol-explicit" [list [list objcopy "-B
> $arch -O $target" ] ]
> > + run_dump_test "binary-symbol-implicit" [list [list objcopy "-B
> $arch -O $target" ] ]
> > }
> >
> > -binary_symbol implicit $srcdir/$subdir/version.s "" _binary_[regsub
> -all {[^0-9a-zA-Z]} $srcdir/$subdir/version.s _]
> > -binary_symbol explicit $srcdir/$subdir/version.s
> "--binary-symbol-prefix symbol1" symbol1
> > +binary_symbol
>
> Personally I'd prefer if we kept two parameterized invocations of
> binary_symbol
> here. It would be just one parameter now, the testcase name "tag".
>
>
Done.
Thank you for your review, I am not familiar with the binutils test
framework, and my tcl skills need to be raised from the underworld.
Regards,
Alon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20251107/6251461d/attachment-0001.htm>
More information about the Binutils
mailing list