Commit 11a2abee authored by Sergiy Belozorov's avatar Sergiy Belozorov Committed by Commit Bot

[tools] Report timeouts and near-timeouts to be displayed on builds

R=machenbach@chromium.org, tmrts@chromium.org

No-Try: true
Bug: chromium:841700
Change-Id: I18552e928223dd8ea03ac518f6b1b2460d10135d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1559851
Commit-Queue: Sergiy Belozorov <sergiyb@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60751}
parent f78f43b1
...@@ -104,6 +104,7 @@ from __future__ import print_function ...@@ -104,6 +104,7 @@ from __future__ import print_function
from functools import reduce from functools import reduce
from collections import OrderedDict from collections import OrderedDict
import datetime
import json import json
import logging import logging
import math import math
...@@ -157,9 +158,16 @@ class Results(object): ...@@ -157,9 +158,16 @@ class Results(object):
def __init__(self, traces=None, errors=None): def __init__(self, traces=None, errors=None):
self.traces = traces or [] self.traces = traces or []
self.errors = errors or [] self.errors = errors or []
self.timeouts = []
self.near_timeouts = [] # > 90% of the max runtime
def ToDict(self): def ToDict(self):
return {"traces": self.traces, "errors": self.errors} return {
"traces": self.traces,
"errors": self.errors,
"timeouts": self.timeouts,
"near_timeouts": self.near_timeouts,
}
def WriteToFile(self, file_name): def WriteToFile(self, file_name):
with open(file_name, "w") as f: with open(file_name, "w") as f:
...@@ -168,6 +176,8 @@ class Results(object): ...@@ -168,6 +176,8 @@ class Results(object):
def __add__(self, other): def __add__(self, other):
self.traces += other.traces self.traces += other.traces
self.errors += other.errors self.errors += other.errors
self.timeouts += other.timeouts
self.near_timeouts += other.near_timeouts
return self return self
def __str__(self): # pragma: no cover def __str__(self): # pragma: no cover
...@@ -471,6 +481,11 @@ class TraceConfig(GraphConfig): ...@@ -471,6 +481,11 @@ class TraceConfig(GraphConfig):
class RunnableConfig(GraphConfig): class RunnableConfig(GraphConfig):
"""Represents a runnable suite definition (i.e. has a main file). """Represents a runnable suite definition (i.e. has a main file).
""" """
def __init__(self, suite, parent, arch):
super(RunnableConfig, self).__init__(suite, parent, arch)
self.has_timeouts = False
self.has_near_timeouts = False
@property @property
def main(self): def main(self):
return self._suite.get("main", "") return self._suite.get("main", "")
...@@ -647,6 +662,14 @@ class Platform(object): ...@@ -647,6 +662,14 @@ class Platform(object):
def _Run(self, runnable, count, secondary=False): def _Run(self, runnable, count, secondary=False):
raise NotImplementedError() # pragma: no cover raise NotImplementedError() # pragma: no cover
def _TimedRun(self, runnable, count, secondary=False):
runnable_start_time = datetime.datetime.utcnow()
stdout = self._Run(runnable, count, secondary)
runnable_duration = datetime.datetime.utcnow() - runnable_start_time
if runnable_duration.total_seconds() > 0.9 * runnable.timeout:
runnable.has_near_timeouts = True
return stdout
def Run(self, runnable, count): def Run(self, runnable, count):
"""Execute the benchmark's main file. """Execute the benchmark's main file.
...@@ -658,9 +681,9 @@ class Platform(object): ...@@ -658,9 +681,9 @@ class Platform(object):
Returns: A tuple with the two benchmark outputs. The latter will be None if Returns: A tuple with the two benchmark outputs. The latter will be None if
options.shell_dir_secondary was not specified. options.shell_dir_secondary was not specified.
""" """
stdout = self._Run(runnable, count, secondary=False) stdout = self._TimedRun(runnable, count, secondary=False)
if self.shell_dir_secondary: if self.shell_dir_secondary:
return stdout, self._Run(runnable, count, secondary=True) return stdout, self._TimedRun(runnable, count, secondary=True)
else: else:
return stdout, None return stdout, None
...@@ -714,6 +737,7 @@ class DesktopPlatform(Platform): ...@@ -714,6 +737,7 @@ class DesktopPlatform(Platform):
logging.info(title % "Stderr" + "\n%s", output.stderr) logging.info(title % "Stderr" + "\n%s", output.stderr)
if output.timed_out: if output.timed_out:
logging.warning(">>> Test timed out after %ss.", runnable.timeout) logging.warning(">>> Test timed out after %ss.", runnable.timeout)
runnable.has_timeouts = True
raise TestFailedError() raise TestFailedError()
if output.exit_code != 0: if output.exit_code != 0:
logging.warning(">>> Test crashed.") logging.warning(">>> Test crashed.")
...@@ -805,6 +829,7 @@ class AndroidPlatform(Platform): # pragma: no cover ...@@ -805,6 +829,7 @@ class AndroidPlatform(Platform): # pragma: no cover
if e.output is not None: if e.output is not None:
logging.info(title % "Stdout" + "\n%s", e.output) logging.info(title % "Stdout" + "\n%s", e.output)
logging.warning(">>> Test timed out after %ss.", runnable.timeout) logging.warning(">>> Test timed out after %ss.", runnable.timeout)
runnable.has_timeouts = True
raise TestFailedError() raise TestFailedError()
if runnable.process_size: if runnable.process_size:
return stdout + "MaxMemory: Unsupported" return stdout + "MaxMemory: Unsupported"
...@@ -1096,6 +1121,10 @@ def Main(args): ...@@ -1096,6 +1121,10 @@ def Main(args):
Runner, trybot=options.shell_dir_secondary) Runner, trybot=options.shell_dir_secondary)
results += result results += result
results_secondary += result_secondary results_secondary += result_secondary
if runnable.has_timeouts:
results.timeouts.append(runnable_name)
if runnable.has_near_timeouts:
results.near_timeouts.append(runnable_name)
platform.PostExecution() platform.PostExecution()
if options.json_test_results: if options.json_test_results:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment