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