* [RFA:] More run_dump_test functionality.
@ 2001-09-10 21:06 Hans-Peter Nilsson
2001-09-14 6:29 ` Nick Clifton
0 siblings, 1 reply; 2+ messages in thread
From: Hans-Peter Nilsson @ 2001-09-10 21:06 UTC (permalink / raw)
To: binutils
I had a need to modify linked output before inpecting it in the
MMIX ld testsuite. I though about introducing some sequence
construct, but in the end I found the need was limited to
running objcopy on the linked output, before inspecting it with
readelf or objdump (or objcopy, but I had no use for that). So
in interest of keeping it simple, I added just another function.
I use this to integrity-check the mmo output and the mmo
reader for the MMIX port. (Just a few more docs to write...)
One might think that a test using objcopy should belong with the binutils
subdir, but then again, the input is the linked program.
Ok to commit?
ld/testsuite:
* lib/ld-lib.exp (run_dump_test): Handle new option
"objcopy_linked_file". Return after failing, if errors were
expected but none were found.
(slurp_options): Support underscores in option names.
Index: ld-lib.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/lib/ld-lib.exp,v
retrieving revision 1.10
diff -p -c -r1.10 ld-lib.exp
*** ld-lib.exp 2001/07/24 11:07:16 1.10
--- ld-lib.exp 2001/09/11 03:39:54
*************** proc simple_diff { file_1 file_2 } {
*** 434,439 ****
--- 434,445 ----
# Link assembled files using FLAGS, in the order of the "source"
# directives, when using multiple files.
#
+ # objcopy_linked_file: FLAGS
+ # Run objcopy on the linked file with the specified flags.
+ # This lets you transform the linked file using objcopy, before the
+ # result is analyzed by an analyzer program specified below (which
+ # may in turn *also* be objcopy).
+ #
# PROG: PROGRAM-NAME
# The name of the program to run to analyze the .o file produced
# by the assembler or the linker output. This can be omitted;
*************** proc run_dump_test { name } {
*** 503,508 ****
--- 509,515 ----
}
set dumpfile tmpdir/dump.out
set run_ld 0
+ set run_objcopy 0
set opts(as) {}
set opts(ld) {}
set opts(xfail) {}
*************** proc run_dump_test { name } {
*** 516,521 ****
--- 523,529 ----
set opts(PROG) {}
set opts(source) {}
set opts(error) {}
+ set opts(objcopy_linked_file) {}
set asflags{${file}.s} {}
foreach i $opt_array {
*************** proc run_dump_test { name } {
*** 552,557 ****
--- 560,569 ----
if { $opt_name == "ld" } {
set run_ld 1
}
+ # Likewise objcopy_linked_file.
+ if { $opt_name == "objcopy_linked_file" } {
+ set run_objcopy 1
+ }
}
}
set opts($opt_name) [concat $opts($opt_name) $opt_val]
*************** proc run_dump_test { name } {
*** 683,689 ****
verbose -log "failed with: <$comp_output>, expected: <$opts(error)>"
send_log "$comp_output\n"
verbose "$comp_output" 3
! if { $opts(error) != "" } {
if [regexp $opts(error) $comp_output] {
pass $testname
return
--- 695,701 ----
verbose -log "failed with: <$comp_output>, expected: <$opts(error)>"
send_log "$comp_output\n"
verbose "$comp_output" 3
! if { $opts(error) != "" && $run_objcopy == 0 } {
if [regexp $opts(error) $comp_output] {
pass $testname
return
*************** proc run_dump_test { name } {
*** 692,697 ****
--- 704,736 ----
fail $testname
return
}
+
+ if { $run_objcopy } {
+ set infile $objfile
+ set objfile "tmpdir/dump1"
+
+ # Note that we don't use OBJCOPYFLAGS here; any flags must be
+ # explicitly specified.
+ set cmd "$OBJCOPY $opts(objcopy_linked_file) $infile $objfile"
+
+ send_log "$cmd\n"
+ set cmdret [catch "exec $cmd" comp_output]
+ set comp_output [prune_warnings $comp_output]
+
+ if { $cmdret != 0 || ![string match "" $comp_output] } then {
+ verbose -log "failed with: <$comp_output>, expected: <$opts(error)>"
+ send_log "$comp_output\n"
+ verbose "$comp_output" 3
+ if { $opts(error) != "" } {
+ if [regexp $opts(error) $comp_output] {
+ pass $testname
+ return
+ }
+ }
+ fail $testname
+ return
+ }
+ }
} else {
set objfile "tmpdir/dump0.o"
}
*************** proc run_dump_test { name } {
*** 699,704 ****
--- 738,744 ----
# We must not have expected failure if we get here.
if { $opts(error) != "" } {
fail $testname
+ return
}
if { [which $binary] == 0 } {
*************** proc slurp_options { file } {
*** 754,761 ****
set ws {[ ]*}
set nws {[^ ]*}
# whitespace is ignored anywhere except within the options list;
! # option names are alphabetic only
! set pat "^#${ws}(\[a-zA-Z\]*)$ws:${ws}(.*)$ws\$"
while { [gets $f line] != -1 } {
set line [string trim $line]
# Whitespace here is space-tab.
--- 794,801 ----
set ws {[ ]*}
set nws {[^ ]*}
# whitespace is ignored anywhere except within the options list;
! # option names are alphabetic plus underscore only.
! set pat "^#${ws}(\[a-zA-Z_\]*)$ws:${ws}(.*)$ws\$"
while { [gets $f line] != -1 } {
set line [string trim $line]
# Whitespace here is space-tab.
brgds, H-P
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFA:] More run_dump_test functionality.
2001-09-10 21:06 [RFA:] More run_dump_test functionality Hans-Peter Nilsson
@ 2001-09-14 6:29 ` Nick Clifton
0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2001-09-14 6:29 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: binutils
Hi Hans-Peter,
> ld/testsuite:
>
> * lib/ld-lib.exp (run_dump_test): Handle new option
> "objcopy_linked_file". Return after failing, if errors were
> expected but none were found.
> (slurp_options): Support underscores in option names.
Approved.
Cheers
Nick
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-09-14 6:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-10 21:06 [RFA:] More run_dump_test functionality Hans-Peter Nilsson
2001-09-14 6:29 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).