[1/3] sim: testsuite: calculate $arch from $subdir

Message ID 20210404143538.14995-1-vapier@gentoo.org
State New
Headers show
Series
  • [1/3] sim: testsuite: calculate $arch from $subdir
Related show

Commit Message

Luis Machado via Gdb-patches April 4, 2021, 2:35 p.m.
Since we require ports to use a matching subdir name in the testsuite
tree, we can use that to calculate the $arch value.
---
 sim/testsuite/aarch64/allinsn.exp         |  4 ----
 sim/testsuite/arm/allinsn.exp             |  4 ----
 sim/testsuite/arm/iwmmxt/iwmmxt.exp       |  4 ----
 sim/testsuite/arm/misc.exp                |  4 ----
 sim/testsuite/arm/thumb/allthumb.exp      |  4 ----
 sim/testsuite/arm/xscale/xscale.exp       |  4 ----
 sim/testsuite/avr/allinsn.exp             |  4 ----
 sim/testsuite/bfin/allinsn.exp            |  4 ----
 sim/testsuite/bpf/allinsn.exp             |  4 ----
 sim/testsuite/cr16/allinsn.exp            |  4 ----
 sim/testsuite/cr16/misc.exp               |  4 ----
 sim/testsuite/cris/asm/asm.exp            |  4 ----
 sim/testsuite/cris/c/c.exp                |  4 ----
 sim/testsuite/cris/hw/rv-n-cris/rvc.exp   |  7 +-----
 sim/testsuite/d10v/allinsn.exp            |  4 ----
 sim/testsuite/example-synacor/allinsn.exp |  4 ----
 sim/testsuite/frv/allinsn.exp             |  4 ----
 sim/testsuite/frv/fr400/allinsn.exp       |  4 ----
 sim/testsuite/frv/fr500/allinsn.exp       |  4 ----
 sim/testsuite/frv/fr550/allinsn.exp       |  4 ----
 sim/testsuite/frv/interrupts.exp          |  4 ----
 sim/testsuite/frv/misc.exp                |  4 ----
 sim/testsuite/frv/parallel.exp            |  4 ----
 sim/testsuite/ft32/allinsn.exp            |  4 ----
 sim/testsuite/h8300/allinsn.exp           |  4 ----
 sim/testsuite/iq2000/allinsn.exp          |  4 ----
 sim/testsuite/lib/sim-defs.exp            | 27 ++++++++++++++---------
 sim/testsuite/lm32/allinsn.exp            |  4 ----
 sim/testsuite/m32c/allinsn.exp            |  4 ----
 sim/testsuite/m32r/allinsn.exp            |  4 ----
 sim/testsuite/m32r/misc.exp               |  4 ----
 sim/testsuite/m68hc11/allinsn.exp         |  4 ----
 sim/testsuite/mcore/allinsn.exp           |  4 ----
 sim/testsuite/microblaze/allinsn.exp      |  4 ----
 sim/testsuite/mips/basic.exp              |  4 ----
 sim/testsuite/mn10300/allinsn.exp         |  4 ----
 sim/testsuite/moxie/allinsn.exp           |  4 ----
 sim/testsuite/msp430/allinsn.exp          |  4 ----
 sim/testsuite/or1k/alltests.exp           |  4 ----
 sim/testsuite/pru/allinsn.exp             |  4 ----
 sim/testsuite/riscv/allinsn.exp           |  4 ----
 sim/testsuite/sh/allinsn.exp              |  4 ----
 sim/testsuite/v850/allinsns.exp           |  4 ----
 43 files changed, 18 insertions(+), 180 deletions(-)

-- 
2.30.2

Comments

Dimitar Dimitrov April 5, 2021, 4:31 p.m. | #1
On Sun, 4 Apr 2021 17:35:36 EEST Mike Frysinger via Gdb-patches wrote:
> Since we require ports to use a matching subdir name in the testsuite

> tree, we can use that to calculate the $arch value.

> ---

>  sim/testsuite/aarch64/allinsn.exp         |  4 ----

>  sim/testsuite/arm/allinsn.exp             |  4 ----

>  sim/testsuite/arm/iwmmxt/iwmmxt.exp       |  4 ----

>  sim/testsuite/arm/misc.exp                |  4 ----

>  sim/testsuite/arm/thumb/allthumb.exp      |  4 ----

>  sim/testsuite/arm/xscale/xscale.exp       |  4 ----

>  sim/testsuite/avr/allinsn.exp             |  4 ----

>  sim/testsuite/bfin/allinsn.exp            |  4 ----

>  sim/testsuite/bpf/allinsn.exp             |  4 ----

>  sim/testsuite/cr16/allinsn.exp            |  4 ----

>  sim/testsuite/cr16/misc.exp               |  4 ----

>  sim/testsuite/cris/asm/asm.exp            |  4 ----

>  sim/testsuite/cris/c/c.exp                |  4 ----

