Message ID | 1447138000-1961-1-git-send-email-vapier@gentoo.org |
---|---|
State | Committed |
Delegated to: | Mike Frysinger |
Headers | show |
On 11/10/2015 06:46 AM, Mike Frysinger wrote: > Sometimes in tests, we need supplemental files like linker scripts or > board helper files. There's no way to set those flags in the tests > currently and relative paths don't work (breaks out of tree builds). > > Update the main option parser to replace some strings on the fly. Now > tests can do things like: > # ld: -T@srcdir@/@subdir@/sample.ld > > I'm not sure if there's any precedence for things like this in the tree. Seems like ld's testsuite has something like that. At least, grepping for "subdir" finds a ton of things like these, in .d files: ld-d10v/reloc-005.d:2:#ld: -T $srcdir/$subdir/reloc-005.ld ld-d10v/reloc-013.d:2:#ld: -T $srcdir/$subdir/reloc-013.ld ld-d10v/reloc-014.d:2:#ld: -T $srcdir/$subdir/reloc-014.ld ld-d10v/reloc-006.d:2:#ld: -T $srcdir/$subdir/reloc-006.ld I can't find where the magic $srcdir and $subdir are expanded. Maybe that's just passed through a tcl eval somewhere, which expands the tcl variables. Thanks, Pedro Alves
On 20 Nov 2015 15:36, Pedro Alves wrote: > On 11/10/2015 06:46 AM, Mike Frysinger wrote: > > Sometimes in tests, we need supplemental files like linker scripts or > > board helper files. There's no way to set those flags in the tests > > currently and relative paths don't work (breaks out of tree builds). > > > > Update the main option parser to replace some strings on the fly. Now > > tests can do things like: > > # ld: -T@srcdir@/@subdir@/sample.ld > > > > I'm not sure if there's any precedence for things like this in the tree. > > Seems like ld's testsuite has something like that. At least, grepping > for "subdir" finds a ton of things like these, in .d files: > > ld-d10v/reloc-005.d:2:#ld: -T $srcdir/$subdir/reloc-005.ld > ld-d10v/reloc-013.d:2:#ld: -T $srcdir/$subdir/reloc-013.ld > ld-d10v/reloc-014.d:2:#ld: -T $srcdir/$subdir/reloc-014.ld > ld-d10v/reloc-006.d:2:#ld: -T $srcdir/$subdir/reloc-006.ld ah, i should have thought of ld tests. thanks. > I can't find where the magic $srcdir and $subdir are expanded. Maybe > that's just passed through a tcl eval somewhere, which expands the tcl > variables. gcc seems to use dg-xxx helpers everywhere and those take care of executing code in context. i've made a note to (someday) look into converting the sim testsuite to use those. i guess using more of what dejagnu provides is the right answer ? -mike
diff --git a/sim/testsuite/lib/sim-defs.exp b/sim/testsuite/lib/sim-defs.exp index 2faf5dc..918ec0b 100644 --- a/sim/testsuite/lib/sim-defs.exp +++ b/sim/testsuite/lib/sim-defs.exp @@ -423,6 +424,7 @@ proc run_sim_test { name requested_machs } { # Subroutine of run_sim_test to process options in FILE. proc slurp_options { file } { + global subdir srcdir if [catch { set f [open $file r] } x] { #perror "couldn't open `$file': $x" perror "$x" @@ -442,6 +444,10 @@ proc slurp_options { file } { # Whitespace here is space-tab. if [regexp $pat $line xxx opt_name opt_machs opt_val] { # match! + set opt_val [string map [list \ + {@srcdir@} "$srcdir" \ + {@subdir@} "$subdir" \ + ] "$opt_val"] lappend opt_array [list $opt_name $opt_machs $opt_val] set seen_opt 1 } else {