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