>  sim/testsuite/cris/hw/rv-n-cris/rvc.exp   |  7 +-----

>  sim/testsuite/d10v/allinsn.exp            |  4 ----

>  sim/testsuite/example-synacor/allinsn.exp |  4 ----

>  sim/testsuite/frv/allinsn.exp             |  4 ----

>  sim/testsuite/frv/fr400/allinsn.exp       |  4 ----

>  sim/testsuite/frv/fr500/allinsn.exp       |  4 ----

>  sim/testsuite/frv/fr550/allinsn.exp       |  4 ----

>  sim/testsuite/frv/interrupts.exp          |  4 ----

>  sim/testsuite/frv/misc.exp                |  4 ----

>  sim/testsuite/frv/parallel.exp            |  4 ----

>  sim/testsuite/ft32/allinsn.exp            |  4 ----

>  sim/testsuite/h8300/allinsn.exp           |  4 ----

>  sim/testsuite/iq2000/allinsn.exp          |  4 ----

>  sim/testsuite/lib/sim-defs.exp            | 27 ++++++++++++++---------

>  sim/testsuite/lm32/allinsn.exp            |  4 ----

>  sim/testsuite/m32c/allinsn.exp            |  4 ----

>  sim/testsuite/m32r/allinsn.exp            |  4 ----

>  sim/testsuite/m32r/misc.exp               |  4 ----

>  sim/testsuite/m68hc11/allinsn.exp         |  4 ----

>  sim/testsuite/mcore/allinsn.exp           |  4 ----

>  sim/testsuite/microblaze/allinsn.exp      |  4 ----

>  sim/testsuite/mips/basic.exp              |  4 ----

>  sim/testsuite/mn10300/allinsn.exp         |  4 ----

>  sim/testsuite/moxie/allinsn.exp           |  4 ----

>  sim/testsuite/msp430/allinsn.exp          |  4 ----

>  sim/testsuite/or1k/alltests.exp           |  4 ----

>  sim/testsuite/pru/allinsn.exp             |  4 ----

>  sim/testsuite/riscv/allinsn.exp           |  4 ----

>  sim/testsuite/sh/allinsn.exp              |  4 ----

>  sim/testsuite/v850/allinsns.exp           |  4 ----

>  43 files changed, 18 insertions(+), 180 deletions(-)

Hi,

This patch set, in combination with the attached minor fix, is resolving all 
"check-sim" errors and failures for PRU target.

Thanks,
Dimitar
From 6f0fb28ff86acc17b5038978cc42144ffa5a5cb4 Mon Sep 17 00:00:00 2001
From: Dimitar Dimitrov <dimitar@dinux.eu>

Date: Mon, 5 Apr 2021 19:21:35 +0300
Subject: [PATCH] sim: Add bfd include path for common testsuite tools

On my Fedora33 host this patch fixes the following "make check-sim"
errors for both pru cross target, and native x86_64:

In file included from ../../../binutils/sim/common/sim-basics.h:131,
                 from testsuite/common/bits32m0.c:13:../../../binutils/sim/../include/gdb/callback.h:55:10: fatal error: bfd.h: No such file or directory
   55 | #include "bfd.h"
      |          ^~~~~~~

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>

---
 sim/testsuite/common/local.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sim/testsuite/common/local.mk b/sim/testsuite/common/local.mk
index 38ffb0b0b7d..4db7981d160 100644
--- a/sim/testsuite/common/local.mk
+++ b/sim/testsuite/common/local.mk
@@ -29,7 +29,8 @@ check_PROGRAMS += $(TESTS)
 
 %C%_CPPFLAGS = \
 	-I$(srcdir)/common \
-	-I$(srcroot)/include
+	-I$(srcroot)/include \
+	-I../bfd
 
 # These tests are build-time only tools.  Override the default rules for them.
 %D%/%.o: %D%/%.c
-- 
2.20.1
Luis Machado via Gdb-patches April 5, 2021, 5:17 p.m. | #2
On 05 Apr 2021 19:31, Dimitar Dimitrov wrote:
> From 6f0fb28ff86acc17b5038978cc42144ffa5a5cb4 Mon Sep 17 00:00:00 2001

> From: Dimitar Dimitrov <dimitar@dinux.eu>

> Date: Mon, 5 Apr 2021 19:21:35 +0300

> Subject: [PATCH] sim: Add bfd include path for common testsuite tools

> 

> On my Fedora33 host this patch fixes the following "make check-sim"

> errors for both pru cross target, and native x86_64:

> 

> In file included from ../../../binutils/sim/common/sim-basics.h:131,

>                  from testsuite/common/bits32m0.c:13:../../../binutils/sim/../include/gdb/callback.h:55:10: fatal error: bfd.h: No such file or directory

>    55 | #include "bfd.h"

>       |          ^~~~~~~


i'm guessing you don't have libbfd installed in your host distro already ?
i do which is why i think i missed this.

