Skip to content

Commit 283e584

Browse files
committed
Merge branch 'eyraud/test_256' into 'master'
Adapt the testsuite to work with AAMP See merge request eng/das/cov/gnatcoverage!538 The testsuite needs some adaptation fixes to work with the AAMP target. Notably, add the support to execute a main through the facade simulator. For eng/das/cov/gnatcoverage#256
2 parents 674626c + 21c170b commit 283e584

File tree

18 files changed

+290
-45
lines changed

18 files changed

+290
-45
lines changed

testsuite/SCOV/instr.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from e3.fs import mkdir
77

88
from SUITE.context import thistest
9-
from SUITE.cutils import contents_of, ext, indent
9+
from SUITE.control import env
10+
from SUITE.cutils import contents_of, copy_to_dir, ext, indent
1011
from SUITE.tutils import RUNTIME_INFO, GNATCOV_INFO, locate_gpr_file, xcov
1112

1213

@@ -356,3 +357,23 @@ def available_ada_dump_triggers():
356357
return ["main-end", "ravenscar-task-termination"]
357358
else:
358359
return ["main-end"]
360+
361+
362+
def maybe_relocate_binaries(object_dir, exe_dir, mains):
363+
"""
364+
Relocate binaries produced in the object_dir to the exe_dir for the AAMP
365+
target.
366+
367+
:param object_dir: object directory of the main project.
368+
:param exe_dir: executable directory of the main project.
369+
:param mains: main filenames.
370+
"""
371+
# The GNAAMP linker disregards the full name passed to the -o switch but
372+
# only picks the simple name. Thus, the executable ends up in the object
373+
# directory.
374+
#
375+
# Copy it to the executable directory so that the rest of the testsuite
376+
# can assume executables are always there.
377+
if "aamp" in env.target.platform:
378+
for main in mains:
379+
copy_to_dir(object_dir, exe_dir, main)

testsuite/SCOV/internals/driver.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
add_dumper_lch_hook,
3333
default_dump_channel,
3434
default_dump_trigger,
35+
maybe_relocate_binaries,
3536
xcov_convert_base64,
3637
xcov_instrument,
3738
)
@@ -625,12 +626,13 @@ def run(self):
625626
this_depth = thistest.depth + 1 if self.covctl else thistest.depth
626627

627628
self.gpr_obj_dir = "obj"
629+
self.gpr_exe_dir = self.abdir(attribute=True)
628630
self.gpr = gprfor(
629631
mains=self.drivers,
630632
prjid="gen",
631633
objdir=self.gpr_obj_dir,
632634
srcdirs=["../" * n + "src" for n in range(1, this_depth)],
633-
exedir=self.abdir(attribute=True),
635+
exedir=self.gpr_exe_dir,
634636
main_cargs="-fno-inline",
635637
deps=self.covctl.deps if self.covctl else [],
636638
extra=self.covctl.gpr() if self.covctl else "",
@@ -1533,6 +1535,9 @@ def mode_build(self):
15331535
extracargs=self.extracargs,
15341536
gargs=self.common_build_gargs() + ["--src-subdirs=gnatcov-instr"],
15351537
)
1538+
maybe_relocate_binaries(
1539+
self.gpr_obj_dir, self.gpr_exe_dir, [exename_for(self.main())]
1540+
)
15361541

15371542
def mode_execute(self, main):
15381543
register_failure = not self.testcase.expect_failures

testsuite/SCOV/minicheck.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717

1818
from SCOV.instr import (
1919
default_dump_channel,
20+
maybe_relocate_binaries,
2021
xcov_convert_base64,
2122
xcov_instrument,
2223
)
2324
from SUITE.cutils import contents_of, indent
2425
from SUITE.tutils import (
26+
exename_for,
2527
exepath_to,
2628
gprbuild,
2729
run_cov_program,
@@ -353,6 +355,8 @@ def gprbuild_wrapper(root_project):
353355
# multiple traces in the current directory.
354356
for m in mains:
355357
rm(srctrace_pattern_for(m, is_manual, manual_prj_name))
358+
# Callback to run for each instrumented main
359+
maybe_relocate_binaries(gpr_obj_dir, gpr_exe_dir, [exename_for(m)])
356360

357361
patterns = set()
358362
trace_files = []

testsuite/SUITE/control.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,13 @@ def __init__(self, runtime_name=None):
257257
self.has_exception_propagation = True
258258
self.discrs = []
259259

260-
if not self.runtime_name:
260+
# Set specific scenario variables to always pass to any project loading
261+
# command (gnatcov <command> -P or gprbuild / gprinstall)
262+
self.gpr_scenario_vars = []
263+
264+
if "aamp" in self.runtime_name:
265+
self.gpr_scenario_vars = ["-XLIBRARY_SUPPORT=no"]
266+
elif not self.runtime_name:
261267
self.has_full_runtime = True
262268
self.discrs = ["RTS_FULL"]
263269
elif "embedded" in self.runtime_name:
@@ -349,6 +355,8 @@ def __init__(self, exeext, partiallinks, to_platform_specific_symbol=None):
349355
),
350356
# x86_64-windows targets
351357
"x86_64.*mingw": TargetInfo(exeext=".exe", partiallinks=False),
358+
# AAMP target
359+
"aamp": TargetInfo(exeext=".axe", partiallinks=False),
352360
# default
353361
".": TargetInfo(exeext="", partiallinks=False),
354362
}

