diff options
author | Mike Frysinger <vapier@gentoo.org> | 2021-11-21 03:41:39 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2021-11-26 19:48:05 -0500 |
commit | c0d6a6e5828882040bbb55bafea6b188a18fc000 (patch) | |
tree | d8cf4615c587d48caa174be280f30eb622d167b7 /sim/testsuite/lib | |
parent | 4c721b266fdae6e2761cc122fac4cfb42932e295 (diff) | |
download | binutils-c0d6a6e5828882040bbb55bafea6b188a18fc000.zip binutils-c0d6a6e5828882040bbb55bafea6b188a18fc000.tar.gz binutils-c0d6a6e5828882040bbb55bafea6b188a18fc000.tar.bz2 |
sim: testsuite: rework sim_init usage
The sim_init function was called by runtest for each test when --tool
was set to sim. When we changed to --tool '' to collapse the testsuite
dir, the init function was no longer called on every test. However, it
was still being called explicitly by config/default.exp. It's not clear
why that explicit call ever existed since, in the past, it meant it was
redundant.
Lets drop the single sim_init call in config/default.exp and move it out
to all our tests. This replicates the runtest behavior so we can setup
variables on a per-test basis which allows us to recollapse the sim_path
logic back. We'll also leverage this in the future for toolchain setup.
Also add a few comments clarifying the overall runtime behavior.
Diffstat (limited to 'sim/testsuite/lib')
-rw-r--r-- | sim/testsuite/lib/sim-defs.exp | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/sim/testsuite/lib/sim-defs.exp b/sim/testsuite/lib/sim-defs.exp index 405f1b7..46a8b3f 100644 --- a/sim/testsuite/lib/sim-defs.exp +++ b/sim/testsuite/lib/sim-defs.exp @@ -7,12 +7,22 @@ set sim_path "unknown-run" # Initialize the testrun. -# Required by dejagnu. +# +# Normally dejagnu will execute ${tool}_init automatically, but since we set +# --tool '' (for a simpler testsuite/ layout), we have each test call this +# itself. proc sim_init { args } { + global builddir + global subdir global sim_path - set sim_path [board_info target sim] - # Need to return an empty string (copied from GAS). + + # Find the path to the simulator for executing. + set arch "$subdir" + while { [file dirname $arch] != "." } { + set arch [file dirname $arch] + } + set sim_path "$builddir/$arch/run" # As gross as it is, we unset the linker script specified by the target # board. The simulator board file mips-sim.exp, sets ldscript to the @@ -23,6 +33,8 @@ proc sim_init { args } { # all simulators. unset_currtarget_info ldscript + # Need to return an empty string. This tells dejagnu to *not* re-run us + # with the exact test that we're about to run. return "" } @@ -35,22 +47,6 @@ proc sim_version {} { clone_output "$sim_path $version\n" } -# Find the path to the simulator for executing. -proc sim_tool_path {} { - global sim_path - set sim "$sim_path" - if [string equal "" $sim] { - global builddir - global subdir - set arch "$subdir" - while { [file dirname $arch] != "." } { - set arch [file dirname $arch] - } - return "$builddir/$arch/run" - } - return "$sim" -} - # Run a program on the simulator. # Required by dejagnu (at least ${tool}_run used to be). # @@ -73,6 +69,8 @@ proc sim_tool_path {} { # simulator (not the simulated program, the simulator) with sim_load. proc sim_run { prog sim_opts prog_opts redir options } { + global sim_path + # Set the default value of the timeout. # FIXME: The timeout value we actually want is a function of # host, target, and testcase. @@ -99,7 +97,7 @@ proc sim_run { prog sim_opts prog_opts redir options } { verbose "testcase timeout is set to $testcase_timeout" 1 - set sim [sim_tool_path] + set sim $sim_path if [is_remote host] { set prog [remote_download host $prog] @@ -182,13 +180,14 @@ proc sim_run { prog sim_opts prog_opts redir options } { proc run_sim_test { name requested_machs } { global subdir srcdir objdir + global sim_path global opts global cpu_option global cpu_option_sep global SIMFLAGS_FOR_TARGET - if ![file exists [sim_tool_path]] { - unsupported "$name: missing simulator [sim_tool_path]" + if ![file exists $sim_path] { + unsupported "$name: missing simulator $sim_path" return } |