>  %C%_CPPFLAGS = \

>  	-I$(srcdir)/common \

> -	-I$(srcroot)/include

> +	-I$(srcroot)/include \

> +	-I../bfd


this looks fine.  i'm not sure it's super kosher since it's technically,
mixing host & target headers, but i don't think we have much choice at
this point.
-mike
Dimitar Dimitrov April 5, 2021, 6:19 p.m. | #3
On Mon, 5 Apr 2021 20:17:01 EEST Mike Frysinger wrote:
> On 05 Apr 2021 19:31, Dimitar Dimitrov wrote:

> > From 6f0fb28ff86acc17b5038978cc42144ffa5a5cb4 Mon Sep 17 00:00:00 2001

> > From: Dimitar Dimitrov <dimitar@dinux.eu>

> > Date: Mon, 5 Apr 2021 19:21:35 +0300

> > Subject: [PATCH] sim: Add bfd include path for common testsuite tools

> > 

> > On my Fedora33 host this patch fixes the following "make check-sim"

> > errors for both pru cross target, and native x86_64:

> > 

> > In file included from ../../../binutils/sim/common/sim-basics.h:131,

> > 

> >                  from

> >                  testsuite/common/bits32m0.c:13:../../../binutils/sim/../

> >                  include/gdb/callback.h:55:10: fatal error: bfd.h: No such

> >                  file or directory>    

> >    55 | #include "bfd.h"

> >    

> >       |          ^~~~~~~

> 

> i'm guessing you don't have libbfd installed in your host distro already ?

> i do which is why i think i missed this.

You are correct. I don't have libbfd installed on my host.

Regards,
Dimitar
Dimitar Dimitrov May 6, 2021, 8:51 p.m. | #4
On понеделник, 5 април 2021 г. 21:19:02 EEST Dimitar Dimitrov wrote:
> On Mon, 5 Apr 2021 20:17:01 EEST Mike Frysinger wrote:

> > On 05 Apr 2021 19:31, Dimitar Dimitrov wrote:

> > > From 6f0fb28ff86acc17b5038978cc42144ffa5a5cb4 Mon Sep 17 00:00:00 2001

> > > From: Dimitar Dimitrov <dimitar@dinux.eu>

> > > Date: Mon, 5 Apr 2021 19:21:35 +0300

> > > Subject: [PATCH] sim: Add bfd include path for common testsuite tools

> > > 

> > > On my Fedora33 host this patch fixes the following "make check-sim"

> > > errors for both pru cross target, and native x86_64:

> > > 

> > > In file included from ../../../binutils/sim/common/sim-basics.h:131,

> > > 

> > >                  from

> > >                  testsuite/common/bits32m0.c:13:../../../binutils/sim/..

> > >                  /

> > >                  include/gdb/callback.h:55:10: fatal error: bfd.h: No

> > >                  such

> > >                  file or directory>

> > >    

> > >    55 | #include "bfd.h"

> > >    

> > >       |          ^~~~~~~

> > 

> > i'm guessing you don't have libbfd installed in your host distro already ?

> > i do which is why i think i missed this.

> 

> You are correct. I don't have libbfd installed on my host.

Can this fix be merged? Or should I instead install libbfd as a prerequsite 
for running the sim test suite?

Thanks,
Dimitar
Luis Machado via Gdb-patches May 6, 2021, 10:27 p.m. | #5
On 06 May 2021 23:51, Dimitar Dimitrov wrote:
> On понеделник, 5 април 2021 г. 21:19:02 EEST Dimitar Dimitrov wrote:

> > On Mon, 5 Apr 2021 20:17:01 EEST Mike Frysinger wrote:

> > > On 05 Apr 2021 19:31, Dimitar Dimitrov wrote:

> > > > From 6f0fb28ff86acc17b5038978cc42144ffa5a5cb4 Mon Sep 17 00:00:00 2001

> > > > From: Dimitar Dimitrov <dimitar@dinux.eu>

> > > > Date: Mon, 5 Apr 2021 19:21:35 +0300

> > > > Subject: [PATCH] sim: Add bfd include path for common testsuite tools

> > > > 

> > > > On my Fedora33 host this patch fixes the following "make check-sim"

> > > > errors for both pru cross target, and native x86_64:

> > > > 

> > > > In file included from ../../../binutils/sim/common/sim-basics.h:131,

> > > > 

> > > >                  from

> > > >                  testsuite/common/bits32m0.c:13:../../../binutils/sim/..

> > > >                  /

> > > >                  include/gdb/callback.h:55:10: fatal error: bfd.h: No

> > > >                  such

> > > >                  file or directory>

> > > >    

> > > >    55 | #include "bfd.h"

> > > >    

> > > >       |          ^~~~~~~

> > > 

> > > i'm guessing you don't have libbfd installed in your host distro already ?

> > > i do which is why i think i missed this.

> > 

