asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # Script to test different toolchains against ChromeOS benchmarks. |
cmtice | 7cdb11a | 2015-05-28 10:24:41 -0700 | [diff] [blame] | 4 | import datetime |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 5 | import optparse |
| 6 | import os |
| 7 | import sys |
| 8 | import build_chromeos |
| 9 | import setup_chromeos |
cmtice | 94bc470 | 2014-05-29 16:29:04 -0700 | [diff] [blame] | 10 | import time |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 11 | from utils import command_executer |
| 12 | from utils import misc |
| 13 | from utils import logger |
| 14 | |
| 15 | |
Caroline Tice | ebbc3da | 2015-09-03 10:27:20 -0700 | [diff] [blame] | 16 | CROSTC_ROOT = "/usr/local/google/crostc" |
cmtice | 23130bd | 2014-07-15 11:19:29 -0700 | [diff] [blame] | 17 | AFDO_BOARDS = ["butterfly", "lumpy", "stumpy", "stout", "parrot", "parrot_ivb"] |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 18 | MAIL_PROGRAM = "~/var/bin/mail-sheriff" |
Caroline Tice | ebbc3da | 2015-09-03 10:27:20 -0700 | [diff] [blame] | 19 | WEEKLY_REPORTS_ROOT = os.path.join(CROSTC_ROOT, "weekly_test_data") |
| 20 | PENDING_ARCHIVES_DIR = os.path.join(CROSTC_ROOT, "pending_archives") |
| 21 | NIGHTLY_TESTS_DIR = os.path.join(CROSTC_ROOT, "nightly_test_reports") |
cmtice | 94bc470 | 2014-05-29 16:29:04 -0700 | [diff] [blame] | 22 | |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 23 | class GCCConfig(object): |
| 24 | def __init__(self, githash): |
| 25 | self.githash = githash |
| 26 | |
| 27 | |
| 28 | class ToolchainConfig: |
| 29 | def __init__(self, gcc_config=None, binutils_config=None): |
| 30 | self.gcc_config = gcc_config |
| 31 | |
| 32 | |
| 33 | class ChromeOSCheckout(object): |
| 34 | def __init__(self, board, chromeos_root): |
| 35 | self._board = board |
| 36 | self._chromeos_root = chromeos_root |
| 37 | self._ce = command_executer.GetCommandExecuter() |
| 38 | self._l = logger.GetLogger() |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 39 | self._build_num = None |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 40 | |
asharif | 3e38de0 | 2013-02-19 19:34:59 +0000 | [diff] [blame] | 41 | def _DeleteChroot(self): |
asharif | 8741427 | 2013-02-19 19:58:45 +0000 | [diff] [blame] | 42 | command = "cd %s; cros_sdk --delete" % self._chromeos_root |
asharif | 3e38de0 | 2013-02-19 19:34:59 +0000 | [diff] [blame] | 43 | return self._ce.RunCommand(command) |
| 44 | |
asharif | 6797358 | 2013-02-19 20:19:40 +0000 | [diff] [blame] | 45 | def _DeleteCcahe(self): |
| 46 | # crosbug.com/34956 |
| 47 | command = "sudo rm -rf %s" % os.path.join(self._chromeos_root, ".cache") |
| 48 | return self._ce.RunCommand(command) |
| 49 | |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 50 | def _GetBuildNumber(self): |
| 51 | """ This function assumes a ChromeOS image has been built in the chroot. |
| 52 | It translates the 'latest' symlink in the |
| 53 | <chroot>/src/build/images/<board> directory, to find the actual |
| 54 | ChromeOS build number for the image that was built. For example, if |
| 55 | src/build/image/lumpy/latest -> R37-5982.0.2014_06_23_0454-a1, then |
| 56 | This function would parse it out and assign 'R37-5982' to self._build_num. |
| 57 | This is used to determine the official, vanilla build to use for |
| 58 | comparison tests. |
| 59 | """ |
| 60 | # Get the path to 'latest' |
| 61 | sym_path = os.path.join (misc.GetImageDir(self._chromeos_root, |
| 62 | self._board), |
| 63 | "latest") |
| 64 | # Translate the symlink to its 'real' path. |
| 65 | real_path = os.path.realpath(sym_path) |
| 66 | # Break up the path and get the last piece |
| 67 | # (e.g. 'R37-5982.0.2014_06_23_0454-a1" |
| 68 | path_pieces = real_path.split("/") |
| 69 | last_piece = path_pieces[-1] |
| 70 | # Break this piece into the image number + other pieces, and get the |
| 71 | # image number [ 'R37-5982', '0', '2014_06_23_0454-a1'] |
| 72 | image_parts = last_piece.split(".") |
| 73 | self._build_num = image_parts[0] |
| 74 | |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 75 | def _BuildAndImage(self, label=""): |
| 76 | if (not label or |
| 77 | not misc.DoesLabelExist(self._chromeos_root, self._board, label)): |
| 78 | build_chromeos_args = [build_chromeos.__file__, |
| 79 | "--chromeos_root=%s" % self._chromeos_root, |
| 80 | "--board=%s" % self._board, |
| 81 | "--rebuild"] |
asharif | e6b72fe | 2013-02-19 19:58:18 +0000 | [diff] [blame] | 82 | if self._public: |
| 83 | build_chromeos_args.append("--env=USE=-chrome_internal") |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 84 | |
cmtice | 23130bd | 2014-07-15 11:19:29 -0700 | [diff] [blame] | 85 | if self._board in AFDO_BOARDS: |
| 86 | build_chromeos_args.append("--env=USE=afdo_use") |
| 87 | |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 88 | ret = build_chromeos.Main(build_chromeos_args) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 89 | if ret != 0: |
| 90 | raise RuntimeError("Couldn't build ChromeOS!") |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 91 | |
| 92 | if not self._build_num: |
| 93 | self._GetBuildNumber() |
| 94 | # Check to see if we need to create the symbolic link for the vanilla |
| 95 | # image, and do so if appropriate. |
| 96 | if not misc.DoesLabelExist(self._chromeos_root, self._board, "vanilla"): |
| 97 | build_name = "%s-release/%s.0.0" % (self._board, self._build_num) |
| 98 | full_vanilla_path = os.path.join (os.getcwd(), self._chromeos_root, |
| 99 | 'chroot/tmp', build_name) |
| 100 | misc.LabelLatestImage(self._chromeos_root, self._board, label, |
| 101 | full_vanilla_path) |
| 102 | else: |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 103 | misc.LabelLatestImage(self._chromeos_root, self._board, label) |
| 104 | return label |
| 105 | |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 106 | def _SetupBoard(self, env_dict, usepkg_flag, clobber_flag): |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 107 | env_string = misc.GetEnvStringFromDict(env_dict) |
| 108 | command = ("%s %s" % |
| 109 | (env_string, |
| 110 | misc.GetSetupBoardCommand(self._board, |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 111 | usepkg=usepkg_flag, |
| 112 | force=clobber_flag))) |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 113 | ret = self._ce.ChrootRunCommand(self._chromeos_root, |
| 114 | command) |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 115 | error_str = "Could not setup board: '%s'" % command |
| 116 | assert ret == 0, error_str |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 117 | |
| 118 | def _UnInstallToolchain(self): |
| 119 | command = ("sudo CLEAN_DELAY=0 emerge -C cross-%s/gcc" % |
| 120 | misc.GetCtargetFromBoard(self._board, |
| 121 | self._chromeos_root)) |
| 122 | ret = self._ce.ChrootRunCommand(self._chromeos_root, |
| 123 | command) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 124 | if ret != 0: |
| 125 | raise RuntimeError("Couldn't uninstall the toolchain!") |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 126 | |
| 127 | def _CheckoutChromeOS(self): |
| 128 | # TODO(asharif): Setup a fixed ChromeOS version (quarterly snapshot). |
| 129 | if not os.path.exists(self._chromeos_root): |
| 130 | setup_chromeos_args = [setup_chromeos.__file__, |
Caroline Tice | c35909e | 2013-10-02 17:13:13 -0700 | [diff] [blame] | 131 | "--dir=%s" % self._chromeos_root] |
asharif | e6b72fe | 2013-02-19 19:58:18 +0000 | [diff] [blame] | 132 | if self._public: |
| 133 | setup_chromeos_args.append("--public") |
asharif | 5fe40e2 | 2013-02-19 19:58:50 +0000 | [diff] [blame] | 134 | ret = setup_chromeos.Main(setup_chromeos_args) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 135 | if ret != 0: |
| 136 | raise RuntimeError("Couldn't run setup_chromeos!") |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 137 | |
Caroline Tice | c35909e | 2013-10-02 17:13:13 -0700 | [diff] [blame] | 138 | |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 139 | def _BuildToolchain(self, config): |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 140 | # Call setup_board for basic, vanilla setup. |
| 141 | self._SetupBoard({}, usepkg_flag=True, clobber_flag=False) |
| 142 | # Now uninstall the vanilla compiler and setup/build our custom |
| 143 | # compiler. |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 144 | self._UnInstallToolchain() |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 145 | envdict = {"USE": "git_gcc", |
| 146 | "GCC_GITHASH": config.gcc_config.githash, |
| 147 | "EMERGE_DEFAULT_OPTS": "--exclude=gcc"} |
| 148 | self._SetupBoard(envdict, usepkg_flag=False, clobber_flag=False) |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 149 | |
| 150 | |
| 151 | class ToolchainComparator(ChromeOSCheckout): |
Han Shen | 3641312 | 2015-08-28 11:05:40 -0700 | [diff] [blame] | 152 | def __init__(self, board, remotes, configs, clean, |
Han Shen | 4349429 | 2015-09-14 10:26:40 -0700 | [diff] [blame] | 153 | public, force_mismatch, noschedv2=False): |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 154 | self._board = board |
| 155 | self._remotes = remotes |
| 156 | self._chromeos_root = "chromeos" |
| 157 | self._configs = configs |
asharif | 3e38de0 | 2013-02-19 19:34:59 +0000 | [diff] [blame] | 158 | self._clean = clean |
asharif | e6b72fe | 2013-02-19 19:58:18 +0000 | [diff] [blame] | 159 | self._public = public |
asharif | 58a8c9f | 2013-02-19 20:42:43 +0000 | [diff] [blame] | 160 | self._force_mismatch = force_mismatch |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 161 | self._ce = command_executer.GetCommandExecuter() |
| 162 | self._l = logger.GetLogger() |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 163 | timestamp = datetime.datetime.strftime(datetime.datetime.now(), |
| 164 | "%Y-%m-%d_%H:%M:%S") |
Caroline Tice | ebbc3da | 2015-09-03 10:27:20 -0700 | [diff] [blame] | 165 | self._reports_dir = os.path.join(NIGHTLY_TESTS_DIR, |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 166 | "%s.%s" % (timestamp, board), |
| 167 | ) |
Han Shen | 4349429 | 2015-09-14 10:26:40 -0700 | [diff] [blame] | 168 | self._noschedv2 = noschedv2 |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 169 | ChromeOSCheckout.__init__(self, board, self._chromeos_root) |
| 170 | |
cmtice | a6255d0 | 2014-01-10 10:27:22 -0800 | [diff] [blame] | 171 | |
| 172 | def _FinishSetup(self): |
| 173 | # Get correct .boto file |
| 174 | current_dir = os.getcwd() |
Caroline Tice | ebbc3da | 2015-09-03 10:27:20 -0700 | [diff] [blame] | 175 | src = "/usr/local/google/home/mobiletc-prebuild/.boto" |
cmtice | a6255d0 | 2014-01-10 10:27:22 -0800 | [diff] [blame] | 176 | dest = os.path.join(current_dir, self._chromeos_root, |
| 177 | "src/private-overlays/chromeos-overlay/" |
| 178 | "googlestorage_account.boto") |
| 179 | # Copy the file to the correct place |
| 180 | copy_cmd = "cp %s %s" % (src, dest) |
| 181 | retval = self._ce.RunCommand(copy_cmd) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 182 | if retval != 0: |
| 183 | raise RuntimeError("Couldn't copy .boto file for google storage.") |
cmtice | a6255d0 | 2014-01-10 10:27:22 -0800 | [diff] [blame] | 184 | |
| 185 | # Fix protections on ssh key |
| 186 | command = ("chmod 600 /var/cache/chromeos-cache/distfiles/target" |
| 187 | "/chrome-src-internal/src/third_party/chromite/ssh_keys" |
| 188 | "/testing_rsa") |
| 189 | retval = self._ce.ChrootRunCommand(self._chromeos_root, command) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 190 | if retval != 0: |
| 191 | raise RuntimeError("chmod for testing_rsa failed") |
cmtice | a6255d0 | 2014-01-10 10:27:22 -0800 | [diff] [blame] | 192 | |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 193 | def _TestLabels(self, labels): |
| 194 | experiment_file = "toolchain_experiment.txt" |
asharif | 58a8c9f | 2013-02-19 20:42:43 +0000 | [diff] [blame] | 195 | image_args = "" |
| 196 | if self._force_mismatch: |
asharif | 0b5d5c8 | 2013-02-19 20:42:56 +0000 | [diff] [blame] | 197 | image_args = "--force-mismatch" |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 198 | experiment_header = """ |
| 199 | board: %s |
| 200 | remote: %s |
cmtice | d1f03b8 | 2015-06-30 15:19:23 -0700 | [diff] [blame] | 201 | retries: 1 |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 202 | """ % (self._board, self._remotes) |
| 203 | experiment_tests = """ |
cmtice | 0c84ea7 | 2015-06-25 14:22:36 -0700 | [diff] [blame] | 204 | benchmark: all_toolchain_perf { |
cmtice | 0440388 | 2013-11-04 16:38:37 -0500 | [diff] [blame] | 205 | suite: telemetry_Crosperf |
cmtice | 6de7f8f | 2014-03-14 14:08:21 -0700 | [diff] [blame] | 206 | iterations: 3 |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 207 | } |
| 208 | """ |
| 209 | with open(experiment_file, "w") as f: |
| 210 | print >>f, experiment_header |
| 211 | print >>f, experiment_tests |
| 212 | for label in labels: |
| 213 | # TODO(asharif): Fix crosperf so it accepts labels with symbols |
| 214 | crosperf_label = label |
| 215 | crosperf_label = crosperf_label.replace("-", "minus") |
| 216 | crosperf_label = crosperf_label.replace("+", "plus") |
asharif | e4a5a8f | 2013-02-19 20:19:33 +0000 | [diff] [blame] | 217 | crosperf_label = crosperf_label.replace(".", "") |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 218 | |
| 219 | # Use the official build instead of building vanilla ourselves. |
| 220 | if label == "vanilla": |
| 221 | build_name = '%s-release/%s.0.0' % (self._board, self._build_num) |
| 222 | |
| 223 | # Now add 'official build' to test file. |
| 224 | official_image = """ |
| 225 | official_image { |
| 226 | chromeos_root: %s |
| 227 | build: %s |
| 228 | } |
| 229 | """ % (self._chromeos_root, build_name) |
| 230 | print >>f, official_image |
| 231 | |
cmtice | 94bc470 | 2014-05-29 16:29:04 -0700 | [diff] [blame] | 232 | else: |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 233 | experiment_image = """ |
| 234 | %s { |
| 235 | chromeos_image: %s |
| 236 | image_args: %s |
| 237 | } |
| 238 | """ % (crosperf_label, |
| 239 | os.path.join(misc.GetImageDir(self._chromeos_root, |
| 240 | self._board), |
| 241 | label, "chromiumos_test_image.bin"), |
| 242 | image_args) |
| 243 | print >>f, experiment_image |
| 244 | |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 245 | crosperf = os.path.join(os.path.dirname(__file__), |
| 246 | "crosperf", |
| 247 | "crosperf") |
Han Shen | 4349429 | 2015-09-14 10:26:40 -0700 | [diff] [blame] | 248 | noschedv2_opts = '--noschedv2' if self._noschedv2 else '' |
Han Shen | 3641312 | 2015-08-28 11:05:40 -0700 | [diff] [blame] | 249 | command = ("{crosperf} --no_email=True --results_dir={r_dir} " |
Han Shen | 4349429 | 2015-09-14 10:26:40 -0700 | [diff] [blame] | 250 | "--json_report=True {noschedv2_opts} {exp_file}").format( |
Han Shen | 3641312 | 2015-08-28 11:05:40 -0700 | [diff] [blame] | 251 | crosperf=crosperf, |
| 252 | r_dir=self._reports_dir, |
Han Shen | 4349429 | 2015-09-14 10:26:40 -0700 | [diff] [blame] | 253 | noschedv2_opts=noschedv2_opts, |
Han Shen | 3641312 | 2015-08-28 11:05:40 -0700 | [diff] [blame] | 254 | exp_file=experiment_file) |
cmtice | aa700b0 | 2015-06-12 13:26:47 -0700 | [diff] [blame] | 255 | |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 256 | ret = self._ce.RunCommand(command) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 257 | if ret != 0: |
| 258 | raise RuntimeError("Couldn't run crosperf!") |
Caroline Tice | ebbc3da | 2015-09-03 10:27:20 -0700 | [diff] [blame] | 259 | else: |
| 260 | # Copy json report to pending archives directory. |
| 261 | command = "cp %s/*.json %s/." % (self._reports_dir, PENDING_ARCHIVES_DIR) |
| 262 | ret = self._ce.RunCommand(command) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 263 | return |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 264 | |
| 265 | |
| 266 | def _CopyWeeklyReportFiles(self, labels): |
| 267 | """Create tar files of the custom and official images and copy them |
| 268 | to the weekly reports directory, so they exist when the weekly report |
| 269 | gets generated. IMPORTANT NOTE: This function must run *after* |
| 270 | crosperf has been run; otherwise the vanilla images will not be there. |
| 271 | """ |
| 272 | images_path = os.path.join(os.path.realpath(self._chromeos_root), |
| 273 | "src/build/images", self._board) |
| 274 | weekday = time.strftime("%a") |
| 275 | data_dir = os.path.join(WEEKLY_REPORTS_ROOT, self._board) |
| 276 | dest_dir = os.path.join (data_dir, weekday) |
| 277 | if not os.path.exists(dest_dir): |
| 278 | os.makedirs(dest_dir) |
cmtice | 4536ef6 | 2014-07-08 11:17:21 -0700 | [diff] [blame] | 279 | # Make sure dest_dir is empty (clean out last week's data). |
| 280 | cmd = "cd %s; rm -Rf %s_*_image*" % (dest_dir, weekday) |
| 281 | self._ce.RunCommand(cmd) |
| 282 | # Now create new tar files and copy them over. |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 283 | for l in labels: |
| 284 | test_path = os.path.join(images_path, l) |
| 285 | if os.path.exists(test_path): |
| 286 | if l != "vanilla": |
| 287 | label_name = "test" |
| 288 | else: |
| 289 | label_name = "vanilla" |
| 290 | tar_file_name = "%s_%s_image.tar" % (weekday, label_name) |
Han Shen | fe054f1 | 2015-02-18 15:00:13 -0800 | [diff] [blame] | 291 | cmd = ("cd %s; tar -cvf %s %s/chromiumos_test_image.bin; " |
| 292 | "cp %s %s/.") % (images_path, |
| 293 | tar_file_name, |
| 294 | l, tar_file_name, |
| 295 | dest_dir) |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 296 | tar_ret = self._ce.RunCommand(cmd) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 297 | if tar_ret != 0: |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 298 | self._l.LogOutput("Error while creating/copying test tar file(%s)." |
| 299 | % tar_file_name) |
| 300 | |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 301 | def _SendEmail(self): |
| 302 | """Find email msesage generated by crosperf and send it.""" |
| 303 | filename = os.path.join(self._reports_dir, "msg_body.html") |
| 304 | if (os.path.exists(filename) and |
| 305 | os.path.exists(os.path.expanduser(MAIL_PROGRAM))): |
cmtice | 0495c71 | 2015-05-28 15:21:07 -0700 | [diff] [blame] | 306 | command = ('cat %s | %s -s "Nightly test results, %s" -team -html' |
| 307 | % (filename, MAIL_PROGRAM, self._board)) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 308 | self._ce.RunCommand(command) |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 309 | |
| 310 | def DoAll(self): |
| 311 | self._CheckoutChromeOS() |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 312 | labels = [] |
cmtice | 56fb716 | 2014-06-18 11:32:15 -0700 | [diff] [blame] | 313 | labels.append("vanilla") |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 314 | for config in self._configs: |
| 315 | label = misc.GetFilenameFromString(config.gcc_config.githash) |
| 316 | if (not misc.DoesLabelExist(self._chromeos_root, |
| 317 | self._board, |
| 318 | label)): |
| 319 | self._BuildToolchain(config) |
| 320 | label = self._BuildAndImage(label) |
| 321 | labels.append(label) |
cmtice | a6255d0 | 2014-01-10 10:27:22 -0800 | [diff] [blame] | 322 | self._FinishSetup() |
cmtice | b458809 | 2015-05-27 08:07:50 -0700 | [diff] [blame] | 323 | self._TestLabels(labels) |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 324 | self._SendEmail() |
| 325 | # Only try to copy the image files if the test runs ran successfully. |
| 326 | self._CopyWeeklyReportFiles(labels) |
asharif | 3e38de0 | 2013-02-19 19:34:59 +0000 | [diff] [blame] | 327 | if self._clean: |
| 328 | ret = self._DeleteChroot() |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 329 | if ret != 0: |
| 330 | return ret |
asharif | 6797358 | 2013-02-19 20:19:40 +0000 | [diff] [blame] | 331 | ret = self._DeleteCcahe() |
cmtice | 7f3190b | 2015-05-22 14:14:51 -0700 | [diff] [blame] | 332 | if ret != 0: |
| 333 | return ret |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 334 | return 0 |
| 335 | |
| 336 | |
| 337 | def Main(argv): |
| 338 | """The main function.""" |
| 339 | # Common initializations |
| 340 | ### command_executer.InitCommandExecuter(True) |
| 341 | command_executer.InitCommandExecuter() |
| 342 | parser = optparse.OptionParser() |
| 343 | parser.add_option("--remote", |
| 344 | dest="remote", |
| 345 | help="Remote machines to run tests on.") |
| 346 | parser.add_option("--board", |
| 347 | dest="board", |
| 348 | default="x86-zgb", |
| 349 | help="The target board.") |
| 350 | parser.add_option("--githashes", |
| 351 | dest="githashes", |
| 352 | default="master", |
| 353 | help="The gcc githashes to test.") |
asharif | 3e38de0 | 2013-02-19 19:34:59 +0000 | [diff] [blame] | 354 | parser.add_option("--clean", |
| 355 | dest="clean", |
| 356 | default=False, |
| 357 | action="store_true", |
| 358 | help="Clean the chroot after testing.") |
asharif | e6b72fe | 2013-02-19 19:58:18 +0000 | [diff] [blame] | 359 | parser.add_option("--public", |
| 360 | dest="public", |
| 361 | default=False, |
| 362 | action="store_true", |
| 363 | help="Use the public checkout/build.") |
asharif | 58a8c9f | 2013-02-19 20:42:43 +0000 | [diff] [blame] | 364 | parser.add_option("--force-mismatch", |
| 365 | dest="force_mismatch", |
| 366 | default="", |
| 367 | help="Force the image regardless of board mismatch") |
Han Shen | 4349429 | 2015-09-14 10:26:40 -0700 | [diff] [blame] | 368 | parser.add_option("--noschedv2", |
| 369 | dest="noschedv2", |
Han Shen | 3641312 | 2015-08-28 11:05:40 -0700 | [diff] [blame] | 370 | action="store_true", |
| 371 | default=False, |
Han Shen | 4349429 | 2015-09-14 10:26:40 -0700 | [diff] [blame] | 372 | help="Pass --noschedv2 to crosperf.") |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 373 | options, _ = parser.parse_args(argv) |
| 374 | if not options.board: |
| 375 | print "Please give a board." |
| 376 | return 1 |
| 377 | if not options.remote: |
| 378 | print "Please give at least one remote machine." |
| 379 | return 1 |
| 380 | toolchain_configs = [] |
| 381 | for githash in options.githashes.split(","): |
| 382 | gcc_config = GCCConfig(githash=githash) |
| 383 | toolchain_config = ToolchainConfig(gcc_config=gcc_config) |
| 384 | toolchain_configs.append(toolchain_config) |
asharif | 3e38de0 | 2013-02-19 19:34:59 +0000 | [diff] [blame] | 385 | fc = ToolchainComparator(options.board, options.remote, toolchain_configs, |
asharif | 58a8c9f | 2013-02-19 20:42:43 +0000 | [diff] [blame] | 386 | options.clean, options.public, |
Han Shen | 3641312 | 2015-08-28 11:05:40 -0700 | [diff] [blame] | 387 | options.force_mismatch, |
Han Shen | 4349429 | 2015-09-14 10:26:40 -0700 | [diff] [blame] | 388 | options.noschedv2) |
asharif | 96f5969 | 2013-02-16 03:13:36 +0000 | [diff] [blame] | 389 | return fc.DoAll() |
| 390 | |
| 391 | |
| 392 | if __name__ == "__main__": |
| 393 | retval = Main(sys.argv) |
| 394 | sys.exit(retval) |