[tools] Fix merging sancov files from multiple test attempts
This differentiates sancov files from several runs of the same test. This situation happens when a test fails and is rerun for flake checking. BUG=v8:5502 Review-Url: https://codereview.chromium.org/2414093003 Cr-Commit-Position: refs/heads/master@{#40304}
This commit is contained in:
parent
0b74984156
commit
7d2c514d84
@ -7,7 +7,7 @@
|
||||
|
||||
When merging test runner output, the sancov files are expected
|
||||
to be located in one directory with the file-name pattern:
|
||||
<executable name>.test.<id>.sancov
|
||||
<executable name>.test.<id>.<attempt>.sancov
|
||||
|
||||
For each executable, this script writes a new file:
|
||||
<executable name>.result.sancov
|
||||
@ -48,7 +48,7 @@ CPUS = cpu_count()
|
||||
|
||||
# Regexp to find sancov file as output by the v8 test runner. Also grabs the
|
||||
# executable name in group 1.
|
||||
SANCOV_FILE_RE = re.compile(r'^(.*)\.test\.\d+\.sancov$')
|
||||
SANCOV_FILE_RE = re.compile(r'^(.*)\.test\.\d+\.\d+\.sancov$')
|
||||
|
||||
# Regexp to find sancov result files as returned from swarming.
|
||||
SANCOV_RESULTS_FILE_RE = re.compile(r'^.*\.result\.sancov$')
|
||||
|
@ -11,19 +11,19 @@ import sancov_merger
|
||||
# executable name -> file list.
|
||||
FILE_MAP = {
|
||||
'd8': [
|
||||
'd8.test.1.sancov',
|
||||
'd8.test.2.sancov',
|
||||
'd8.test.3.sancov',
|
||||
'd8.test.4.sancov',
|
||||
'd8.test.5.sancov',
|
||||
'd8.test.6.sancov',
|
||||
'd8.test.7.sancov',
|
||||
'd8.test.1.1.sancov',
|
||||
'd8.test.2.1.sancov',
|
||||
'd8.test.3.1.sancov',
|
||||
'd8.test.4.1.sancov',
|
||||
'd8.test.5.1.sancov',
|
||||
'd8.test.5.2.sancov',
|
||||
'd8.test.6.1.sancov',
|
||||
],
|
||||
'cctest': [
|
||||
'cctest.test.1.sancov',
|
||||
'cctest.test.2.sancov',
|
||||
'cctest.test.3.sancov',
|
||||
'cctest.test.4.sancov',
|
||||
'cctest.test.1.1.sancov',
|
||||
'cctest.test.2.1.sancov',
|
||||
'cctest.test.3.1.sancov',
|
||||
'cctest.test.4.1.sancov',
|
||||
],
|
||||
}
|
||||
|
||||
@ -32,42 +32,42 @@ FILE_MAP = {
|
||||
# (flag, path, executable name, intermediate result index, file list).
|
||||
EXPECTED_INPUTS_2 = [
|
||||
(False, '/some/path', 'cctest', 0, [
|
||||
'cctest.test.1.sancov',
|
||||
'cctest.test.2.sancov']),
|
||||
'cctest.test.1.1.sancov',
|
||||
'cctest.test.2.1.sancov']),
|
||||
(False, '/some/path', 'cctest', 1, [
|
||||
'cctest.test.3.sancov',
|
||||
'cctest.test.4.sancov']),
|
||||
'cctest.test.3.1.sancov',
|
||||
'cctest.test.4.1.sancov']),
|
||||
(False, '/some/path', 'd8', 0, [
|
||||
'd8.test.1.sancov',
|
||||
'd8.test.2.sancov',
|
||||
'd8.test.3.sancov',
|
||||
'd8.test.4.sancov']),
|
||||
'd8.test.1.1.sancov',
|
||||
'd8.test.2.1.sancov',
|
||||
'd8.test.3.1.sancov',
|
||||
'd8.test.4.1.sancov']),
|
||||
(False, '/some/path', 'd8', 1, [
|
||||
'd8.test.5.sancov',
|
||||
'd8.test.6.sancov',
|
||||
'd8.test.7.sancov']),
|
||||
'd8.test.5.1.sancov',
|
||||
'd8.test.5.2.sancov',
|
||||
'd8.test.6.1.sancov']),
|
||||
]
|
||||
|
||||
|
||||
# The same for 4 cpus.
|
||||
EXPECTED_INPUTS_4 = [
|
||||
(True, '/some/path', 'cctest', 0, [
|
||||
'cctest.test.1.sancov',
|
||||
'cctest.test.2.sancov']),
|
||||
'cctest.test.1.1.sancov',
|
||||
'cctest.test.2.1.sancov']),
|
||||
(True, '/some/path', 'cctest', 1, [
|
||||
'cctest.test.3.sancov',
|
||||
'cctest.test.4.sancov']),
|
||||
'cctest.test.3.1.sancov',
|
||||
'cctest.test.4.1.sancov']),
|
||||
(True, '/some/path', 'd8', 0, [
|
||||
'd8.test.1.sancov',
|
||||
'd8.test.2.sancov']),
|
||||
'd8.test.1.1.sancov',
|
||||
'd8.test.2.1.sancov']),
|
||||
(True, '/some/path', 'd8', 1, [
|
||||
'd8.test.3.sancov',
|
||||
'd8.test.4.sancov']),
|
||||
'd8.test.3.1.sancov',
|
||||
'd8.test.4.1.sancov']),
|
||||
(True, '/some/path', 'd8', 2, [
|
||||
'd8.test.5.sancov',
|
||||
'd8.test.6.sancov']),
|
||||
'd8.test.5.1.sancov',
|
||||
'd8.test.5.2.sancov']),
|
||||
(True, '/some/path', 'd8', 3, [
|
||||
'd8.test.7.sancov'])]
|
||||
'd8.test.6.1.sancov'])]
|
||||
|
||||
|
||||
class MergerTests(unittest.TestCase):
|
||||
|
@ -149,8 +149,9 @@ class TestJob(Job):
|
||||
|
||||
Rename files with PIDs to files with unique test IDs, because the number
|
||||
of tests might be higher than pid_max. E.g.:
|
||||
d8.1234.sancov -> d8.test.1.sancov, where 1234 was the process' PID
|
||||
and 1 is the test ID.
|
||||
d8.1234.sancov -> d8.test.42.1.sancov, where 1234 was the process' PID,
|
||||
42 is the test ID and 1 is the attempt (the same test might be rerun on
|
||||
failures).
|
||||
"""
|
||||
if context.sancov_dir and output.pid is not None:
|
||||
sancov_file = os.path.join(
|
||||
@ -160,7 +161,10 @@ class TestJob(Job):
|
||||
if os.path.exists(sancov_file):
|
||||
parts = sancov_file.split(".")
|
||||
new_sancov_file = ".".join(
|
||||
parts[:-2] + ["test", str(self.test.id)] + parts[-1:])
|
||||
parts[:-2] +
|
||||
["test", str(self.test.id), str(self.test.run)] +
|
||||
parts[-1:]
|
||||
)
|
||||
assert not os.path.exists(new_sancov_file)
|
||||
os.rename(sancov_file, new_sancov_file)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user