Commit Graph

580 Commits

Author SHA1 Message Date
Jose E. Marchesi
7bb9f0c2be sim/bpf: desCGENization of the BPF simulator
The BPF port in binutils has been rewritten (commit
d218e7fedc) in order to not be longer
based on CGEN.  Please see that commit log for more information.

This patch updates the BPF simulator accordingly.  The new
implementation is much simpler and it is based on the new BPF opcodes.

Tested with target bpf-unknown-none with both 64-bit little-endian
host and 32-bit little-endian host.

Note that I have not tested in a big-endian host yet.  I will do so
once this lands upstream so I can use the GCC compiler farm.
2023-07-21 12:40:50 +02:00
Jose E. Marchesi
873a1ec405 sim: bpf: update to new BPF relocations
This patch updates the BPF GNU sim testsuite in order to match the new
BPF relocations introduced in binutils in a recent patch [1].

[1] https://sourceware.org/pipermail/binutils/2023-March/126429.html
2023-04-26 19:22:14 +02:00
Guillermo E. Martinez
7cbf35923d sim: bpf: fix testsuite due to linker warnings [PR sim/29954]
On a bpf-*-* testsuite fails:
	./ld/ld-new: warning: test has a LOAD segment with RWX permissions

Adjusting `--memory-size=10Mb' to the simulator bpf testsuite passes.

Tested on bpf-*-*:

Bug: https://sourceware.org/PR29954

sim/testsuite:
	* bpf/allinsn.exp (SIMFLAGS_FOR_TARGET): Adjust sim flags.
2023-01-04 20:54:14 -05:00
Joel Brobecker
213516ef31 Update copyright year range in header of all files managed by GDB
This commit is the result of running the gdb/copyright.py script,
which automated the update of the copyright year range for all
source files managed by the GDB project to be updated to include
year 2023.
2023-01-01 17:01:16 +04:00
Dimitar Dimitrov
7bee555bb7 sim: pru: Fix behaviour when loop count is zero
If the counter for LOOP instruction is provided by a register with
value zero, then the instruction must cause a PC jump directly to the
loop end.  But in that particular case simulator must not initialize
its internal loop variables, because loop body will not be executed.
Instead, simulator must obtain the loop's end address directly from
the LOOP instruction.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2022-11-12 15:10:07 +02:00
Mike Frysinger
7b3dd7b9b3 sim: testsuite: fix cris stat3 in diff setups
This test uses the test itself as an input to stating regular files.
This gets funky though: when we run check in parallel, the output
object dir is the subdir that matches the .exp file.  When we run
with -j1, the output object dir is the sim builddir itself.

The old test would append argv[0] to find the file, while the new
test uses basename on it.  Each method works in only one of the
aforementioned build scenarios.  Rather than complicate this any
more, switch to a different file that we know will always exist:
the Makefile.
2022-11-04 01:42:41 +07:00
Mike Frysinger
4ce3ba0865 sim: testsuite: fix cris badarch in multi-target builds
This test assumes that /bin/sh will never be a CRIS ELF by way of
assuming that the current bfd cannot load it (since a basic cris
cross-compiler only understands CRIS ELFs).  In a multi-target
build though, bfd understands just about every ELF out there, so
we're able to read the /bin/sh format before failing at a diff
point in the cris code.

Let's switch to using / instead since it'll fail for a similar
reason (at least similar enough for what this test is testing).
2022-11-04 01:42:41 +07:00
Mike Frysinger
8f97b519fb sim: testsuite: improve parallel test processing
The current logic limits itself to a maxdepth of 4 when looking for
results.  This wouldn't be a problem if cris didn't have a testsuite
at a depth of 5 which we end up ignoring when summarizing.  Rather
than bump the number from 4 to 5, rework the code so that we gather
the exact set of tests that we tried to run.
2022-10-26 14:38:44 +05:45
Mike Frysinger
e60091e4d3 sim: testsuite: update ignored .exp files [PR sim/29596]
Now that we run `check/foo.exp` instead of `check/./foo.exp`,
update the config/ & lib/ exceptions to cover both paths.

Bug: https://sourceware.org/PR29596
2022-10-24 01:28:15 +05:45
Mike Frysinger
86ef36f655 sim: testsuite: tweak parallel find invocation [PR sim/29596]
Make sure we invoke runtest with the same exp filenames when running in
parallel as it will find when run single threaded.  When `runtest` finds
files itself, it will use paths like "aarch64/allinsn.exp".  When we run
`find .` with the %p option, it produces "./aarch64/allinsn.exp".  Switch
to %P to get "aarch64/allinsn.exp".

Bug: https://sourceware.org/PR29596
2022-10-24 00:58:49 +05:45
Tsukasa OI
c6422d7be7 sim/riscv: fix multiply instructions on simulator
After this commit:

  commit 0938b032da
  Date:   Wed Feb 2 10:06:15 2022 +0900

      RISC-V: Add 'Zmmul' extension in assembler.

some instructions in the RISC-V simulator stopped working as a new
instruction class 'INSN_CLASS_ZMMUL' was added, and some existing
instructions were moved into this class.

The simulator doesn't currently handle this instruction class, and so
the instructions will now cause an illegal instruction trap.

This commit adds support for INSN_CLASS_ZMMUL, and adds a test that
ensures the affected instructions can be executed by the simulator.

Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Reviewed-by: Andrew Burgess <aburgess@redhat.com>
2022-10-11 12:38:36 +01:00
Jeff Law
477904ca75 Fix for v850e divq instruction
This is the last of the correctness fixes I've been carrying around for the
v850.

Like the other recent fixes, this is another case where we haven't been as
careful as we should WRT host vs target types.   For the divq instruction
both operands are 32 bit types.  Yet in the simulator code we convert them
from unsigned int to signed long by assignment.  So 0xfffffffb (aka -5)
turns into 4294967291 and naturally that changes the result of our division.

The fix is simple, insert a cast to int32_t to force interpretation as a
signed value.

Testcase for the simulator is included.  It has a trivial dependency on the
bins patch.
2022-04-06 11:10:40 -04:00
Jeff Law
49fffa58f7 Fix "bins" simulation for v850e3v5
I've been carrying this for a few years.   One test in the GCC testsuite is
failing due to a bug in the handling of the v850e3v5 instruction "bins".

When the "bins" instruction specifies a 32bit bitfield size, the simulator
exhibits undefined behavior by trying to shift a 32 bit quantity by 32 bits.
In the case of a 32 bit shift, we know what the resultant mask should be.  So
we can just set it.

That seemed better than using 1UL for the constant (on a 32bit host unsigned
long might still just be 32 bits) or needlessly forcing everything to
long long types.

Thankfully the case where this shows up is only bins <src>, 0, 32, <dest>
which would normally be encoded as a simple move.

	* testsuite/v850/allinsns.exp: Add v850e3v5.
	* testsuite/v850/bins.cgs: New test.
	* v850/simops.c (v850_bins): Avoid undefined behavior on left shift.
2022-04-06 11:06:53 -04:00
Jeff Law
5321c31bc7 Fix for MUL instruction on the v850
* sim/v850/simops.c (Multiply64): Properly test if we need to
	negate either of the operands.

	* sim/testsuite/v850/mul.cgs: New test.
2022-03-29 20:08:35 -04:00
Hans-Peter Nilsson
7443cb7479 sim/testsuite/cris/c/stat3.c: Fix formatting nit
* c/stat3.c (main): Fix formatting nit.
2022-02-16 07:38:38 +01:00
Mike Frysinger
d0b2f561a1 sim: testsuite: cleanup the istarget * logic
Now that the multitarget testing has settled, clean up the cases where
istarget * is used.  This ends up being mostly style unindenting.
2022-02-16 00:36:47 -05:00
Hans-Peter Nilsson
e63f65fea9 sim/testsuite: Default global_cc_os and global_cc_works properly
There was an omission on 3e6dc39ed7 "sim/testsuite: Set
global_cc_os also when no compiler is found"; global_cc_os
wasn't set for other than the primary target, which means
that the "unguarded" use of global_cc_os in
testsuite/cris/c/c.exp caused the dreaded "ERROR: can't read
"global_cc_os": no such variable" when e.g. configuring for
pru-elf and doing "make check-sim".  Better initializing
both variables at the top to default values, rather than
adding another single 'set global_cc_os ""', to reduce the
risk of not setting them properly if or when that
if-statement-chain is made longer.

sim/testsuite:
	* lib/sim-defs.exp (sim_init_toolchain): Default
	global_cc_os and global_cc_works properly, before if-chain.
2022-02-15 23:35:23 +01:00
Hans-Peter Nilsson
234f5865fa sim/testsuite/cris: If failing compilation, mark C tests as errors
...when we know we have a working compiler.  This will reduce
the risk of faulty edits by exposing them rather than hiding
them as "unresolved".  It also harmonizes behavior with that of
run_sim_test.

	* c/c.exp: Mark C tests failing compilation test errors.
2022-02-14 23:53:23 +01:00
Hans-Peter Nilsson
4b0e74fd18 sim/testsuite/cris: Remove faulty use of basename in C tests
Calls to basename were added here as part of commit
e1e1ae6e9b "sim: testsuite: fix objdir handling", but that
commit missed adding "#include <libgen.h>" or the equivalent
GNU extension, see basename(3).  Fixing that shows a logical
error in the change to openpf1.c; the non-/-prefixed
code-path was changed instead of the "/"-prefixed code-path,
which is the one executed after that commit.

For "newlib" these tests failed linking after that commit.
Recent newlib has the (asm-renamed) GNU-extension-variant of
basename, but we're better off not using it at all.

Unfortunately, compilation failures for C tests run by the
machinery in c.exp are currently just marked "unresolved",
in contrast to C and assembler tests run by calling
run_sim_test.

The interaction of calling with the full program-path vs.
use of --sysroot exposes a consistency problem: when
--sysroot is used, argv[0] isn't the path by which the
program can find itself.  It's undecided whether argv[0] for
the program running in the simulator should be edited
(related to the naked argument to the simulator before
passing on to the simulated program) to remove a leading
--sysroot.  Either way, such a change would be out of scope
for this commit.

	* c/stat3.c (mybasename): New macro.  Use it instead of basename.
	* c/openpf1.c: Correct basename-related change and update related
	comment.
2022-02-14 23:53:13 +01:00
Hans-Peter Nilsson
6f62dbfb12 sim/testsuite/cris: As applicable, require simoption --cris-900000xx
Apply the new run_sim_test option "require" as in "#require
simoption --cris-900000xx" for all tests using that option.
This allows a clean test-suite-run for a build with
--disable-sim-hardware, where that option is not supported,
by skipping those tests as "untested".

sim/testsuite/cris:
	* asm/io1.ms, asm/io2.ms, asm/io3.ms, asm/io6.ms,
	asm/io7.ms: Call "#require: simoption --cris-900000xx".
2022-02-14 23:50:55 +01:00
Hans-Peter Nilsson
81064d7abc sim/testsuite: Support "requires: simoption <--name-of-option>"
Simulator features can be present or not, typically
depending on different-valued configure options, like
--enable-sim-hardware[=off|=on].  To avoid failures in
test-suite-runs when testing such configurations, a new
predicate is needed, as neither "target", "progos" nor
"mach" fits cleanly.

The immediate need was to check for presence of a simulator
option, but rather than a specialized "requires-simoption:"
predicate I thought I'd handle the general (parametrized)
need, so here's a generic predicate machinery and a (first)
predicate to use together with it; checking whether a
particular option is supported, by looking at "run --help"
output.  This was inspired by the check_effective_target_
machinery in the gcc test-suite.

Multiple "requires: <requirement> <parameter>" form a list of
predicates (with parameters), to be used as a conjunction.

sim/testsuite:
	* lib/sim-defs.exp (sim_check_requires_simoption): New function.
	(run_sim_test): Support "requires: <requirement> <parameter>".
2022-02-14 23:50:48 +01:00
Hans-Peter Nilsson
46f238477f sim/testsuite/cris/hw/rv-n-cris/irq1.ms: Disable due to randomness
For reasons that remain largely to be investigated (besides
the apparent lack of synchronization between two processes),
this test fails randomly, with two different sets of common
outputs.  Curiously, that doesn't happen for the other
similar tests.  There's a comment that mentions this, though
that doesn't make it a sustainable part of a test-suite.
(Known-blinking tests should be disabled until fixed.)

sim/testsuite/cris:
	* hw/rv-n-cris/irq1.ms: Disable by use of a never-matched
	"progos" value.
2022-02-14 23:50:42 +01:00
Hans-Peter Nilsson
56ba3848dc sim/testsuite/cris/c: Use -sim3 but only for newlib targets
Commit a39487c668 "sim: cris: use -sim with C tests for cris-elf
targets" caused " -sim" to be appended to CFLAGS_FOR_TARGET for
cris*-*-elf, where testing had until then relied on
"RUNTESTFLAGS=--target_board=cris-sim" being passed when running "make
check-sim", adding the right options.  While "-sim" happens to work,
the baseboard-file cris-sim.exp uses "-sim3" so for consistency use
that instead.

Then commit b42f20d2ac "sim: testsuite: drop most specific istarget
checks" caused " -sim" to be appended for *all* targets, which just
doesn't work.  For example, for crisv32-linux-gnu, that's not a
recognized option and will cause a dejagnu error and further testing
in c.exp will be aborted.

While cris-sim.exp appends "-static" for *-linux-gnu, further changes
in the test-suite have caused "linux"-specific tests to break, so that
part will be tended to separately.

But, save and restore CFLAGS_FOR_TARGET around the modification and
use where needed, to not have the CRIS-specific modification affect a
continuing test-run (possibly for other targets).

sim/testsuite/cris:
	* c/c.exp (CFLAGS_FOR_TARGET): Replace appended option " -sim"
	with " -sim3", but do it conditionally for newlib targets.  Save
	and restore CFLAGS_FOR_TARGET in saved_CFLAGS_FOR_TARGET such
	that it doesn't affect the value of CFLAGS_FOR_TARGET outside
	c.exp.
2022-02-14 23:50:36 +01:00
Hans-Peter Nilsson
3e6dc39ed7 sim/testsuite: Set global_cc_os also when no compiler is found
If we don't set this variable, it doesn't exist, and using "#progos:"
in an assembler-file will cause an error rather than just skipping the
test, viz:

Running /src/sim/testsuite/cris/hw/rv-n-cris/rvc.exp ...
ERROR: tcl error sourcing /src/sim/testsuite/cris/hw/rv-n-cris/rvc.exp.
ERROR: can't read "global_cc_os": no such variable
    while executing
"if { $opts(progos) != "" && $opts(progos) != $global_cc_os } {
	untested $subdir/$name
	return
    }"
    (procedure "run_sim_test" line 102)

Neither the commit introducing progos, nor the top comment
in run_sim_test, mentions progos as intended only for C
tests, or that its use must be gated on $global_cc_works !=
0, so (not) setting it in the no-working-compiler path seems
just overlooked.

Allowing it to be used for assembler tests makes it usable
for e.g. an always-false predicate and in expressions in
.exp files without gating on $global_cc_works != 0.

With this patch, global_cc_os is set to "", just as for "unknown OS".

    sim/testsuite:
	* lib/sim-defs.exp (sim_init_toolchain): Set global_cc_os also when
	no working target C compiler is found.
2022-02-14 23:50:29 +01:00
Hans-Peter Nilsson
3293b4f667 sim/testsuite/cris: Assembler testcase for PRIx32 usage bug
Several C test-cases exposed the bug, but let's have one for
people who test using just the assembler and linker.

	* asm/endmem1.ms: New test.
2022-02-14 23:50:24 +01:00
Faraz Shahbazker
06c441ccef sim: mips: Add simulator support for mips32r6/mips64r6
2022-02-01  Ali Lown  <ali.lown@imgtec.com>
	    Andrew Bennett  <andrew.bennett@imgtec.com>
	    Dragan Mladjenovic  <dragan.mladjenovic@rt-rk.com>
	    Faraz Shahbazker  <fshahbazker@wavecomp.com>

sim/common/ChangeLog:
	* sim-bits.h (EXTEND9, EXTEND18 ,EXTEND19, EXTEND21,
	EXTEND26): New macros.

sim/mips/ChangeLog:
	* Makefile.in (IGEN_INCLUDE): Add mips3264r6.igen.
	* configure: Regenerate.
	* configure.ac: Support mipsisa32r6 and mipsisa64r6.
	(sim_engine_run): Pick simulator model from processor specified
	in e_flags.
	* cp1.c (value_fpr): Handle fmt_dc32.
	(fp_unary, fp_binary): Zero initialize locals.
	(update_fcsr, fp_classify, fp_rint, fp_r6_cmp, inner_fmac,
	fp_fmac, fp_min, fp_max, fp_mina, fp_maxa, fp_fmadd, fp_fmsub):
	New functions.
	(sim_fpu_class_mips_mapping): New.
	* cp1.h (fcsr_ABS2008_mask, fcsr_ABS2008_shift): New define.
	* interp.c (MIPSR6_P): New.
	(load_word): Allow unaligned memory access for MIPSR6.
	* micromips.igen (sc, scd): Adapt to new do_sc* helper signature.
	* mips.igen: Add *r6 models.
	(signal_if_cti, forbiddenslot32): New helpers.
	(delayslot32): Use signal_if_cti.
	(do_sc, do_scd); Add store_ll_bit parameter.
	(sc, scd): Adapt to previous change.
	(nal, beq, bal): New definitions for *r6.
	(sll): Split nop and ssnop cases into ...
	(nop, ssnop): New definitions.
	(loadstore_ea): Use the 32-bit compatibility adressing.
	(cache): Split logic into ...
	(do_cache): New helper.
	(check_fpu): Select IEEE 754-2008 mode for R6.
	(not_word_value, unpredictable, check_mt_hilo, check_mf_hilo,
	check_multi_hilo, check_div_hilo, check_u64, do_dmfc1b, add,
	li, addu, and, andi, bgez, bgtz, blez, bltz, bne, break, dadd,
	daddiu, daddu, dror, dror32, drorv, dsll, dsll32, dsllv, dsra,
	dsra32, dsrav, dsrl, dsrl32, dsub, dsubu, j, jal, jalr,
	jalr.hb, lb, lbu, ld, lh, lhu, lui, lw, lwu, nor, or, ori, ror,
	rorv, sb, sd, sh, sll, sllv, slt, slti, sltiu, sltu, sra, srav,
	srl, srlv, sub, subu, sw, sync, syscall, teq, tge, tgeu, tlt,
	tltu, tne, xor, xori, check_fmt_p, do_load_double,
	do_store_double, abs.FMT, add.FMT, ceil.l.FMT, ceil.w.FMT,
	cfc1, ctc1, cvt.d.FMT, cvt.l.FMT, cvt.w.FMT, div.FMT, dfmc1,
	dmtc1, floor.l.FMT, floor.w.FMT, ldc1, lwc1, mfc1, mov.FMT,
	mtc1, mul.FMT, recip.FMT, round.l.FMT, round.w.FMT, rsqrt.FMT,
	sdc1, sqrt.FMT, sub.FMT, swc1, trunc.l.FMT, trunc.w.FMT, bc0f,
	bc0fl, bc0t, bc0tl, dmfc0, dmtc0, eret, mfc0, mtc0, cop, tlbp,
	tlbr, tlbwi, tlbwr): Enable on *r6 models.
	* mips3264r2.igen (dext, dextm, dextu, di, dins, dinsm, dinsu,
	dsbh, dshd, ei, ext, mfhc1, mthc1, ins, seb, seh, synci, rdhwr,
	wsbh): Likewise.
	* mips3264r6.igen: New file.
	* sim-main.h (FP_formats): Add fmt_dc32.
	(FORBIDDEN_SLOT): New macros.
	(simFORBIDDENSLOT, FP_R6CMP_*, FP_R6CLASS_*): New defines.
	(fp_r6_cmp, fp_classify, fp_rint, fp_min, fp_max, fp_mina,
	fp_maxa, fp_fmadd, fp_fmsub): New declarations.
	(R6Compare, Classify, RoundToIntegralExact, Min, Max, MinA,
	MaxA, FusedMultiplyAdd, FusedMultiplySub): New macros. Wrapping
	previous declarations.

sim/testsuite/mips/ChangeLog:
	* basic.exp: Add r6-*.s tests.
	(run_r6_removed_test): New function.
	(run_endian_tests): New function.
	* hilo-hazard-3.s: Skip for mips*r6.
	* r2-fpu.s: New test.
	* r6-64.s: New test.
	* r6-branch.s: New test.
	* r6-forbidden.s: New test.
	* r6-fpu.s: New test.
	* r6-llsc-dp.s: New test.
	* r6-llsc-wp.s: New test.
	* r6-removed.csv: New test.
	* r6-removed.s: New test.
	* r6.s: New test.
	* utils-r6.inc: New inc.
2022-02-04 19:37:26 -05:00
Mike Frysinger
39a5fdbc65 sim: testsuite: migrate to standard uintXX_t types
This old code setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.
2022-01-06 01:17:38 -05:00
Joel Brobecker
4a94e36819 Automatic Copyright Year update after running gdb/copyright.py
This commit brings all the changes made by running gdb/copyright.py
as per GDB's Start of New Year Procedure.

For the avoidance of doubt, all changes in this commits were
performed by the script.
2022-01-01 19:13:23 +04:00
Mike Frysinger
de8a2781a5 sim: use ## for automake comments
The ## marker tells automake to not include the comment in its
generated output, so use that in most places where the comment
only makes sense in the inputs.
2021-12-09 01:40:28 -05:00
Mike Frysinger
3daaa003d2 sim: frv: split up testsuite a bit
Running frv's allinsn in serial is quite slow due to the sheer number
of tests it contains.  By splitting it up and running in parallel, the
execution time on my system goes from ~100sec to ~60sec.
2021-12-04 12:52:35 -05:00
Mike Frysinger
b42f20d2ac sim: testsuite: drop most specific istarget checks
We'll rely on the toolchain probing to determine whether each arch's
tests can be run rather the current configure target.  This allows
testing all of the ports in a multitarget configuration.

For now, we don't reformat the files entirely to make it easier to
review, and in case we need to make adjustments.  Once this feels
like it's stable, we can flatten the code a bit by removing the if
statement entirely.
2021-11-28 21:55:16 -05:00
Mike Frysinger
804de1faf4 sim: testsuite: support parallel execution
Break up the dejagnu logic so that we can parallelize the testsuite.
This takes a page from gcc & gdb where each .exp is run in isolation
instead of in serial.

For most targets, this doesn't make much of a difference as they only
have a single .exp.  A few (like cris & frv) have multiple .exp though
and will see a bit of a speed up.

The real gain is when testing a multitarget build.  This way we can
run all the targets in parallel and cut the execution time a bit.
On my system, it goes from ~155sec to ~100sec.

We can gain further speedups by splitting up some of the larger .exp
files into smaller groups.  We'll do that in a followup though.
2021-11-28 21:55:15 -05:00
Mike Frysinger
7a259895bb sim: testsuite: expand arch specific toolchain settings
Leverage the new per-port toolchain settings to initialize the env
for eeach set of tests.  This allows us to run all the tests in a
multitarget build if the user sets up the vars.  If they don't, we
can still skip all the tests.
2021-11-28 21:55:15 -05:00
Mike Frysinger
8996c21067 sim: testsuite: setup per-port toolchain settings for multitarget build
Gas does not support multitarget builds -- it still only supports
a single input & output format.  ld is a bit better, but requires
manual flags to select the right output.  This makes it impossible
to run the complete testsuite in a multitarget build.

To address this limitation, create a suite of FOR_TARGET variables
so these can be set to precompiled as & ld programs.  It requires
a bit of setup ahead of time, but it's a one-time cost, and makes
running the full testsuite at once much easier.
2021-11-28 21:55:15 -05:00
Mike Frysinger
6916d9e65c sim: testsuite: add dedicated flag for init toolchain tests
As we setup more reliable CC_FOR_TARGET variables for each target, the
bfin way of overriding it to stuff custom CFLAGS doesn't scale well.
Add a dedicated CFLAGS_FOR_TARGET_init setting that each set of tests
can setup if they want to add custom options.
2021-11-27 03:09:57 -05:00
Mike Frysinger
2b9c7c262e sim: testsuite: clean up arch specific toolchain settings
In a multitarget build, we process all targets in order, so make sure
the toolchain settings from one don't leak into the next.
2021-11-27 01:27:17 -05:00
Mike Frysinger
8613fa4c49 sim: cris: always search for local rvdummy tool
If the board info sets the sim to a basename that is found via $PATH
(which is the default dejagnu behavior), the logic here to use its
dirname to find rvdummy fails because it looks for `./rvdummy`.  So
switch it to always use the local build of rvdummy which is the one
we want to be testing against in the first place.

If we get a request for testing against a different setup, we can
figure out & document the needs at that point, and then setup some
config knobs to control it.
2021-11-27 01:26:41 -05:00
Mike Frysinger
429a55b865 sim: testsuite: fix bits-gen EXEEXT handling
Add missing $(EXEEXT) to dependencies on bits-gen.  These are actually
build-only tools, but automake doesn't allow for build & host tools, so
the rules are re-using EXEEXT.
2021-11-26 20:41:44 -05:00
Mike Frysinger
1214c97666 sim: testsuite: initial support for OS-specific tests
We usually test against the newlib/libgloss environment, but for a
few ports that also support Linux apps, we want to test that logic
too.  A lot of the C code is written such that it works with either
newlib/libgloss or glibc/linux toolchains, but we have some tests
that end up being Linux-specific.  Cris has been using the target
tuple as a rough proxy for this (where cris*-*-elf is assumed to be
newlib/libgloss, and everything else is glibc/linux), but that is a
bit too rough, and it doesn't work in a multitarget build.

So lets create a few stub files that we can do compile tests with
to detect the different setups, and then let tests declare which
one they require (if they require any at all).
2021-11-26 20:06:55 -05:00
Mike Frysinger
264dcc17cc sim: testsuite: unify basic C compiler checks
Both bfin & cris ports test the C compiler to see if it works, but in
their own way.  Unify the checks in the common code so we can leverage
them in more ports in the future, and collapse the bfin & cris code.
2021-11-26 19:51:15 -05:00
Mike Frysinger
c0d6a6e582 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.
2021-11-26 19:48:05 -05:00
Mike Frysinger
4c721b266f sim: cris: fix testsuite hang when sim is missing
If the cris sim hasn't been built yet, trying to run its testsuite
will hang indefinitely.  The common sim APIs already have this, so
copy it over to the cris forks of the test+run functions.
2021-11-26 19:37:31 -05:00
Mike Frysinger
e1e1ae6e9b sim: testsuite: fix objdir handling
The tests assume that the cwd is the objdir directory and write its
intermediates to there all the time.  When using runtest's --objdir
setting though, this puts the files in the wrong place.  This isn't
a big problem currently as we never change --objdir, but in order to
support parallel test execution, we're going to start setting that
option, so clean up the code ahead of time.

We also have to tweak some of the cris tests which were making
assumptions about the argv[0] value.
2021-11-26 19:27:21 -05:00
Mike Frysinger
03c0f9c205 sim: testsuite: rename global_sim_options to SIMFLAGS_FOR_TARGET
Now that all the other toolchain settings have been renamed to match
the dejagnu settings of XXX_FOR_TARGET, rename global_sim_options to
SIMFLAGS_FOR_TARGET too.
2021-11-26 19:17:59 -05:00
Mike Frysinger
d07ada6f5a sim: testsuite: replace global_ld_options with LDFLAGS_FOR_TARGET
Only a few tests actually use global_ld_options, but we can replace the
sim-specific settings with the dejagnu common LDFLAGS_FOR_TARGET and get
the same result.
2021-11-26 19:03:13 -05:00
Mike Frysinger
0e87783408 sim: testsuite: replace global_as_options with ASFLAGS_FOR_TARGET
Only a few tests actually use global_as_options, but we can replace the
sim-specific settings with the dejagnu common ASFLAGS_FOR_TARGET and get
the same result.
2021-11-26 15:07:04 -05:00
Mike Frysinger
c099934746 sim: testsuite: drop unused global_cc_options
Nothing in the testsuite is using this setting, so let's drop it.
Any code that wants to set compiler flags can use CFLAGS_FOR_TARGET
instead to get the same effect.
2021-11-26 13:28:15 -05:00
Mike Frysinger
aa1b9bdef2 sim: testsuite: punt unused toolchain variables
These haven't been used in over 20 years.  The sim testsuite used to
run these tools itself directly, but back in ~1999 it switched to the
dejagnu helpers (e.g. target_assemble & target_link), and the dejagnu
logic only utilizes XXX_FOR_TARGET variables.  Punt them here to avoid
confusion with dead code.
2021-11-26 13:27:34 -05:00
Mike Frysinger
bbda248c50 sim: v850: fix cpu_option testsuite handling
The v850 testsuite code has been testing the $opt variable, but this
was never actually set anywhere globally or v850-specific.  Instead,
this was a random variable leaking out of the sh testsuite code.  As
far as I can tell, it has always been this way.  That means the code
only ever tested the v850 cpu target (which is the default).

This failure can be easily seen in practice by running the v850 code
in isolation and seeing it crash:
$ runtest v850/allinsns.exp
...
Running target unix
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
Using ../../../sim/testsuite/config/default.exp as tool-and-target-specific interface file.
WARNING: Assuming target board is the local machine (which is probably wrong).
You may need to set your DEJAGNU environment variable.
Running ../../../sim/testsuite/v850/allinsns.exp ...
ERROR: tcl error sourcing ../../../sim/testsuite/v850/allinsns.exp.
ERROR: tcl error code TCL LOOKUP VARNAME opt
ERROR: can't read "opt": no such variable
    while executing
"switch -regexp -- $opt {

Backing up a bit, the reason for this logic in the first place is
because the common sim testsuite code makes an assumption about the
assembler options with cpu_option -- the option and its value are
always separated by an =.  This is not the case with v850.  So tweak
the core sim logic a bit to support omitting the = so that we can
switch v850 to the standard all_machs setting and avoid opt entirely.
2021-11-20 23:13:50 -05:00
Mike Frysinger
6e3e76d17b sim: bfin: fix short --env usage in testsuite
Now that we have more than one option that matches "--env", the test
config here doesn't work.  Use the explicit --environment.
2021-11-19 21:27:50 -05:00