public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [RFC] sim: testsuite: support @vars@ in flags
@ 2015-11-10  6:46 Mike Frysinger
  2015-11-20 15:36 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Frysinger @ 2015-11-10  6:46 UTC (permalink / raw)
  To: gdb-patches

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.

2015-11-10  Mike Frysinger  <vapier@gentoo.org>

	* lib/sim-defs.exp (slurp_options): Pull in global subdir/srcdir.
	Replace @srcdir@ and @subdir@ in the read option.
---
 sim/testsuite/lib/sim-defs.exp | 5 +++++
 1 file changed, 5 insertions(+)

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 {
-- 
2.6.2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [RFC] sim: testsuite: support @vars@ in flags
  2015-11-10  6:46 [PATCH] [RFC] sim: testsuite: support @vars@ in flags Mike Frysinger
@ 2015-11-20 15:36 ` Pedro Alves
  2015-11-20 19:32   ` Mike Frysinger
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2015-11-20 15:36 UTC (permalink / raw)
  To: Mike Frysinger, gdb-patches

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [RFC] sim: testsuite: support @vars@ in flags
  2015-11-20 15:36 ` Pedro Alves
@ 2015-11-20 19:32   ` Mike Frysinger
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2015-11-20 19:32 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1415 bytes --]

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-20 19:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-10  6:46 [PATCH] [RFC] sim: testsuite: support @vars@ in flags Mike Frysinger
2015-11-20 15:36 ` Pedro Alves
2015-11-20 19:32   ` Mike Frysinger

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).