Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 1 | #!/usr/bin/python2 |
| 2 | """Script for running nightly compiler tests on ChromeOS. |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 3 | |
| 4 | This script launches a buildbot to build ChromeOS with the latest compiler on |
| 5 | a particular board; then it finds and downloads the trybot image and the |
| 6 | corresponding official image, and runs crosperf performance tests comparing |
| 7 | the two. It then generates a report, emails it to the c-compiler-chrome, as |
| 8 | well as copying the images into the seven-day reports directory. |
| 9 | """ |
| 10 | |
| 11 | # Script to test different toolchains against ChromeOS benchmarks. |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 12 | |
| 13 | from __future__ import print_function |
| 14 | |
Caroline Tice | eddb063 | 2016-04-14 09:19:02 -0700 | [diff] [blame] | 15 | import argparse |
cmtice | ce5ffa4 | 2015-02-12 15:18:43 -0800 | [diff] [blame] | 16 | import datetime |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 17 | import os |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 18 | import re |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 19 | import sys |
| 20 | import time |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 21 | |
Caroline Tice | a8af9a7 | 2016-07-20 12:52:59 -0700 | [diff] [blame] | 22 | from cros_utils import command_executer |
| 23 | from cros_utils import logger |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 24 | |
Caroline Tice | a8af9a7 | 2016-07-20 12:52:59 -0700 | [diff] [blame] | 25 | from cros_utils import buildbot_utils |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 26 | |
| 27 | # CL that updated GCC ebuilds to use 'next_gcc'. |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 28 | USE_NEXT_GCC_PATCH = '230260' |
Yunlian Jiang | 3c6e467 | 2015-08-24 15:58:22 -0700 | [diff] [blame] | 29 | |
Yunlian Jiang | 2f56356 | 2015-08-28 13:54:04 -0700 | [diff] [blame] | 30 | # CL that uses LLVM to build the peppy image. |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 31 | USE_LLVM_PATCH = '295217' |
Yunlian Jiang | 2f56356 | 2015-08-28 13:54:04 -0700 | [diff] [blame] | 32 | |
Yunlian Jiang | 3c6e467 | 2015-08-24 15:58:22 -0700 | [diff] [blame] | 33 | # The boards on which we run weekly reports |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 34 | WEEKLY_REPORT_BOARDS = ['lumpy'] |
cmtice | 46093e5 | 2014-12-09 14:59:16 -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' |
| 40 | WEEKLY_REPORTS_ROOT = os.path.join(CROSTC_ROOT, 'weekly_test_data') |
| 41 | PENDING_ARCHIVES_DIR = os.path.join(CROSTC_ROOT, 'pending_archives') |
| 42 | NIGHTLY_TESTS_DIR = os.path.join(CROSTC_ROOT, 'nightly_test_reports') |
| 43 | |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 44 | IMAGE_FS = (r'{board}-{image_type}/{chrome_version}-{tip}\.' + |
| 45 | r'{branch}\.{branch_branch}') |
| 46 | TRYBOT_IMAGE_FS = 'trybot-' + IMAGE_FS + '-{build_id}' |
| 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 | |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 59 | |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 60 | class ToolchainComparator(object): |
| 61 | """Class for doing the nightly tests work.""" |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 62 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 63 | def __init__(self, |
| 64 | board, |
| 65 | remotes, |
| 66 | chromeos_root, |
| 67 | weekday, |
| 68 | patches, |
| 69 | noschedv2=False): |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 70 | self._board = board |
| 71 | self._remotes = remotes |
| 72 | self._chromeos_root = chromeos_root |
| 73 | self._base_dir = os.getcwd() |
| 74 | self._ce = command_executer.GetCommandExecuter() |
| 75 | self._l = logger.GetLogger() |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 76 | self._build = '%s-release' % board |
Yunlian Jiang | 3c6e467 | 2015-08-24 15:58:22 -0700 | [diff] [blame] | 77 | self._patches = patches.split(',') |
| 78 | self._patches_string = '_'.join(str(p) for p in self._patches) |
Han Shen | 4349429 | 2015-09-14 10:26:40 -0700 | [diff] [blame] | 79 | self._noschedv2 = noschedv2 |
Yunlian Jiang | 3c6e467 | 2015-08-24 15:58:22 -0700 | [diff] [blame] | 80 | |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 81 | if not weekday: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 82 | self._weekday = time.strftime('%a') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 83 | else: |
| 84 | self._weekday = weekday |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 85 | timestamp = datetime.datetime.strftime(datetime.datetime.now(), |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 86 | '%Y-%m-%d_%H:%M:%S') |
Manoj Gupta | aee96b7 | 2016-10-24 13:43:28 -0700 | [diff] [blame^] | 87 | self._reports_dir = os.path.join( |
| 88 | NIGHTLY_TESTS_DIR, |
| 89 | '%s.%s' % (timestamp, board),) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 90 | |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 91 | def _GetVanillaImageName(self, trybot_image): |
| 92 | """Given a trybot artifact name, get corresponding vanilla image name. |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 93 | |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 94 | Args: |
| 95 | trybot_image: artifact name such as |
| 96 | 'trybot-daisy-release/R40-6394.0.0-b1389' |
| 97 | |
| 98 | Returns: |
| 99 | Corresponding official image name, e.g. 'daisy-release/R40-6394.0.0'. |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 100 | """ |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 101 | mo = re.search(TRYBOT_IMAGE_RE, trybot_image) |
| 102 | assert mo |
| 103 | return IMAGE_FS.replace('\\', '').format(**mo.groupdict()) |
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 | def _GetNonAFDOImageName(self, trybot_image): |
| 106 | """Given a trybot artifact name, get corresponding non-AFDO image name. |
| 107 | |
| 108 | We get the non-AFDO image from the PFQ builders. This image |
| 109 | is not generated for all the boards and, the closest PFQ image |
| 110 | was the one build for the previous ChromeOS version (the chrome |
| 111 | used in the current version is the one validated in the previous |
| 112 | version). |
| 113 | The previous ChromeOS does not always exist either. So, we try |
| 114 | a couple of versions before. |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 115 | |
| 116 | Args: |
| 117 | trybot_image: artifact name such as |
| 118 | 'trybot-daisy-release/R40-6394.0.0-b1389' |
| 119 | |
| 120 | Returns: |
| 121 | Corresponding chrome PFQ image name, e.g. |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 122 | 'daisy-chrome-pfq/R40-6393.0.0-rc1'. |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 123 | """ |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 124 | mo = re.search(TRYBOT_IMAGE_RE, trybot_image) |
| 125 | assert mo |
| 126 | image_dict = mo.groupdict() |
| 127 | image_dict['image_type'] = 'chrome-pfq' |
| 128 | for _ in xrange(2): |
| 129 | image_dict['tip'] = str(int(image_dict['tip']) - 1) |
| 130 | nonafdo_image = PFQ_IMAGE_FS.replace('\\', '').format(**image_dict) |
| 131 | if buildbot_utils.DoesImageExist(self._chromeos_root, nonafdo_image): |
| 132 | return nonafdo_image |
| 133 | return '' |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 134 | |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 135 | def _FinishSetup(self): |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 136 | """Make sure testing_rsa file is properly set up.""" |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 137 | # Fix protections on ssh key |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 138 | command = ('chmod 600 /var/cache/chromeos-cache/distfiles/target' |
| 139 | '/chrome-src-internal/src/third_party/chromite/ssh_keys' |
| 140 | '/testing_rsa') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 141 | ret_val = self._ce.ChrootRunCommand(self._chromeos_root, command) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 142 | if ret_val != 0: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 143 | raise RuntimeError('chmod for testing_rsa failed') |
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 | def _TestImages(self, trybot_image, vanilla_image, nonafdo_image): |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 146 | """Create crosperf experiment file. |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 147 | |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 148 | Given the names of the trybot, vanilla and non-AFDO images, create the |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 149 | appropriate crosperf experiment file and launch crosperf on it. |
| 150 | """ |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 151 | experiment_file_dir = os.path.join(self._chromeos_root, '..', self._weekday) |
| 152 | experiment_file_name = '%s_toolchain_experiment.txt' % self._board |
Yunlian Jiang | 2f56356 | 2015-08-28 13:54:04 -0700 | [diff] [blame] | 153 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 154 | compiler_string = 'gcc' |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 155 | if USE_LLVM_PATCH in self._patches_string: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 156 | experiment_file_name = '%s_llvm_experiment.txt' % self._board |
| 157 | compiler_string = 'llvm' |
Yunlian Jiang | 2f56356 | 2015-08-28 13:54:04 -0700 | [diff] [blame] | 158 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 159 | experiment_file = os.path.join(experiment_file_dir, experiment_file_name) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 160 | experiment_header = """ |
| 161 | board: %s |
| 162 | remote: %s |
Luis Lozano | e1efeb8 | 2015-06-16 16:35:44 -0700 | [diff] [blame] | 163 | retries: 1 |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 164 | """ % (self._board, self._remotes) |
| 165 | experiment_tests = """ |
Luis Lozano | 1489d64 | 2015-12-08 10:08:19 -0800 | [diff] [blame] | 166 | benchmark: all_toolchain_perf { |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 167 | suite: telemetry_Crosperf |
| 168 | iterations: 3 |
| 169 | } |
| 170 | """ |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 171 | |
| 172 | with open(experiment_file, 'w') as f: |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 173 | f.write(experiment_header) |
| 174 | f.write(experiment_tests) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 175 | |
| 176 | # Now add vanilla to test file. |
| 177 | official_image = """ |
| 178 | vanilla_image { |
| 179 | chromeos_root: %s |
| 180 | build: %s |
Caroline Tice | ddde505 | 2015-09-23 09:43:35 -0700 | [diff] [blame] | 181 | compiler: gcc |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 182 | } |
| 183 | """ % (self._chromeos_root, vanilla_image) |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 184 | f.write(official_image) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 185 | |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 186 | # Now add non-AFDO image to test file. |
Luis Lozano | 439f2b7 | 2016-01-08 11:56:02 -0800 | [diff] [blame] | 187 | if nonafdo_image: |
| 188 | official_nonafdo_image = """ |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 189 | nonafdo_image { |
| 190 | chromeos_root: %s |
| 191 | build: %s |
| 192 | compiler: gcc |
| 193 | } |
| 194 | """ % (self._chromeos_root, nonafdo_image) |
Luis Lozano | 439f2b7 | 2016-01-08 11:56:02 -0800 | [diff] [blame] | 195 | f.write(official_nonafdo_image) |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 196 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 197 | label_string = '%s_trybot_image' % compiler_string |
Caroline Tice | 80eab98 | 2015-11-04 14:03:14 -0800 | [diff] [blame] | 198 | if USE_NEXT_GCC_PATCH in self._patches: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 199 | label_string = 'gcc_next_trybot_image' |
Caroline Tice | 80eab98 | 2015-11-04 14:03:14 -0800 | [diff] [blame] | 200 | |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 201 | experiment_image = """ |
Caroline Tice | 80eab98 | 2015-11-04 14:03:14 -0800 | [diff] [blame] | 202 | %s { |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 203 | chromeos_root: %s |
| 204 | build: %s |
Caroline Tice | ddde505 | 2015-09-23 09:43:35 -0700 | [diff] [blame] | 205 | compiler: %s |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 206 | } |
Caroline Tice | 80eab98 | 2015-11-04 14:03:14 -0800 | [diff] [blame] | 207 | """ % (label_string, self._chromeos_root, trybot_image, |
| 208 | compiler_string) |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 209 | f.write(experiment_image) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 210 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 211 | crosperf = os.path.join(TOOLCHAIN_DIR, 'crosperf', 'crosperf') |
Han Shen | 4349429 | 2015-09-14 10:26:40 -0700 | [diff] [blame] | 212 | noschedv2_opts = '--noschedv2' if self._noschedv2 else '' |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 213 | command = ('{crosperf} --no_email=True --results_dir={r_dir} ' |
| 214 | '--json_report=True {noschedv2_opts} {exp_file}').format( |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 215 | crosperf=crosperf, |
| 216 | r_dir=self._reports_dir, |
| 217 | noschedv2_opts=noschedv2_opts, |
| 218 | exp_file=experiment_file) |
cmtice | aa700b0 | 2015-06-12 13:26:47 -0700 | [diff] [blame] | 219 | |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 220 | ret = self._ce.RunCommand(command) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 221 | if ret != 0: |
Manoj Gupta | aee96b7 | 2016-10-24 13:43:28 -0700 | [diff] [blame^] | 222 | raise RuntimeError('Crosperf execution error!') |
Caroline Tice | ebbc3da | 2015-09-03 10:27:20 -0700 | [diff] [blame] | 223 | else: |
| 224 | # Copy json report to pending archives directory. |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 225 | command = 'cp %s/*.json %s/.' % (self._reports_dir, PENDING_ARCHIVES_DIR) |
Caroline Tice | ebbc3da | 2015-09-03 10:27:20 -0700 | [diff] [blame] | 226 | ret = self._ce.RunCommand(command) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 227 | return |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 228 | |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 229 | def _CopyWeeklyReportFiles(self, trybot_image, vanilla_image, nonafdo_image): |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 230 | """Put files in place for running seven-day reports. |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 231 | |
| 232 | Create tar files of the custom and official images and copy them |
| 233 | to the weekly reports directory, so they exist when the weekly report |
| 234 | gets generated. IMPORTANT NOTE: This function must run *after* |
| 235 | crosperf has been run; otherwise the vanilla images will not be there. |
| 236 | """ |
| 237 | |
| 238 | dry_run = False |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 239 | if os.getlogin() != ROLE_ACCOUNT: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 240 | self._l.LogOutput('Running this from non-role account; not copying ' |
| 241 | 'tar files for weekly reports.') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 242 | dry_run = True |
| 243 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 244 | images_path = os.path.join( |
| 245 | os.path.realpath(self._chromeos_root), 'chroot/tmp') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 246 | |
| 247 | data_dir = os.path.join(WEEKLY_REPORTS_ROOT, self._board) |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 248 | dest_dir = os.path.join(data_dir, self._weekday) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 249 | if not os.path.exists(dest_dir): |
| 250 | os.makedirs(dest_dir) |
| 251 | |
| 252 | # Make sure dest_dir is empty (clean out last week's data). |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 253 | cmd = 'cd %s; rm -Rf %s_*_image*' % (dest_dir, self._weekday) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 254 | if dry_run: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 255 | print('CMD: %s' % cmd) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 256 | else: |
| 257 | self._ce.RunCommand(cmd) |
| 258 | |
| 259 | # Now create new tar files and copy them over. |
Luis Lozano | 439f2b7 | 2016-01-08 11:56:02 -0800 | [diff] [blame] | 260 | labels = {'test': trybot_image, 'vanilla': vanilla_image} |
| 261 | if nonafdo_image: |
| 262 | labels['nonafdo'] = nonafdo_image |
| 263 | for label_name, test_path in labels.iteritems(): |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 264 | tar_file_name = '%s_%s_image.tar' % (self._weekday, label_name) |
| 265 | cmd = ('cd %s; tar -cvf %s %s/chromiumos_test_image.bin; ' |
| 266 | 'cp %s %s/.') % (images_path, tar_file_name, test_path, |
| 267 | tar_file_name, dest_dir) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 268 | if dry_run: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 269 | print('CMD: %s' % cmd) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 270 | tar_ret = 0 |
| 271 | else: |
| 272 | tar_ret = self._ce.RunCommand(cmd) |
| 273 | if tar_ret: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 274 | self._l.LogOutput('Error while creating/copying test tar file(%s).' % |
| 275 | tar_file_name) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 276 | |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 277 | def _SendEmail(self): |
| 278 | """Find email message generated by crosperf and send it.""" |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 279 | filename = os.path.join(self._reports_dir, 'msg_body.html') |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 280 | if (os.path.exists(filename) and |
| 281 | os.path.exists(os.path.expanduser(MAIL_PROGRAM))): |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 282 | email_title = 'buildbot test results' |
Yunlian Jiang | 2f56356 | 2015-08-28 13:54:04 -0700 | [diff] [blame] | 283 | if self._patches_string == USE_LLVM_PATCH: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 284 | email_title = 'buildbot llvm test results' |
| 285 | command = ('cat %s | %s -s "%s, %s" -team -html' % |
| 286 | (filename, MAIL_PROGRAM, email_title, self._board)) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 287 | self._ce.RunCommand(command) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 288 | |
| 289 | def DoAll(self): |
Yunlian Jiang | 14cf596 | 2015-12-11 15:50:14 -0800 | [diff] [blame] | 290 | """Main function inside ToolchainComparator class. |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 291 | |
| 292 | Launch trybot, get image names, create crosperf experiment file, run |
| 293 | crosperf, and copy images into seven-day report directories. |
| 294 | """ |
cmtice | ce5ffa4 | 2015-02-12 15:18:43 -0800 | [diff] [blame] | 295 | date_str = datetime.date.today() |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 296 | description = 'master_%s_%s_%s' % (self._patches_string, self._build, |
Han Shen | fe054f1 | 2015-02-18 15:00:13 -0800 | [diff] [blame] | 297 | date_str) |
Manoj Gupta | aee96b7 | 2016-10-24 13:43:28 -0700 | [diff] [blame^] | 298 | trybot_image = buildbot_utils.GetTrybotImage( |
| 299 | self._chromeos_root, |
| 300 | self._build, |
| 301 | self._patches, |
| 302 | description, |
| 303 | other_flags=['--notests'], |
| 304 | build_toolchain=True) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 305 | |
cmtice | d54f980 | 2015-02-05 11:04:11 -0800 | [diff] [blame] | 306 | if len(trybot_image) == 0: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 307 | self._l.LogError('Unable to find trybot_image for %s!' % description) |
Luis Lozano | 7f20acb | 2015-11-04 17:15:08 -0800 | [diff] [blame] | 308 | return 1 |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 309 | |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 310 | vanilla_image = self._GetVanillaImageName(trybot_image) |
| 311 | nonafdo_image = self._GetNonAFDOImageName(trybot_image) |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 312 | |
Yunlian Jiang | 56f1376 | 2016-01-06 12:56:24 -0800 | [diff] [blame] | 313 | # The trybot image is ready here, in some cases, the vanilla image |
| 314 | # is not ready, so we need to make sure vanilla image is available. |
| 315 | buildbot_utils.WaitForImage(self._chromeos_root, vanilla_image) |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 316 | print('trybot_image: %s' % trybot_image) |
| 317 | print('vanilla_image: %s' % vanilla_image) |
| 318 | print('nonafdo_image: %s' % nonafdo_image) |
Luis Lozano | c75fd05 | 2016-02-19 17:37:01 -0800 | [diff] [blame] | 319 | |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 320 | if os.getlogin() == ROLE_ACCOUNT: |
| 321 | self._FinishSetup() |
| 322 | |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 323 | self._TestImages(trybot_image, vanilla_image, nonafdo_image) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 324 | self._SendEmail() |
Yunlian Jiang | 3c6e467 | 2015-08-24 15:58:22 -0700 | [diff] [blame] | 325 | if (self._patches_string == USE_NEXT_GCC_PATCH and |
| 326 | self._board in WEEKLY_REPORT_BOARDS): |
Luis Lozano | 7f20acb | 2015-11-04 17:15:08 -0800 | [diff] [blame] | 327 | # Only try to copy the image files if the test runs ran successfully. |
Luis Lozano | 783954f | 2015-12-21 18:06:29 -0800 | [diff] [blame] | 328 | self._CopyWeeklyReportFiles(trybot_image, vanilla_image, nonafdo_image) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 329 | return 0 |
| 330 | |
| 331 | |
| 332 | def Main(argv): |
| 333 | """The main function.""" |
| 334 | |
| 335 | # Common initializations |
| 336 | command_executer.InitCommandExecuter() |
Caroline Tice | eddb063 | 2016-04-14 09:19:02 -0700 | [diff] [blame] | 337 | parser = argparse.ArgumentParser() |
Manoj Gupta | aee96b7 | 2016-10-24 13:43:28 -0700 | [diff] [blame^] | 338 | parser.add_argument( |
| 339 | '--remote', dest='remote', help='Remote machines to run tests on.') |
| 340 | parser.add_argument( |
| 341 | '--board', dest='board', default='x86-zgb', help='The target board.') |
| 342 | parser.add_argument( |
| 343 | '--chromeos_root', |
| 344 | dest='chromeos_root', |
| 345 | help='The chromeos root from which to run tests.') |
| 346 | parser.add_argument( |
| 347 | '--weekday', |
| 348 | default='', |
| 349 | dest='weekday', |
| 350 | help='The day of the week for which to run tests.') |
| 351 | parser.add_argument( |
| 352 | '--patch', |
| 353 | dest='patches', |
| 354 | help='The patches to use for the testing, ' |
| 355 | "seprate the patch numbers with ',' " |
| 356 | 'for more than one patches.') |
| 357 | parser.add_argument( |
| 358 | '--noschedv2', |
| 359 | dest='noschedv2', |
| 360 | action='store_true', |
| 361 | default=False, |
| 362 | help='Pass --noschedv2 to crosperf.') |
Han Shen | 3641312 | 2015-08-28 11:05:40 -0700 | [diff] [blame] | 363 | |
Caroline Tice | eddb063 | 2016-04-14 09:19:02 -0700 | [diff] [blame] | 364 | options = parser.parse_args(argv[1:]) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 365 | if not options.board: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 366 | print('Please give a board.') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 367 | return 1 |
| 368 | if not options.remote: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 369 | print('Please give at least one remote machine.') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 370 | return 1 |
| 371 | if not options.chromeos_root: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 372 | print('Please specify the ChromeOS root directory.') |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 373 | return 1 |
Yunlian Jiang | 76259e6 | 2015-08-21 08:44:31 -0700 | [diff] [blame] | 374 | if options.patches: |
Yunlian Jiang | 3c6e467 | 2015-08-24 15:58:22 -0700 | [diff] [blame] | 375 | patches = options.patches |
| 376 | else: |
| 377 | patches = USE_NEXT_GCC_PATCH |
Yunlian Jiang | e52838c | 2015-08-20 14:32:37 -0700 | [diff] [blame] | 378 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 379 | fc = ToolchainComparator(options.board, options.remote, options.chromeos_root, |
| 380 | options.weekday, patches, options.noschedv2) |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 381 | return fc.DoAll() |
| 382 | |
| 383 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 384 | if __name__ == '__main__': |
cmtice | 46093e5 | 2014-12-09 14:59:16 -0800 | [diff] [blame] | 385 | retval = Main(sys.argv) |
| 386 | sys.exit(retval) |