Skip to content

Commit 1c04811

Browse files
committed
Merge branch 'eyraud/gnaamp' into 'master'
AAMP: copy the runtime to the test directory See merge request eng/das/cov/gnatcoverage!844 As AAMP does not support library project, always copy the instrumentation runtime to the test directory as building an instrumented program builds it. For eng/das/cov/gnatcoverage#256
2 parents 381d1cb + 606fe97 commit 1c04811

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

testsuite/SCOV/instr.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import os.path
44
import re
5+
import shutil
56

6-
from e3.fs import mkdir
7+
from e3.fs import mkdir, sync_tree
78

89
from SUITE.context import thistest
910
from SUITE.control import env
@@ -344,3 +345,21 @@ def maybe_relocate_binaries(object_dir, exe_dir, mains):
344345
if "aamp" in env.target.platform:
345346
for main in mains:
346347
copy_to_dir(object_dir, exe_dir, main)
348+
349+
350+
def maybe_copy_runtime(test_dir):
351+
"""
352+
Copy the Ada instrumentation runtime in test_dir for the AAMP target.
353+
"""
354+
if "aamp" in env.target.platform:
355+
rts_path = os.path.join(
356+
os.path.dirname(shutil.which("gnatcov")),
357+
"..",
358+
"share",
359+
"gnatcoverage",
360+
"gnatcov_ada_rts",
361+
)
362+
rts_dest_path = os.path.join(test_dir, "rts")
363+
mkdir(rts_dest_path)
364+
sync_tree(rts_path, rts_dest_path)
365+
env.add_search_path(env_var="GPR_PROJECT_PATH", path=rts_dest_path)

testsuite/SCOV/internals/driver.py

Lines changed: 6 additions & 0 deletions
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_copy_runtime,
3536
maybe_relocate_binaries,
3637
xcov_convert_base64,
3738
xcov_instrument,
@@ -1484,6 +1485,11 @@ def mode_build(self):
14841485
subdirs = None
14851486
instrument_gprsw = GPRswitches(root_project=self.gpr)
14861487

1488+
# The AAMP target does not support library project and requires
1489+
# rebuilding the instrumentation runtime: copy it in the test
1490+
# directory.
1491+
maybe_copy_runtime(os.getcwd())
1492+
14871493
# Instrument now, requesting the propagation of instrumentation
14881494
# issues on the test status. Note that we expect this to include
14891495
# a check on instrumentation warnings.

testsuite/SCOV/minicheck.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from SCOV.instr import (
1919
default_dump_channel,
20+
maybe_copy_runtime,
2021
maybe_relocate_binaries,
2122
xcov_convert_base64,
2223
xcov_instrument,
@@ -267,6 +268,11 @@ def gprbuild_wrapper(root_project):
267268
if dump_channel == "auto":
268269
dump_channel = default_dump_channel()
269270

271+
# The AAMP target does not support library project and requires
272+
# rebuilding the instrumentation runtime: copy it in the test
273+
# directory.
274+
maybe_copy_runtime(os.getcwd())
275+
270276
# Instrument the project and build the result
271277
extra_instr_args = cov_or_instr_args + list(extra_instr_args or [])
272278
xcov_instrument(

tools/gnatcov/ada-rts/gnatcov_rts-traces-output.adb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,16 @@ package body GNATcov_RTS.Traces.Output is
310310

311311
declare
312312
Timestamp : Interfaces.Unsigned_64 := Exec_Date;
313-
Bytes : Uint8_Array := (1 => 0);
313+
Bytes : Uint8_Array (1 .. 8);
314+
Bytes_Str : String (1 .. 8);
315+
for Bytes_Str'Address use Bytes'Address;
316+
pragma Import (Ada, Bytes_Str);
314317
begin
315318
for I in 1 .. 8 loop
316-
Bytes (1) := Interfaces.Unsigned_8 (Timestamp mod 8);
319+
Bytes (I) := Interfaces.Unsigned_8 (Timestamp mod 8);
317320
Timestamp := Shift_Right (Timestamp, 8);
318-
Write_Bytes (Output, Bytes);
319321
end loop;
322+
Write_Info (Output, Info_Exec_Date, Bytes_Str);
320323
end;
321324

322325
Write_Info (Output, Info_User_Data, User_Data);

0 commit comments

Comments
 (0)