testsuite/SUITE/cutils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import sys
1212
import tempfile
1313

14-
from e3.fs import mkdir
14+
from e3.fs import cp, mkdir
1515
from e3.os.fs import cd, which
1616
from e3.os.process import Run
1717

@@ -309,3 +309,14 @@ def multi_range(*args, minus=None):
309309
class Identifier:
310310
def __init__(self, name):
311311
self.name = name
312+
313+
314+
def copy_to_dir(orig_dir, target_dir, filename):
315+
"""
316+
Copy filename from orig_dir to target_dir.
317+
"""
318+
if os.path.abspath(orig_dir) != os.path.abspath(target_dir):
319+
cp(
320+
os.path.join(orig_dir, filename),
321+
os.path.join(target_dir, filename),
322+
)

testsuite/SUITE/tutils.py

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from SUITE.cutils import (
4141
FatalError,
4242
contents_of,
43+
list_to_file,
4344
text_to_file,
4445
to_list,
4546
unhandled_exception_in,
@@ -264,11 +265,9 @@ def gpr_common_args(project, auto_config_args=True):
264265
"""
265266
gproptions = []
266267

267-
gproptions.append(
268-
# verbose mode for verifiability in qualif mode.
269-
# quiet mode for performance (less io) otherwise.
270-
"-v" if thistest.options.qualif_level else "-q",
271-
)
268+
# If running in qualif mode, run with the verbose switch for verifiability
269+
if thistest.options.qualif_level:
270+
gproptions.append("-v")
272271
if auto_config_args:
273272
gproptions.append(
274273
"--config={}".format(os.path.join(ROOT_DIR, BUILDER.SUITE_CGPR))
@@ -290,7 +289,8 @@ def gpr_common_args(project, auto_config_args=True):
290289
):
291290
gproptions.append("-XLOADER=RAM")
292291

293-
return gproptions
292+
# Add runtime specific scenario variables
293+
return gproptions + RUNTIME_INFO.gpr_scenario_vars
294294

295295

296296
def gprbuild(
@@ -729,26 +729,28 @@ def xcov_suite_args(
729729
or any(arg.startswith("-P") for arg in covargs)
730730
)
731731

732+
result = (
733+
gpr_common_args(project=None, auto_config_args=auto_config_args)
734+
if project_handling_enabled
735+
else []
736+
)
737+
732738
# If --config is asked and project handling is involved, pass it and stop
733739
# there. If there is a board, it must be described in the project file
734740
# (gnatcov's -P argument).
735741
if auto_config_args and project_handling_enabled:
736-
return [
737-
"--config={}".format(os.path.join(ROOT_DIR, BUILDER.SUITE_CGPR))
738-
]
742+
return result
739743

740-
# Nothing to do if the caller does not want automatic --target/--RTS
744+
# Nothing to add if the caller does not want automatic --target/--RTS
741745
# arguments.
742746
if not auto_target_args:
743-
return []
747+
return result
744748

745749
# Otherwise, handle target and board information.
746750
#
747751
# Remember that the testsuite determines the target from the machine that
748752
# hosts the testsuite and from its own --host/--build/--target arguments...
749-
750-
result = []
751-
753+
#
752754
# If we have a specific target board specified with --board, use that:
753755
#
754756
# --target=p55-elf --board=iSystem-5554
@@ -1015,6 +1017,37 @@ def run_cov_program(
10151017
exec_args = exec_args or []
10161018
inp = None
10171019
use_pycross = False
1020+
if thistest.options.target:
1021+
# If we are testing for AAMP, use the facade simulator. It expects a
1022+
# configuration file (facade.cfg) in the executable dir, and the
1023+
# executable must be run through an executable.sod file, which sets
1024+
# up the simulator environment. This .sod file should be in the same
1025+
# directory as the executable.
1026+
if "aamp" in control.env.target.platform:
1027+
args.append("dosfsod.exe")
1028+
list_to_file(
1029+
[
1030+
"sw tx on",
1031+
'$TEXTIO = ""',
1032+
"switch batch on",
1033+
"fill 0000..ffff 0",
1034+
"load " + executable,
1035+
"go",
1036+
"halt",
1037+
],
1038+
"test.sod",
1039+
)
1040+
args.append("@test.sod")
1041+
cp(os.path.join(ROOT_DIR, "facade.cfg"), "facade.cfg")
1042+
args.extend(exec_args)
1043+
out = cmdrun(
1044+
args,
1045+
out=out,
1046+
env=env,
1047+
register_failure=register_failure,
1048+
for_pgm=True,
1049+
)
1050+
return out
10181051

10191052
# If we are in a cross configuration, run the program using run-cross2
10201053
if thistest.options.target and thistest.env.target.platform != "c":

testsuite/facade.cfg

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[FACADE] ## *MUST* be first line of file
2+
## switches must begin in column 1
3+
## no spaces allowed before the "="
4+
## see config.h for valid switches and types
5+
6+
[T5] ## test equipment section
7+
BASE_ADDR= 0000 # T5 base address (hex)
8+
DHC_BASE_ADDR= 00000 # deep history card base address (hex)
9+
BUS_TIMEOUT= 10 # milliseconds (decimal)
10+
XFR_TIMEOUT= 10 # milliseconds (decimal)
11+
CONS_TIMEOUT= 10 # milliseconds (decimal)
12+
T5_RESET_HOLD= 8 # target clock ticks (decimal)
13+
#TARGET_RESET_HOLD= 40 # target clock ticks (decimal)
14+
#POD_FREQ_SELECT= 20 # pod freq select for AAMP5vr1 pods
15+
# target freq must be in one of following ranges:
16+
# 15-30 MHz (default)
17+
# 30-50 MHz
18+
# 5-15 MHz
19+
20+
[DBG] ## debug engine section
21+
SHOW_PC= 1 # Update the PC in the console window
22+
23+
[GUI] ## GUI section
24+
SCREEN_BUFSIZE= 500 # number of lines saved in console window (250-2500)
25+
MAX_SRC_WIN= 1 # specifies the maximum number of source windows
26+
# open at any given time (must be 1, 2, or 3)
27+
TITLE=v3.5 # String to use in the Title bar after Facade
28+
#TMPPATH=C:/TMP # specifies the directory for scratch files
29+
# (history and memory buffers)
30+
# default: working directory specified at installation

testsuite/tests/U211-014-setup/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def check_full(
218218
)
219219
p = gprbuild(
220220
mixed_prj.project_file,
221-
gargs=["--src-subdirs=gnatcov-instr"],
221+
gargs=["--src-subdirs=gnatcov-instr", "-q"],
222222
trace_mode="src",
223223
runtime_project=rt_prj,
224224
out=log_file,

testsuite/tests/ext_annotations/gen/buf_dump/c_only/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
mains=["main"],
5858
extra_instr_args=[f"--external-annotations={annotations}"],
5959
extra_coverage_args=["-axcov"],
60+
extra_gprbuild_args=["-q"],
6061
dump_trigger="manual",
6162
manual_prj_name="main",
6263
tolerate_instrument_messages=instr_warning,

testsuite/tests/ext_annotations/gen/buf_dump/cpp_only/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
mains=["main"],
5858
extra_instr_args=[f"--external-annotations={annotations}"],
5959
extra_coverage_args=["-axcov"],
60+
extra_gprbuild_args=["-q"],
6061
dump_trigger="manual",
6162
manual_prj_name="main",
6263
tolerate_instrument_messages=instr_warning,

testsuite/tests/instr-cov/checks_and_warnings/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
extra_coverage_args=["-axcov", "--output-dir=xcov"],
2525
gpr_obj_dir=obj_dir,
2626
gpr_exe_dir=obj_dir,
27+
extra_gprbuild_args=["-q"],
2728
extra_gprbuild_cargs=["-gnatwae"],
2829
check_gprbuild_output=True,
2930
trace_mode="src",

testsuite/tests/instr-cov/manual-dump/c_only/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
covlevel="stmt",
4646
mains=["main"],
4747
extra_coverage_args=["-axcov"],
48+
extra_gprbuild_args=["-q"],
4849
dump_trigger="manual",
4950
manual_prj_name="main",
5051
tolerate_instrument_messages=instr_warning,

testsuite/tests/instr-cov/manual-dump/cpp_only/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
covlevel="stmt",
4646
mains=["main"],
4747
extra_coverage_args=["-axcov"],
48+
extra_gprbuild_args=["-q"],
4849
dump_trigger="manual",
4950
manual_prj_name="main",
5051
tolerate_instrument_messages=instr_warning,

0 commit comments

Comments
 (0)