OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Runs perf tests. | 5 """Runs perf tests. |
6 | 6 |
7 Our buildbot infrastructure requires each slave to run steps serially. | 7 Our buildbot infrastructure requires each slave to run steps serially. |
8 This is sub-optimal for android, where these steps can run independently on | 8 This is sub-optimal for android, where these steps can run independently on |
9 multiple connected devices. | 9 multiple connected devices. |
10 | 10 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 import zipfile | 61 import zipfile |
62 | 62 |
63 from devil.android import battery_utils | 63 from devil.android import battery_utils |
64 from devil.android import device_errors | 64 from devil.android import device_errors |
65 from devil.android import forwarder | 65 from devil.android import forwarder |
66 from devil.constants import exit_codes | 66 from devil.constants import exit_codes |
67 from devil.utils import cmd_helper | 67 from devil.utils import cmd_helper |
68 from pylib import constants | 68 from pylib import constants |
69 from pylib.base import base_test_result | 69 from pylib.base import base_test_result |
70 from pylib.base import base_test_runner | 70 from pylib.base import base_test_runner |
| 71 from pylib.constants import host_paths |
71 | 72 |
72 | 73 |
73 # Regex for the master branch commit position. | 74 # Regex for the master branch commit position. |
74 _GIT_CR_POS_RE = re.compile(r'^Cr-Commit-Position: refs/heads/master@{#(\d+)}$') | 75 _GIT_CR_POS_RE = re.compile(r'^Cr-Commit-Position: refs/heads/master@{#(\d+)}$') |
75 | 76 |
76 | 77 |
77 def _GetChromiumRevision(): | 78 def _GetChromiumRevision(): |
78 # pylint: disable=line-too-long | 79 # pylint: disable=line-too-long |
79 """Get the git hash and commit position of the chromium master branch. | 80 """Get the git hash and commit position of the chromium master branch. |
80 | 81 |
81 See: https://chromium.googlesource.com/chromium/tools/build/+/master/scripts/s
lave/runtest.py#212 | 82 See: https://chromium.googlesource.com/chromium/tools/build/+/master/scripts/s
lave/runtest.py#212 |
82 | 83 |
83 Returns: | 84 Returns: |
84 A dictionary with 'revision' and 'commit_pos' keys. | 85 A dictionary with 'revision' and 'commit_pos' keys. |
85 """ | 86 """ |
86 # pylint: enable=line-too-long | 87 # pylint: enable=line-too-long |
87 status, output = cmd_helper.GetCmdStatusAndOutput( | 88 status, output = cmd_helper.GetCmdStatusAndOutput( |
88 ['git', 'log', '-n', '1', '--pretty=format:%H%n%B', 'HEAD'], | 89 ['git', 'log', '-n', '1', '--pretty=format:%H%n%B', 'HEAD'], |
89 constants.DIR_SOURCE_ROOT) | 90 host_paths.DIR_SOURCE_ROOT) |
90 revision = None | 91 revision = None |
91 commit_pos = None | 92 commit_pos = None |
92 if not status: | 93 if not status: |
93 lines = output.splitlines() | 94 lines = output.splitlines() |
94 revision = lines[0] | 95 revision = lines[0] |
95 for line in reversed(lines): | 96 for line in reversed(lines): |
96 m = _GIT_CR_POS_RE.match(line.strip()) | 97 m = _GIT_CR_POS_RE.match(line.strip()) |
97 if m: | 98 if m: |
98 commit_pos = int(m.group(1)) | 99 commit_pos = int(m.group(1)) |
99 break | 100 break |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 full_cmd = cmd | 366 full_cmd = cmd |
366 if self._options.dry_run: | 367 if self._options.dry_run: |
367 full_cmd = 'echo %s' % cmd | 368 full_cmd = 'echo %s' % cmd |
368 | 369 |
369 logfile = sys.stdout | 370 logfile = sys.stdout |
370 archive_bytes = None | 371 archive_bytes = None |
371 if self._options.single_step: | 372 if self._options.single_step: |
372 # Just print a heart-beat so that the outer buildbot scripts won't timeout | 373 # Just print a heart-beat so that the outer buildbot scripts won't timeout |
373 # without response. | 374 # without response. |
374 logfile = _HeartBeatLogger() | 375 logfile = _HeartBeatLogger() |
375 cwd = os.path.abspath(constants.DIR_SOURCE_ROOT) | 376 cwd = os.path.abspath(host_paths.DIR_SOURCE_ROOT) |
376 if full_cmd.startswith('src/'): | 377 if full_cmd.startswith('src/'): |
377 cwd = os.path.abspath(os.path.join(constants.DIR_SOURCE_ROOT, os.pardir)) | 378 cwd = os.path.abspath(os.path.join(host_paths.DIR_SOURCE_ROOT, os.pardir)) |
378 try: | 379 try: |
379 exit_code, output = cmd_helper.GetCmdStatusAndOutputWithTimeout( | 380 exit_code, output = cmd_helper.GetCmdStatusAndOutputWithTimeout( |
380 full_cmd, timeout, cwd=cwd, shell=True, logfile=logfile) | 381 full_cmd, timeout, cwd=cwd, shell=True, logfile=logfile) |
381 json_output = self._ReadChartjsonOutput() | 382 json_output = self._ReadChartjsonOutput() |
382 if test_config.get('archive_output_dir'): | 383 if test_config.get('archive_output_dir'): |
383 archive_bytes = self._ArchiveOutputDir() | 384 archive_bytes = self._ArchiveOutputDir() |
384 except cmd_helper.TimeoutError as e: | 385 except cmd_helper.TimeoutError as e: |
385 exit_code = -1 | 386 exit_code = -1 |
386 output = e.output | 387 output = e.output |
387 json_output = '' | 388 json_output = '' |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 Returns: | 459 Returns: |
459 A tuple of (TestRunResults, retry). | 460 A tuple of (TestRunResults, retry). |
460 """ | 461 """ |
461 _, result_type = self._LaunchPerfTest(test_name) | 462 _, result_type = self._LaunchPerfTest(test_name) |
462 results = base_test_result.TestRunResults() | 463 results = base_test_result.TestRunResults() |
463 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) | 464 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) |
464 retry = None | 465 retry = None |
465 if not results.DidRunPass(): | 466 if not results.DidRunPass(): |
466 retry = test_name | 467 retry = test_name |
467 return results, retry | 468 return results, retry |
OLD | NEW |