> > You are correct. I don't have libbfd installed on my host.

> 

> Can this fix be merged?


the expectation was you'd merge it.  if you need me to do it, let me know.
-mike

Patch

diff --git a/sim/testsuite/aarch64/allinsn.exp b/sim/testsuite/aarch64/allinsn.exp
index 04a234f53577..54d64784c230 100644
--- a/sim/testsuite/aarch64/allinsn.exp
+++ b/sim/testsuite/aarch64/allinsn.exp
@@ -1,10 +1,6 @@ 
 # AArch64 simulator testsuite
 
 if [istarget aarch64*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "aarch64"
-
     # all machines
     set all_machs "aarch64"
 
diff --git a/sim/testsuite/arm/allinsn.exp b/sim/testsuite/arm/allinsn.exp
index 89ff96594793..c4d1ccecc3c6 100644
--- a/sim/testsuite/arm/allinsn.exp
+++ b/sim/testsuite/arm/allinsn.exp
@@ -1,10 +1,6 @@ 
 # ARM simulator testsuite.
 
 if { [istarget arm*-*-*] } {
-    # Used to locate the `run` program.
-    global arch
-    set arch "arm"
-
     # all machines
     set all_machs "xscale"
 
diff --git a/sim/testsuite/arm/iwmmxt/iwmmxt.exp b/sim/testsuite/arm/iwmmxt/iwmmxt.exp
index 9710f3670ba7..4aff9c7d0287 100644
--- a/sim/testsuite/arm/iwmmxt/iwmmxt.exp
+++ b/sim/testsuite/arm/iwmmxt/iwmmxt.exp
@@ -1,10 +1,6 @@ 
 # Intel(r) Wireless MMX(tm) technology simulator testsuite.
 
 if { [istarget arm*-*-*] } {
-    # Used to locate the `run` program.
-    global arch
-    set arch "arm"
-
     # all machines
     set all_machs "xscale"
 
diff --git a/sim/testsuite/arm/misc.exp b/sim/testsuite/arm/misc.exp
index ea6fd3c3c9a0..818ee58adec3 100644
--- a/sim/testsuite/arm/misc.exp
+++ b/sim/testsuite/arm/misc.exp
@@ -1,10 +1,6 @@ 
 # Miscellaneous ARM simulator testcases
 
 if { [istarget arm*-*-*] } {
-    # Used to locate the `run` program.
-    global arch
-    set arch "arm"
-
     # all machines
     set all_machs "arm7tdmi"
 
diff --git a/sim/testsuite/arm/thumb/allthumb.exp b/sim/testsuite/arm/thumb/allthumb.exp
index eca5fa18c719..ec09a0da8294 100644
--- a/sim/testsuite/arm/thumb/allthumb.exp
+++ b/sim/testsuite/arm/thumb/allthumb.exp
@@ -1,10 +1,6 @@ 
 # ARM simulator testsuite.
 
 if { [istarget arm*-*-*] } {
-    # Used to locate the `run` program.
-    global arch
-    set arch "arm"
-
     # all machines
     set all_machs "arm7tdmi"
 
diff --git a/sim/testsuite/arm/xscale/xscale.exp b/sim/testsuite/arm/xscale/xscale.exp
index 20c9df80351c..e65a952dadb0 100644
--- a/sim/testsuite/arm/xscale/xscale.exp
+++ b/sim/testsuite/arm/xscale/xscale.exp
@@ -1,10 +1,6 @@ 
 # XSCALE simulator testsuite.
 
 if { [istarget arm*-*-*] } {
-    # Used to locate the `run` program.
-    global arch
-    set arch "arm"
-
     # all machines
     set all_machs "xscale"
 
diff --git a/sim/testsuite/avr/allinsn.exp b/sim/testsuite/avr/allinsn.exp
index a5c16b629b76..584a93da9305 100644
--- a/sim/testsuite/avr/allinsn.exp
+++ b/sim/testsuite/avr/allinsn.exp
@@ -1,10 +1,6 @@ 
 # avr simulator testsuite
 
 if [istarget avr-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "avr"
-
     # all machines
     set all_machs "avr"
 
diff --git a/sim/testsuite/bfin/allinsn.exp b/sim/testsuite/bfin/allinsn.exp
index 3d3378171c6d..aa304eaa9b4a 100644
--- a/sim/testsuite/bfin/allinsn.exp
+++ b/sim/testsuite/bfin/allinsn.exp
@@ -1,10 +1,6 @@ 
 # Analog Devices Blackfin simulator testsuite
 
 if [istarget bfin-*-elf] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "bfin"
-
     # all machines
     set all_machs "bfin"
 
diff --git a/sim/testsuite/bpf/allinsn.exp b/sim/testsuite/bpf/allinsn.exp
index ffffd8a68928..2cca77021afe 100644
--- a/sim/testsuite/bpf/allinsn.exp
+++ b/sim/testsuite/bpf/allinsn.exp
@@ -1,10 +1,6 @@ 
 # eBPF simulator testsuite
 
 if [istarget bpf-unknown-none] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "bpf"
-
     # all machines
     set all_machs "bpf"
 
diff --git a/sim/testsuite/cr16/allinsn.exp b/sim/testsuite/cr16/allinsn.exp
index 1b6847c78150..d6602b4c6822 100644
--- a/sim/testsuite/cr16/allinsn.exp
+++ b/sim/testsuite/cr16/allinsn.exp
@@ -1,10 +1,6 @@ 
 # CR16 simulator testsuite.
 
 if [istarget cr16*-*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "cr16"
-
     # all machines
     set all_machs "cr16"
 
diff --git a/sim/testsuite/cr16/misc.exp b/sim/testsuite/cr16/misc.exp
index 67fa4c2d7d38..5f9d68132b6a 100644
--- a/sim/testsuite/cr16/misc.exp
+++ b/sim/testsuite/cr16/misc.exp
@@ -1,10 +1,6 @@ 
 # Miscellaneous CR16 simulator testcases
 
 if [istarget cr16*-*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "cr16"
-
     # all machines
     set all_machs "cr16"
 
diff --git a/sim/testsuite/cris/asm/asm.exp b/sim/testsuite/cris/asm/asm.exp
index b8c14c8d05cb..415bbf1082a9 100644
--- a/sim/testsuite/cris/asm/asm.exp
+++ b/sim/testsuite/cris/asm/asm.exp
@@ -16,10 +16,6 @@ 
 # Miscellaneous CRIS simulator testcases in assembly code.
 
 if [istarget cris*-*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "cris"
-
     global ASFLAGS_FOR_TARGET
     # All machines we test and the corresponding assembler option.  Needs
     # update if we build the simulator for crisv0 crisv3 and crisv8 too.
diff --git a/sim/testsuite/cris/c/c.exp b/sim/testsuite/cris/c/c.exp
index 3d493b7c1449..08ea18812ec5 100644
--- a/sim/testsuite/cris/c/c.exp
+++ b/sim/testsuite/cris/c/c.exp
@@ -19,10 +19,6 @@  if ![istarget cris*-*-*] {
     return
 }
 
-# Used to locate the `run` program.
-global arch
-set arch "cris"
-
 set CFLAGS_FOR_TARGET "-O2"
 if [istarget cris-*-*] {
     set mach "crisv10"
diff --git a/sim/testsuite/cris/hw/rv-n-cris/rvc.exp b/sim/testsuite/cris/hw/rv-n-cris/rvc.exp
index 0a018fa4b881..4e302d2238fb 100644
--- a/sim/testsuite/cris/hw/rv-n-cris/rvc.exp
+++ b/sim/testsuite/cris/hw/rv-n-cris/rvc.exp
@@ -112,10 +112,6 @@  proc slurp_rv { file } {
 # The main test loop.
 
 if [istarget cris*-*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "cris"
-
     global ASFLAGS_FOR_TARGET
     set has_rv_and_cris [sim_has_rv_and_cris]
     global global_as_options
@@ -129,8 +125,7 @@  if [istarget cris*-*-*] {
     set sim [board_info target sim]
     if [string equal "" $sim] {
 	global objdir
-	global arch
-	set rvdummy "$objdir/../$arch/rvdummy"
+	set rvdummy "$objdir/cris/rvdummy"
     } else {
 	set rvdummy "[file dirname [board_info target sim]]/rvdummy"
     }
diff --git a/sim/testsuite/d10v/allinsn.exp b/sim/testsuite/d10v/allinsn.exp
index e2e44a290920..5f1a13177f14 100644
--- a/sim/testsuite/d10v/allinsn.exp
+++ b/sim/testsuite/d10v/allinsn.exp
@@ -1,10 +1,6 @@ 
 # d10v simulator testsuite.
 
 if [istarget d10v*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "d10v"
-
     # all machines
     set all_machs "d10v"
 
diff --git a/sim/testsuite/example-synacor/allinsn.exp b/sim/testsuite/example-synacor/allinsn.exp
index 7210a610e737..a73312b8adfb 100644
--- a/sim/testsuite/example-synacor/allinsn.exp
+++ b/sim/testsuite/example-synacor/allinsn.exp
@@ -1,10 +1,6 @@ 
 # Example synacor simulator testsuite.
 
 if [istarget *] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "example-synacor"
-
     # All machines.
     set all_machs "example"
 
diff --git a/sim/testsuite/frv/allinsn.exp b/sim/testsuite/frv/allinsn.exp
index 2633f30df567..1781bf0ed170 100644
--- a/sim/testsuite/frv/allinsn.exp
+++ b/sim/testsuite/frv/allinsn.exp
@@ -1,10 +1,6 @@ 
 # FRV simulator testsuite.
 
 if [istarget frv*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "frv"
-
     # all machines
     set all_machs "frv fr500 fr550 fr400 fr405 fr450"
     set cpu_option -mcpu
diff --git a/sim/testsuite/frv/fr400/allinsn.exp b/sim/testsuite/frv/fr400/allinsn.exp
index ea5846f8fa42..03ccbd6e8aba 100644
--- a/sim/testsuite/frv/fr400/allinsn.exp
+++ b/sim/testsuite/frv/fr400/allinsn.exp
@@ -1,10 +1,6 @@ 
 # FRV simulator testsuite.
 
 if [istarget frv*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "frv"
-
     # all machines
     set all_machs "fr400 fr405 fr450 fr550"
     set cpu_option -mcpu
diff --git a/sim/testsuite/frv/fr500/allinsn.exp b/sim/testsuite/frv/fr500/allinsn.exp
index 40caa6307060..fa03797d39ce 100644
--- a/sim/testsuite/frv/fr500/allinsn.exp
+++ b/sim/testsuite/frv/fr500/allinsn.exp
@@ -1,10 +1,6 @@ 
 # FRV simulator testsuite.
 
 if [istarget frv*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "frv"
-
     # all machines
     set all_machs "frv fr500 fr550"
     set cpu_option -mcpu
diff --git a/sim/testsuite/frv/fr550/allinsn.exp b/sim/testsuite/frv/fr550/allinsn.exp
index 8768a6719946..c0e373aa2672 100644
--- a/sim/testsuite/frv/fr550/allinsn.exp
+++ b/sim/testsuite/frv/fr550/allinsn.exp
@@ -1,10 +1,6 @@ 
 # FRV simulator testsuite.
 
 if [istarget frv*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "frv"
-
     # all machines
     set all_machs "fr550"
     set cpu_option -mcpu
diff --git a/sim/testsuite/frv/interrupts.exp b/sim/testsuite/frv/interrupts.exp
index d1f7628d962d..6b2c84a629ad 100644
--- a/sim/testsuite/frv/interrupts.exp
+++ b/sim/testsuite/frv/interrupts.exp
@@ -1,10 +1,6 @@ 
 # FRV simulator testsuite.
 
 if [istarget frv*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "frv"
-
     # all machines
     set all_machs "frv fr500 fr550 fr400"
     set cpu_option -mcpu
diff --git a/sim/testsuite/frv/misc.exp b/sim/testsuite/frv/misc.exp
index d9c80a546000..fb394bb17f00 100644
--- a/sim/testsuite/frv/misc.exp
+++ b/sim/testsuite/frv/misc.exp
@@ -1,10 +1,6 @@ 
 # Miscellaneous FRV simulator testcases.
 
 if [istarget frv*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "frv"
-
     # all machines
     set all_machs "frv fr500 fr550 fr400 fr405 fr450"
     set cpu_option -mcpu
diff --git a/sim/testsuite/frv/parallel.exp b/sim/testsuite/frv/parallel.exp
index a883b9891d5d..612a1bfd9e14 100644
--- a/sim/testsuite/frv/parallel.exp
+++ b/sim/testsuite/frv/parallel.exp
@@ -1,10 +1,6 @@ 
 # FRV simulator testsuite.
 
 if [istarget frv*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "frv"
-
     # all machines
     set all_machs "frv fr500 fr550 fr400"
     set cpu_option -mcpu
diff --git a/sim/testsuite/ft32/allinsn.exp b/sim/testsuite/ft32/allinsn.exp
index 50827a592473..730b4223632d 100644
--- a/sim/testsuite/ft32/allinsn.exp
+++ b/sim/testsuite/ft32/allinsn.exp
@@ -1,10 +1,6 @@ 
 # ft32 simulator testsuite
 
 if [istarget ft32-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "ft32"
-
     # all machines
     set all_machs "ft32"
 
diff --git a/sim/testsuite/h8300/allinsn.exp b/sim/testsuite/h8300/allinsn.exp
index 5355bf58a69d..68468f6bb106 100644
--- a/sim/testsuite/h8300/allinsn.exp
+++ b/sim/testsuite/h8300/allinsn.exp
@@ -1,10 +1,6 @@ 
 # Hitachi H8/300 (h, s, sx) simulator testsuite
 
 if {[istarget h8300*-*-*] || [istarget h8sx*-*-*]} then {
-    # Used to locate the `run` program.
-    global arch
-    set arch "h8300"
-
     set all_machs "h8300 h8300h h8300s h8sx"
 
     foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.s]] {
diff --git a/sim/testsuite/iq2000/allinsn.exp b/sim/testsuite/iq2000/allinsn.exp
index 96d58435fb45..38eee9b277f1 100644
--- a/sim/testsuite/iq2000/allinsn.exp
+++ b/sim/testsuite/iq2000/allinsn.exp
@@ -1,10 +1,6 @@ 
 # iq2000 simulator testsuite
 
 if [istarget iq2000-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "iq2000"
-
     # all machines
     set all_machs "iq2000"
 
diff --git a/sim/testsuite/lib/sim-defs.exp b/sim/testsuite/lib/sim-defs.exp
index e1254a3278cf..1b40216ea6ed 100644
--- a/sim/testsuite/lib/sim-defs.exp
+++ b/sim/testsuite/lib/sim-defs.exp
@@ -48,6 +48,22 @@  proc sim_compile { source dest type options } {
     return $result
 }
 
+# Find the path to the simulator for executing.
+proc sim_tool_path {} {
+    global sim_path
+    set sim "$sim_path"
+    if [string equal "" $sim] {
+	global objdir
+	global subdir
+	set arch "$subdir"
+	while { [file dirname $arch] != "." } {
+	    set arch [file dirname $arch]
+	}
+	return "$objdir/$arch/run"
+    }
+    return "$sim"
+}
+
 # Run a program on the simulator.
 # Required by dejagnu (at least ${tool}_run used to be).
 #
@@ -98,16 +114,7 @@  proc sim_run { prog sim_opts prog_opts redir options } {
 	
     verbose "testcase timeout is set to $testcase_timeout" 1
 
-    set sim [board_info target sim]
-    if [string equal "" $sim] {
-	# Special case the simulator.  These tests are designed to
-	# be run inside of the simulator, not on the native host.
-	# So if the sim target isn't set, default to the target run.
-	# These global variables come from generated site.exp.
-	global objdir
-	global arch
-	set sim "$objdir/$arch/run"
-    }
+    set sim [sim_tool_path]
 
     if [is_remote host] {
 	set prog [remote_download host $prog]
diff --git a/sim/testsuite/lm32/allinsn.exp b/sim/testsuite/lm32/allinsn.exp
index ae7c141bd643..61744985f6c8 100644
--- a/sim/testsuite/lm32/allinsn.exp
+++ b/sim/testsuite/lm32/allinsn.exp
@@ -1,10 +1,6 @@ 
 # lm32 simulator testsuite
 
 if [istarget lm32-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "lm32"
-
     # all machines
     set all_machs "lm32"
 
diff --git a/sim/testsuite/m32c/allinsn.exp b/sim/testsuite/m32c/allinsn.exp
index b09b505972a3..fb5ccca282e1 100644
--- a/sim/testsuite/m32c/allinsn.exp
+++ b/sim/testsuite/m32c/allinsn.exp
@@ -2,10 +2,6 @@ 
 # TODO: Add support for .c tests.
 
 if [istarget m32c*-*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "m32c"
-
     # all machines
     set all_machs "m32c"
 
diff --git a/sim/testsuite/m32r/allinsn.exp b/sim/testsuite/m32r/allinsn.exp
index a800e78b1b46..17a86189f79f 100644
--- a/sim/testsuite/m32r/allinsn.exp
+++ b/sim/testsuite/m32r/allinsn.exp
@@ -1,10 +1,6 @@ 
 # M32R simulator testsuite.
 
 if [istarget m32r*-*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "m32r"
-
     # all machines
     set all_machs "m32r"
 
diff --git a/sim/testsuite/m32r/misc.exp b/sim/testsuite/m32r/misc.exp
index e571c2eeb69d..6c624e737e74 100644
--- a/sim/testsuite/m32r/misc.exp
+++ b/sim/testsuite/m32r/misc.exp
@@ -1,10 +1,6 @@ 
 # Miscellaneous M32R simulator testcases
 
 if [istarget m32r*-*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "m32r"
-
     # all machines
     set all_machs "m32r"
 
diff --git a/sim/testsuite/m68hc11/allinsn.exp b/sim/testsuite/m68hc11/allinsn.exp
index 0e9b51ec5934..db0cbd5d4670 100644
--- a/sim/testsuite/m68hc11/allinsn.exp
+++ b/sim/testsuite/m68hc11/allinsn.exp
@@ -1,10 +1,6 @@ 
 # m68hc11 simulator testsuite
 
 if [istarget m68hc11-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "m68hc11"
-
     # all machines
     set all_machs "m68hc11"
 
diff --git a/sim/testsuite/mcore/allinsn.exp b/sim/testsuite/mcore/allinsn.exp
index ecc934b20146..5921cfc26431 100644
--- a/sim/testsuite/mcore/allinsn.exp
+++ b/sim/testsuite/mcore/allinsn.exp
@@ -1,10 +1,6 @@ 
 # mcore simulator testsuite
 
 if [istarget mcore-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "mcore"
-
     # all machines
     set all_machs "mcore"
 
diff --git a/sim/testsuite/microblaze/allinsn.exp b/sim/testsuite/microblaze/allinsn.exp
index 5f5a4475eed4..f756914292c4 100644
--- a/sim/testsuite/microblaze/allinsn.exp
+++ b/sim/testsuite/microblaze/allinsn.exp
@@ -1,10 +1,6 @@ 
 # microblaze simulator testsuite
 
 if [istarget microblaze-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "microblaze"
-
     # all machines
     set all_machs "microblaze"
 
diff --git a/sim/testsuite/mips/basic.exp b/sim/testsuite/mips/basic.exp
index 2eff923c0fc7..352b3b4e7193 100644
--- a/sim/testsuite/mips/basic.exp
+++ b/sim/testsuite/mips/basic.exp
@@ -42,10 +42,6 @@  proc run_sim_tests { name requested_machs { requested_micromips_machs "" } } {
 
 # Only test mips*-*-elf (e.g., no mips*-*-linux)
 if {[istarget mips*-*-elf]} {
-    # Used to locate the `run` program.
-    global arch
-    set arch "mips"
-
     set dspmodels ""
     set mdmxmodels ""
     set micromipsmodels ""
diff --git a/sim/testsuite/mn10300/allinsn.exp b/sim/testsuite/mn10300/allinsn.exp
index 7166aefddf30..f8431e7222ea 100644
--- a/sim/testsuite/mn10300/allinsn.exp
+++ b/sim/testsuite/mn10300/allinsn.exp
@@ -1,10 +1,6 @@ 
 # mn10300 simulator testsuite
 
 if [istarget mn10300-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "mn10300"
-
     # all machines
     set all_machs "mn10300"
 
diff --git a/sim/testsuite/moxie/allinsn.exp b/sim/testsuite/moxie/allinsn.exp
index 241e67576253..1a6af8b37d45 100644
--- a/sim/testsuite/moxie/allinsn.exp
+++ b/sim/testsuite/moxie/allinsn.exp
@@ -1,10 +1,6 @@ 
 # moxie simulator testsuite
 
 if [istarget moxie-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "moxie"
-
     # all machines
     set all_machs "moxie"
 
diff --git a/sim/testsuite/msp430/allinsn.exp b/sim/testsuite/msp430/allinsn.exp
index 83030290cce2..affa8aedc2ad 100644
--- a/sim/testsuite/msp430/allinsn.exp
+++ b/sim/testsuite/msp430/allinsn.exp
@@ -1,10 +1,6 @@ 
 # msp430 simulator testsuite
 
 if [istarget msp430-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "msp430"
-
     # all machines
     set all_machs "msp430"
 
diff --git a/sim/testsuite/or1k/alltests.exp b/sim/testsuite/or1k/alltests.exp
index 98c1345d0be5..365f3910debf 100644
--- a/sim/testsuite/or1k/alltests.exp
+++ b/sim/testsuite/or1k/alltests.exp
@@ -16,10 +16,6 @@ 
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 if [istarget or1k*-*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "or1k"
-
     set all_machs "or1k"
 
     global global_ld_options
diff --git a/sim/testsuite/pru/allinsn.exp b/sim/testsuite/pru/allinsn.exp
index c0d5ce936894..d147f731c913 100644
--- a/sim/testsuite/pru/allinsn.exp
+++ b/sim/testsuite/pru/allinsn.exp
@@ -19,10 +19,6 @@ 
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 if [istarget pru-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "pru"
-
     # all machines
     set all_machs "pru"
 
diff --git a/sim/testsuite/riscv/allinsn.exp b/sim/testsuite/riscv/allinsn.exp
index 5701391da832..03bec1b541e7 100644
--- a/sim/testsuite/riscv/allinsn.exp
+++ b/sim/testsuite/riscv/allinsn.exp
@@ -1,10 +1,6 @@ 
 # RISC-V simulator testsuite.
 
 if [istarget riscv*-*] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "riscv"
-
     # all machines
     set all_machs "riscv"
 
diff --git a/sim/testsuite/sh/allinsn.exp b/sim/testsuite/sh/allinsn.exp
index 235a40c692ab..40d139299426 100644
--- a/sim/testsuite/sh/allinsn.exp
+++ b/sim/testsuite/sh/allinsn.exp
@@ -13,10 +13,6 @@  foreach opt $board_variant_list {
 }
 
 if [istarget sh-*elf] {
-    # Used to locate the `run` program.
-    global arch
-    set arch "sh"
-
     run_sim_test add.s    $all
     run_sim_test and.s    $all
     run_sim_test bandor.s sh
diff --git a/sim/testsuite/v850/allinsns.exp b/sim/testsuite/v850/allinsns.exp
index 4c3bc088ff6b..93dcffce2f37 100644
--- a/sim/testsuite/v850/allinsns.exp
+++ b/sim/testsuite/v850/allinsns.exp
@@ -3,10 +3,6 @@ 
 if [istarget v850*-*] {
     global opt
 
-    # Used to locate the `run` program.
-    global arch
-    set arch "v850"
-
     # all machines
     switch -regexp -- $opt {
 	.*v850e.* {