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