| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import logging | |
| 7 import json | |
| 8 import optparse | |
| 9 import os | |
| 10 import re | |
| 11 import sys | |
| 12 | |
| 13 from slave import results_dashboard | |
| 14 from slave import slave_utils | |
| 15 | |
| 16 | |
| 17 def _GetMainRevision(commit_pos, build_dir, revision=None): | |
| 18 """Return revision to use as the numerical x-value in the perf dashboard. | |
| 19 | |
| 20 This will be used as the value of "rev" in the data passed to | |
| 21 results_dashboard.SendResults. | |
| 22 | |
| 23 In order or priority, this function could return: | |
| 24 1. The value of "got_revision_cp" in build properties. | |
| 25 3. An SVN number, git commit position, or git commit hash. | |
| 26 """ | |
| 27 if commit_pos is not None: | |
| 28 return int(re.search(r'{#(\d+)}', commit_pos).group(1)) | |
| 29 # TODO(sullivan,qyearsley): Don't fall back to _GetRevision if it returns | |
| 30 # a git commit, since this should be a numerical revision. Instead, abort | |
| 31 # and fail. | |
| 32 return slave_utils.GetRevision(os.path.dirname(os.path.abspath(build_dir))) | |
| 33 | |
| 34 | |
| 35 def main(args): | |
| 36 # Parse options | |
| 37 parser = optparse.OptionParser() | |
| 38 parser.add_option('--name') | |
| 39 parser.add_option('--chartjson-results') | |
| 40 parser.add_option('--got-revision-cp') | |
| 41 parser.add_option('--build-dir') | |
| 42 parser.add_option('--perf-id') | |
| 43 parser.add_option('--results-url') | |
| 44 parser.add_option('--buildername') | |
| 45 parser.add_option('--buildnumber') | |
| 46 parser.add_option('--got-webrtc-revision') | |
| 47 parser.add_option('--got-v8-revision') | |
| 48 parser.add_option('--version') | |
| 49 parser.add_option('--git-revision') | |
| 50 options, extra_args = parser.parse_args(args) | |
| 51 | |
| 52 # Validate options. | |
| 53 if extra_args: | |
| 54 parser.error('Unexpected command line arguments') | |
| 55 if not options.perf_id or not options.results_url: | |
| 56 parser.error('--perf-id and --results-url are required') | |
| 57 | |
| 58 main_revision = _GetMainRevision(options.got_revision_cp, options.build_dir) | |
| 59 blink_revision = slave_utils.GetBlinkRevision(options.build_dir) | |
| 60 revisions = slave_utils.GetPerfDashboardRevisionsWithProperties( | |
| 61 options.got_webrtc_revision, options.got_v8_revision, options.version, | |
| 62 options.git_revision, main_revision, blink_revision) | |
| 63 reference_build = 'reference' in options.name | |
| 64 stripped_test_name = options.name.replace('.reference', '') | |
| 65 dashboard_json = results_dashboard.MakeDashboardJsonV1( | |
| 66 json.loads(options.chartjson_results), | |
| 67 revisions, stripped_test_name, options.perf_id, | |
| 68 options.buildername, options.buildnumber, | |
| 69 None, reference_build) | |
| 70 if dashboard_json: | |
| 71 logging.debug(json.dumps(dashboard_json , indent=2)) | |
| 72 results_dashboard.SendResults( | |
| 73 dashboard_json, | |
| 74 options.results_url, | |
| 75 options.build_dir) | |
| 76 else: | |
| 77 print 'Error: No perf dashboard JSON was produced.' | |
| 78 print '@@@STEP_FAILURE@@@' | |
| 79 return 0 | |
| 80 | |
| 81 | |
| 82 if __name__ == '__main__': | |
| 83 sys.exit(main((sys.argv))) | |
| OLD | NEW |