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