Yunlian Jiang | e84ea3d | 2016-12-12 11:07:40 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python2 |
Ting-Yuan Huang | e581987 | 2016-12-15 14:22:26 -0800 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2016 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 6 | """Script for running nightly compiler tests on ChromeOS. |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 7 | |
| 8 | This script launches a buildbot to build ChromeOS with the latest compiler on |
| 9 | a particular board; then it finds and downloads the trybot image and the |
| 10 | corresponding official image, and runs crosperf performance tests comparing |
| 11 | the two. It then generates a report, emails it to the c-compiler-chrome, as |
| 12 | well as copying the images into the seven-day reports directory. |
| 13 | """ |
| 14 | |
| 15 | # Script to test different toolchains against ChromeOS benchmarks. |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 16 | |
| 17 | from __future__ import print_function |
| 18 | |
Caroline Tice | eddb063 | 2016-04-14 09:19:02 -0700 | [diff] [blame] | 19 | import argparse |
cmtice | ce5ffa4 | 2015-02-12 15:18:43 -0800 | [diff] [blame] | 20 | import datetime |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 21 | import os |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 22 | import re |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 23 | import sys |
| 24 | import time |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 25 | |
Caroline Tice | a8af9a7 | 2016-07-20 12:52:59 -0700 | [diff] [blame] | 26 | from cros_utils import command_executer |
| 27 | from cros_utils import logger |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 28 | |
Caroline Tice | a8af9a7 | 2016-07-20 12:52:59 -0700 | [diff] [blame] | 29 | from cros_utils import buildbot_utils |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 30 | |
Manoj Gupta | c411035 | 2016-12-28 13:47:12 -0800 | [diff] [blame] | 31 | # CL that uses LLVM-Next to build the images (includes chrome). |
Manoj Gupta | d575b8a | 2017-03-08 10:51:28 -0800 | [diff] [blame^] | 32 | USE_LLVM_NEXT_PATCH = '419149' |
Manoj Gupta | c411035 | 2016-12-28 13:47:12 -0800 | [diff] [blame] | 33 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 34 | CROSTC_ROOT = '/usr/local/google/crostc' |
| 35 | ROLE_ACCOUNT = 'mobiletc-prebuild' |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 36 | TOOLCHAIN_DIR = os.path.dirname(os.path.realpath(__file__)) |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 37 | MAIL_PROGRAM = '~/var/bin/mail-sheriff' |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 38 | PENDING_ARCHIVES_DIR = os.path.join(CROSTC_ROOT, 'pending_archives') |
| 39 | NIGHTLY_TESTS_DIR = os.path.join(CROSTC_ROOT, 'nightly_test_reports') |
| 40 | |
Ting-Yuan Huang | e581987 | 2016-12-15 14:22:26 -0800 | [diff] [blame] | 41 | IMAGE_DIR = '{board}-{image_type}' |
| 42 | IMAGE_VERSION_STR = r'{chrome_version}-{tip}\.{branch}\.{branch_branch}' |
| 43 | IMAGE_FS = IMAGE_DIR + '/' + IMAGE_VERSION_STR |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 44 | TRYBOT_IMAGE_FS = 'trybot-' + IMAGE_FS + '-{build_id}' |
| 45 | PFQ_IMAGE_FS = IMAGE_FS + '-rc1' |
Manoj Gupta | aee96b7 | 2016-10-24 13:43:28 -0700 | [diff] [blame] | 46 | IMAGE_RE_GROUPS = { |
| 47 | 'board': r'(?P<board>\S+)', |
| 48 | 'image_type': r'(?P<image_type>\S+)', |
| 49 | 'chrome_version': r'(?P<chrome_version>R\d+)', |
| 50 | 'tip': r'(?P<tip>\d+)', |
| 51 | 'branch': r'(?P<branch>\d+)', |
| 52 | 'branch_branch': r'(?P<branch_branch>\d+)', |
| 53 | 'build_id': r'(?P<build_id>b\d+)' |
| 54 | } |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 55 | TRYBOT_IMAGE_RE = TRYBOT_IMAGE_FS.format(**IMAGE_RE_GROUPS) |
| 56 | |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 57 | |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 58 | class ToolchainComparator(object): |
| 59 | """Class for doing the nightly tests work.""" |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 60 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 61 | def __init__(self, |
| 62 | board, |
| 63 | remotes, |
| 64 | chromeos_root, |
| 65 | weekday, |
| 66 | patches, |
| 67 | noschedv2=False): |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 68 | self._board = board |
| 69 | self._remotes = remotes |
| 70 | self._chromeos_root = chromeos_root |
| 71 | self._base_dir = os.getcwd() |
| 72 | self._ce = command_executer.GetCommandExecuter() |
| 73 | self._l = logger.GetLogger() |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 74 | self._build = '%s-release' % board |
Manoj Gupta | d575b8a | 2017-03-08 10:51:28 -0800 | [diff] [blame^] | 75 | self._patches = patches.split(',') if patches else [] |
Yunlian Jiang | 3c6e467 | 2015-08-24 15:58:22 -0700 | [diff] [blame] | 76 | self._patches_string = '_'.join(str(p) for p in self._patches) |
Han Shen | 4349429 | 2015-09-14 10:26:40 -0700 | [diff] [blame] | 77 | self._noschedv2 = noschedv2 |
Yunlian Jiang | 3c6e467 | 2015-08-24 15:58:22 -0700 | [diff] [blame] | 78 | |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 79 | if not weekday: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 80 | self._weekday = time.strftime('%a') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 81 | else: |
| 82 | self._weekday = weekday |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 83 | timestamp = datetime.datetime.strftime(datetime.datetime.now(), |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 84 | '%Y-%m-%d_%H:%M:%S') |
Manoj Gupta | aee96b7 | 2016-10-24 13:43:28 -0700 | [diff] [blame] | 85 | self._reports_dir = os.path.join( |
| 86 | NIGHTLY_TESTS_DIR, |
| 87 | '%s.%s' % (timestamp, board),) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 88 | |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 89 | def _GetVanillaImageName(self, trybot_image): |
Ting-Yuan Huang | e581987 | 2016-12-15 14:22:26 -0800 | [diff] [blame] | 90 | """Given a trybot artifact name, get latest vanilla image name. |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 91 | |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 92 | Args: |
| 93 | trybot_image: artifact name such as |
| 94 | 'trybot-daisy-release/R40-6394.0.0-b1389' |
| 95 | |
| 96 | Returns: |
Ting-Yuan Huang | e581987 | 2016-12-15 14:22:26 -0800 | [diff] [blame] | 97 | Latest official image name, e.g. 'daisy-release/R57-9089.0.0'. |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 98 | """ |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 99 | mo = re.search(TRYBOT_IMAGE_RE, trybot_image) |
| 100 | assert mo |
Ting-Yuan Huang | e581987 | 2016-12-15 14:22:26 -0800 | [diff] [blame] | 101 | dirname = IMAGE_DIR.replace('\\', '').format(**mo.groupdict()) |
| 102 | version = buildbot_utils.GetGSContent(self._chromeos_root, |
| 103 | dirname + '/LATEST-master') |
| 104 | return dirname + '/' + version |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 105 | |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 106 | def _GetNonAFDOImageName(self, trybot_image): |
| 107 | """Given a trybot artifact name, get corresponding non-AFDO image name. |
| 108 | |
| 109 | We get the non-AFDO image from the PFQ builders. This image |
| 110 | is not generated for all the boards and, the closest PFQ image |
| 111 | was the one build for the previous ChromeOS version (the chrome |
| 112 | used in the current version is the one validated in the previous |
| 113 | version). |
| 114 | The previous ChromeOS does not always exist either. So, we try |
| 115 | a couple of versions before. |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 116 | |
| 117 | Args: |
| 118 | trybot_image: artifact name such as |
| 119 | 'trybot-daisy-release/R40-6394.0.0-b1389' |
| 120 | |
| 121 | Returns: |
| 122 | Corresponding chrome PFQ image name, e.g. |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 123 | 'daisy-chrome-pfq/R40-6393.0.0-rc1'. |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 124 | """ |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 125 | mo = re.search(TRYBOT_IMAGE_RE, trybot_image) |
| 126 | assert mo |
| 127 | image_dict = mo.groupdict() |
| 128 | image_dict['image_type'] = 'chrome-pfq' |
| 129 | for _ in xrange(2): |
| 130 | image_dict['tip'] = str(int(image_dict['tip']) - 1) |
| 131 | nonafdo_image = PFQ_IMAGE_FS.replace('\\', '').format(**image_dict) |
| 132 | if buildbot_utils.DoesImageExist(self._chromeos_root, nonafdo_image): |
| 133 | return nonafdo_image |
| 134 | return '' |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 135 | |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 136 | def _FinishSetup(self): |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 137 | """Make sure testing_rsa file is properly set up.""" |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 138 | # Fix protections on ssh key |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 139 | command = ('chmod 600 /var/cache/chromeos-cache/distfiles/target' |
| 140 | '/chrome-src-internal/src/third_party/chromite/ssh_keys' |
| 141 | '/testing_rsa') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 142 | ret_val = self._ce.ChrootRunCommand(self._chromeos_root, command) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 143 | if ret_val != 0: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 144 | raise RuntimeError('chmod for testing_rsa failed') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 145 | |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 146 | def _TestImages(self, trybot_image, vanilla_image, nonafdo_image): |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 147 | """Create crosperf experiment file. |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 148 | |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 149 | Given the names of the trybot, vanilla and non-AFDO images, create the |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 150 | appropriate crosperf experiment file and launch crosperf on it. |
| 151 | """ |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 152 | experiment_file_dir = os.path.join(self._chromeos_root, '..', self._weekday) |
| 153 | experiment_file_name = '%s_toolchain_experiment.txt' % self._board |
Yunlian Jiang | 2f56356 | 2015-08-28 13:54:04 -0700 | [diff] [blame] | 154 | |
Manoj Gupta | d575b8a | 2017-03-08 10:51:28 -0800 | [diff] [blame^] | 155 | compiler_string = 'llvm' |
Manoj Gupta | c411035 | 2016-12-28 13:47:12 -0800 | [diff] [blame] | 156 | if USE_LLVM_NEXT_PATCH in self._patches_string: |
| 157 | experiment_file_name = '%s_llvm_next_experiment.txt' % self._board |
| 158 | compiler_string = 'llvm_next' |
Yunlian Jiang | 2f56356 | 2015-08-28 13:54:04 -0700 | [diff] [blame] | 159 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 160 | experiment_file = os.path.join(experiment_file_dir, experiment_file_name) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 161 | experiment_header = """ |
| 162 | board: %s |
| 163 | remote: %s |
Luis Lozano | e1efeb8 | 2015-06-16 16:35:44 -0700 | [diff] [blame] | 164 | retries: 1 |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 165 | """ % (self._board, self._remotes) |
| 166 | experiment_tests = """ |
Luis Lozano | 1489d64 | 2015-12-08 10:08:19 -0800 | [diff] [blame] | 167 | benchmark: all_toolchain_perf { |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 168 | suite: telemetry_Crosperf |
Ting-Yuan Huang | 8332364 | 2017-02-17 12:20:02 -0800 | [diff] [blame] | 169 | iterations: 0 |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 170 | } |
Caroline Tice | e82513b | 2016-10-27 12:45:15 -0700 | [diff] [blame] | 171 | |
| 172 | benchmark: page_cycler_v2.typical_25 { |
| 173 | suite: telemetry_Crosperf |
Ting-Yuan Huang | 8332364 | 2017-02-17 12:20:02 -0800 | [diff] [blame] | 174 | iterations: 0 |
Caroline Tice | e82513b | 2016-10-27 12:45:15 -0700 | [diff] [blame] | 175 | run_local: False |
| 176 | retries: 0 |
| 177 | } |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 178 | """ |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 179 | |
| 180 | with open(experiment_file, 'w') as f: |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 181 | f.write(experiment_header) |
| 182 | f.write(experiment_tests) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 183 | |
| 184 | # Now add vanilla to test file. |
| 185 | official_image = """ |
| 186 | vanilla_image { |
| 187 | chromeos_root: %s |
| 188 | build: %s |
Caroline Tice | ddde505 | 2015-09-23 09:43:35 -0700 | [diff] [blame] | 189 | compiler: gcc |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 190 | } |
| 191 | """ % (self._chromeos_root, vanilla_image) |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 192 | f.write(official_image) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 193 | |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 194 | # Now add non-AFDO image to test file. |
Luis Lozano | 439f2b7 | 2016-01-08 11:56:02 -0800 | [diff] [blame] | 195 | if nonafdo_image: |
| 196 | official_nonafdo_image = """ |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 197 | nonafdo_image { |
| 198 | chromeos_root: %s |
| 199 | build: %s |
| 200 | compiler: gcc |
| 201 | } |
| 202 | """ % (self._chromeos_root, nonafdo_image) |
Luis Lozano | 439f2b7 | 2016-01-08 11:56:02 -0800 | [diff] [blame] | 203 | f.write(official_nonafdo_image) |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 204 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 205 | label_string = '%s_trybot_image' % compiler_string |
Caroline Tice | 80eab98 | 2015-11-04 14:03:14 -0800 | [diff] [blame] | 206 | |
Manoj Gupta | 3594db8 | 2017-01-31 11:48:57 -0800 | [diff] [blame] | 207 | # Reuse autotest files from vanilla image for trybot images |
| 208 | autotest_files = os.path.join('/tmp', vanilla_image, 'autotest_files') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 209 | experiment_image = """ |
Caroline Tice | 80eab98 | 2015-11-04 14:03:14 -0800 | [diff] [blame] | 210 | %s { |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 211 | chromeos_root: %s |
| 212 | build: %s |
Manoj Gupta | 3594db8 | 2017-01-31 11:48:57 -0800 | [diff] [blame] | 213 | autotest_path: %s |
Caroline Tice | ddde505 | 2015-09-23 09:43:35 -0700 | [diff] [blame] | 214 | compiler: %s |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 215 | } |
Caroline Tice | 80eab98 | 2015-11-04 14:03:14 -0800 | [diff] [blame] | 216 | """ % (label_string, self._chromeos_root, trybot_image, |
Manoj Gupta | 3594db8 | 2017-01-31 11:48:57 -0800 | [diff] [blame] | 217 | autotest_files, compiler_string) |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 218 | f.write(experiment_image) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 219 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 220 | crosperf = os.path.join(TOOLCHAIN_DIR, 'crosperf', 'crosperf') |
Han Shen | 4349429 | 2015-09-14 10:26:40 -0700 | [diff] [blame] | 221 | noschedv2_opts = '--noschedv2' if self._noschedv2 else '' |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 222 | command = ('{crosperf} --no_email=True --results_dir={r_dir} ' |
| 223 | '--json_report=True {noschedv2_opts} {exp_file}').format( |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 224 | crosperf=crosperf, |
| 225 | r_dir=self._reports_dir, |
| 226 | noschedv2_opts=noschedv2_opts, |
| 227 | exp_file=experiment_file) |
cmtice | aa700b0 | 2015-06-12 13:26:47 -0700 | [diff] [blame] | 228 | |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 229 | ret = self._ce.RunCommand(command) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 230 | if ret != 0: |
Manoj Gupta | aee96b7 | 2016-10-24 13:43:28 -0700 | [diff] [blame] | 231 | raise RuntimeError('Crosperf execution error!') |
Caroline Tice | ebbc3da | 2015-09-03 10:27:20 -0700 | [diff] [blame] | 232 | else: |
| 233 | # Copy json report to pending archives directory. |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 234 | command = 'cp %s/*.json %s/.' % (self._reports_dir, PENDING_ARCHIVES_DIR) |
Caroline Tice | ebbc3da | 2015-09-03 10:27:20 -0700 | [diff] [blame] | 235 | ret = self._ce.RunCommand(command) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 236 | return |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 237 | |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 238 | def _SendEmail(self): |
| 239 | """Find email message generated by crosperf and send it.""" |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 240 | filename = os.path.join(self._reports_dir, 'msg_body.html') |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 241 | if (os.path.exists(filename) and |
| 242 | os.path.exists(os.path.expanduser(MAIL_PROGRAM))): |
Manoj Gupta | d575b8a | 2017-03-08 10:51:28 -0800 | [diff] [blame^] | 243 | email_title = 'buildbot llvm test results' |
Manoj Gupta | c411035 | 2016-12-28 13:47:12 -0800 | [diff] [blame] | 244 | if USE_LLVM_NEXT_PATCH in self._patches_string: |
| 245 | email_title = 'buildbot llvm_next test results' |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 246 | command = ('cat %s | %s -s "%s, %s" -team -html' % |
| 247 | (filename, MAIL_PROGRAM, email_title, self._board)) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 248 | self._ce.RunCommand(command) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 249 | |
| 250 | def DoAll(self): |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 251 | """Main function inside ToolchainComparator class. |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 252 | |
| 253 | Launch trybot, get image names, create crosperf experiment file, run |
| 254 | crosperf, and copy images into seven-day report directories. |
| 255 | """ |
cmtice | ce5ffa4 | 2015-02-12 15:18:43 -0800 | [diff] [blame] | 256 | date_str = datetime.date.today() |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 257 | description = 'master_%s_%s_%s' % (self._patches_string, self._build, |
Han Shen | fe054f1 | 2015-02-18 15:00:13 -0800 | [diff] [blame] | 258 | date_str) |
Yunlian Jiang | e84ea3d | 2016-12-12 11:07:40 -0800 | [diff] [blame] | 259 | build_id, trybot_image = buildbot_utils.GetTrybotImage( |
Manoj Gupta | aee96b7 | 2016-10-24 13:43:28 -0700 | [diff] [blame] | 260 | self._chromeos_root, |
| 261 | self._build, |
| 262 | self._patches, |
| 263 | description, |
| 264 | other_flags=['--notests'], |
| 265 | build_toolchain=True) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 266 | |
Yunlian Jiang | e84ea3d | 2016-12-12 11:07:40 -0800 | [diff] [blame] | 267 | print('trybot_url: \ |
Manoj Gupta | c411035 | 2016-12-28 13:47:12 -0800 | [diff] [blame] | 268 | https://uberchromegw.corp.google.com/i/chromiumos.tryserver/builders/release/builds/%s' |
| 269 | % build_id) |
cmtice | d54f980 | 2015-02-05 11:04:11 -0800 | [diff] [blame] | 270 | if len(trybot_image) == 0: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 271 | self._l.LogError('Unable to find trybot_image for %s!' % description) |
Luis Lozano | 7f20acb | 2015-11-04 17:15:08 -0800 | [diff] [blame] | 272 | return 1 |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 273 | |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 274 | vanilla_image = self._GetVanillaImageName(trybot_image) |
| 275 | nonafdo_image = self._GetNonAFDOImageName(trybot_image) |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 276 | |
| 277 | print('trybot_image: %s' % trybot_image) |
| 278 | print('vanilla_image: %s' % vanilla_image) |
| 279 | print('nonafdo_image: %s' % nonafdo_image) |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 280 | |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 281 | if os.getlogin() == ROLE_ACCOUNT: |
| 282 | self._FinishSetup() |
| 283 | |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 284 | self._TestImages(trybot_image, vanilla_image, nonafdo_image) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 285 | self._SendEmail() |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 286 | return 0 |
| 287 | |
| 288 | |
| 289 | def Main(argv): |
| 290 | """The main function.""" |
| 291 | |
| 292 | # Common initializations |
| 293 | command_executer.InitCommandExecuter() |
Caroline Tice | eddb063 | 2016-04-14 09:19:02 -0700 | [diff] [blame] | 294 | parser = argparse.ArgumentParser() |
Manoj Gupta | aee96b7 | 2016-10-24 13:43:28 -0700 | [diff] [blame] | 295 | parser.add_argument( |
| 296 | '--remote', dest='remote', help='Remote machines to run tests on.') |
| 297 | parser.add_argument( |
| 298 | '--board', dest='board', default='x86-zgb', help='The target board.') |
| 299 | parser.add_argument( |
| 300 | '--chromeos_root', |
| 301 | dest='chromeos_root', |
| 302 | help='The chromeos root from which to run tests.') |
| 303 | parser.add_argument( |
| 304 | '--weekday', |
| 305 | default='', |
| 306 | dest='weekday', |
| 307 | help='The day of the week for which to run tests.') |
| 308 | parser.add_argument( |
| 309 | '--patch', |
| 310 | dest='patches', |
| 311 | help='The patches to use for the testing, ' |
| 312 | "seprate the patch numbers with ',' " |
| 313 | 'for more than one patches.') |
| 314 | parser.add_argument( |
| 315 | '--noschedv2', |
| 316 | dest='noschedv2', |
| 317 | action='store_true', |
| 318 | default=False, |
| 319 | help='Pass --noschedv2 to crosperf.') |
Han Shen | 3641312 | 2015-08-28 11:05:40 -0700 | [diff] [blame] | 320 | |
Caroline Tice | eddb063 | 2016-04-14 09:19:02 -0700 | [diff] [blame] | 321 | options = parser.parse_args(argv[1:]) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 322 | if not options.board: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 323 | print('Please give a board.') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 324 | return 1 |
| 325 | if not options.remote: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 326 | print('Please give at least one remote machine.') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 327 | return 1 |
| 328 | if not options.chromeos_root: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 329 | print('Please specify the ChromeOS root directory.') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 330 | return 1 |
Yunlian Jiang | e52838c | 2015-08-20 14:32:37 -0700 | [diff] [blame] | 331 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 332 | fc = ToolchainComparator(options.board, options.remote, options.chromeos_root, |
Manoj Gupta | d575b8a | 2017-03-08 10:51:28 -0800 | [diff] [blame^] | 333 | options.weekday, options.patches, options.noschedv2) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 334 | return fc.DoAll() |
| 335 | |
| 336 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 337 | if __name__ == '__main__': |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 338 | retval = Main(sys.argv) |
| 339 | sys.exit(retval) |