blob: eccf2f55a24418e9ddf6c4742496f2d847729a4e [file] [log] [blame]
Caroline Tice88272d42016-01-13 09:48:29 -08001#!/usr/bin/python2
asharif96f59692013-02-16 03:13:36 +00002
3# Script to test different toolchains against ChromeOS benchmarks.
Caroline Tice88272d42016-01-13 09:48:29 -08004"""Toolchain team nightly performance test script (local builds)."""
5
6from __future__ import print_function
7
8import argparse
cmtice7cdb11a2015-05-28 10:24:41 -07009import datetime
asharif96f59692013-02-16 03:13:36 +000010import os
11import sys
12import build_chromeos
13import setup_chromeos
cmtice94bc4702014-05-29 16:29:04 -070014import time
Caroline Tice88272d42016-01-13 09:48:29 -080015from cros_utils import command_executer
16from cros_utils import misc
17from cros_utils import logger
asharif96f59692013-02-16 03:13:36 +000018
Luis Lozanof2a3ef42015-12-15 13:49:30 -080019CROSTC_ROOT = '/usr/local/google/crostc'
20MAIL_PROGRAM = '~/var/bin/mail-sheriff'
21WEEKLY_REPORTS_ROOT = os.path.join(CROSTC_ROOT, 'weekly_test_data')
22PENDING_ARCHIVES_DIR = os.path.join(CROSTC_ROOT, 'pending_archives')
23NIGHTLY_TESTS_DIR = os.path.join(CROSTC_ROOT, 'nightly_test_reports')
asharif96f59692013-02-16 03:13:36 +000024
cmtice94bc4702014-05-29 16:29:04 -070025
asharif96f59692013-02-16 03:13:36 +000026class GCCConfig(object):
Caroline Tice88272d42016-01-13 09:48:29 -080027 """GCC configuration class."""
Luis Lozanof2a3ef42015-12-15 13:49:30 -080028
asharif96f59692013-02-16 03:13:36 +000029 def __init__(self, githash):
30 self.githash = githash
31
32
Caroline Tice88272d42016-01-13 09:48:29 -080033class ToolchainConfig(object):
34 """Toolchain configuration class."""
Luis Lozanof2a3ef42015-12-15 13:49:30 -080035
Caroline Tice88272d42016-01-13 09:48:29 -080036 def __init__(self, gcc_config=None):
asharif96f59692013-02-16 03:13:36 +000037 self.gcc_config = gcc_config
38
39
40class ChromeOSCheckout(object):
Caroline Tice88272d42016-01-13 09:48:29 -080041 """Main class for checking out, building and testing ChromeOS."""
Luis Lozanof2a3ef42015-12-15 13:49:30 -080042
asharif96f59692013-02-16 03:13:36 +000043 def __init__(self, board, chromeos_root):
44 self._board = board
45 self._chromeos_root = chromeos_root
46 self._ce = command_executer.GetCommandExecuter()
47 self._l = logger.GetLogger()
cmtice56fb7162014-06-18 11:32:15 -070048 self._build_num = None
asharif96f59692013-02-16 03:13:36 +000049
asharif3e38de02013-02-19 19:34:59 +000050 def _DeleteChroot(self):
Luis Lozanof2a3ef42015-12-15 13:49:30 -080051 command = 'cd %s; cros_sdk --delete' % self._chromeos_root
asharif3e38de02013-02-19 19:34:59 +000052 return self._ce.RunCommand(command)
53
asharif67973582013-02-19 20:19:40 +000054 def _DeleteCcahe(self):
55 # crosbug.com/34956
Luis Lozanof2a3ef42015-12-15 13:49:30 -080056 command = 'sudo rm -rf %s' % os.path.join(self._chromeos_root, '.cache')
asharif67973582013-02-19 20:19:40 +000057 return self._ce.RunCommand(command)
58
cmtice56fb7162014-06-18 11:32:15 -070059 def _GetBuildNumber(self):
Caroline Tice88272d42016-01-13 09:48:29 -080060 """Get the build number of the ChromeOS image from the chroot.
61
62 This function assumes a ChromeOS image has been built in the chroot.
cmtice56fb7162014-06-18 11:32:15 -070063 It translates the 'latest' symlink in the
64 <chroot>/src/build/images/<board> directory, to find the actual
65 ChromeOS build number for the image that was built. For example, if
66 src/build/image/lumpy/latest -> R37-5982.0.2014_06_23_0454-a1, then
67 This function would parse it out and assign 'R37-5982' to self._build_num.
68 This is used to determine the official, vanilla build to use for
69 comparison tests.
70 """
71 # Get the path to 'latest'
Luis Lozanof2a3ef42015-12-15 13:49:30 -080072 sym_path = os.path.join(
73 misc.GetImageDir(self._chromeos_root, self._board), 'latest')
cmtice56fb7162014-06-18 11:32:15 -070074 # Translate the symlink to its 'real' path.
75 real_path = os.path.realpath(sym_path)
76 # Break up the path and get the last piece
77 # (e.g. 'R37-5982.0.2014_06_23_0454-a1"
Luis Lozanof2a3ef42015-12-15 13:49:30 -080078 path_pieces = real_path.split('/')
cmtice56fb7162014-06-18 11:32:15 -070079 last_piece = path_pieces[-1]
80 # Break this piece into the image number + other pieces, and get the
81 # image number [ 'R37-5982', '0', '2014_06_23_0454-a1']
Luis Lozanof2a3ef42015-12-15 13:49:30 -080082 image_parts = last_piece.split('.')
cmtice56fb7162014-06-18 11:32:15 -070083 self._build_num = image_parts[0]
84
Caroline Tice88272d42016-01-13 09:48:29 -080085 def _BuildLabelName(self, config):
Luis Lozanof2a3ef42015-12-15 13:49:30 -080086 pieces = config.split('/')
Caroline Tice80eab982015-11-04 14:03:14 -080087 compiler_version = pieces[-1]
Luis Lozanof2a3ef42015-12-15 13:49:30 -080088 label = compiler_version + '_tot_afdo'
Caroline Tice80eab982015-11-04 14:03:14 -080089 return label
90
Luis Lozanof2a3ef42015-12-15 13:49:30 -080091 def _BuildAndImage(self, label=''):
asharif96f59692013-02-16 03:13:36 +000092 if (not label or
93 not misc.DoesLabelExist(self._chromeos_root, self._board, label)):
Manoj Guptaaee96b72016-10-24 13:43:28 -070094 build_chromeos_args = [
95 build_chromeos.__file__, '--chromeos_root=%s' % self._chromeos_root,
96 '--board=%s' % self._board, '--rebuild'
97 ]
asharife6b72fe2013-02-19 19:58:18 +000098 if self._public:
Luis Lozanof2a3ef42015-12-15 13:49:30 -080099 build_chromeos_args.append('--env=USE=-chrome_internal')
cmtice56fb7162014-06-18 11:32:15 -0700100
asharif96f59692013-02-16 03:13:36 +0000101 ret = build_chromeos.Main(build_chromeos_args)
cmtice7f3190b2015-05-22 14:14:51 -0700102 if ret != 0:
103 raise RuntimeError("Couldn't build ChromeOS!")
cmtice56fb7162014-06-18 11:32:15 -0700104
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800105 if not self._build_num:
cmtice56fb7162014-06-18 11:32:15 -0700106 self._GetBuildNumber()
107 # Check to see if we need to create the symbolic link for the vanilla
108 # image, and do so if appropriate.
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800109 if not misc.DoesLabelExist(self._chromeos_root, self._board, 'vanilla'):
110 build_name = '%s-release/%s.0.0' % (self._board, self._build_num)
111 full_vanilla_path = os.path.join(os.getcwd(), self._chromeos_root,
112 'chroot/tmp', build_name)
cmtice56fb7162014-06-18 11:32:15 -0700113 misc.LabelLatestImage(self._chromeos_root, self._board, label,
114 full_vanilla_path)
115 else:
asharif96f59692013-02-16 03:13:36 +0000116 misc.LabelLatestImage(self._chromeos_root, self._board, label)
117 return label
118
cmtice56fb7162014-06-18 11:32:15 -0700119 def _SetupBoard(self, env_dict, usepkg_flag, clobber_flag):
asharif96f59692013-02-16 03:13:36 +0000120 env_string = misc.GetEnvStringFromDict(env_dict)
Manoj Guptaaee96b72016-10-24 13:43:28 -0700121 command = ('%s %s' % (env_string, misc.GetSetupBoardCommand(
122 self._board, usepkg=usepkg_flag, force=clobber_flag)))
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800123 ret = self._ce.ChrootRunCommand(self._chromeos_root, command)
cmtice56fb7162014-06-18 11:32:15 -0700124 error_str = "Could not setup board: '%s'" % command
125 assert ret == 0, error_str
asharif96f59692013-02-16 03:13:36 +0000126
127 def _UnInstallToolchain(self):
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800128 command = ('sudo CLEAN_DELAY=0 emerge -C cross-%s/gcc' %
129 misc.GetCtargetFromBoard(self._board, self._chromeos_root))
130 ret = self._ce.ChrootRunCommand(self._chromeos_root, command)
cmtice7f3190b2015-05-22 14:14:51 -0700131 if ret != 0:
132 raise RuntimeError("Couldn't uninstall the toolchain!")
asharif96f59692013-02-16 03:13:36 +0000133
134 def _CheckoutChromeOS(self):
135 # TODO(asharif): Setup a fixed ChromeOS version (quarterly snapshot).
136 if not os.path.exists(self._chromeos_root):
Rahul Chaudhry4d4565e2016-01-27 10:46:09 -0800137 setup_chromeos_args = ['--dir=%s' % self._chromeos_root]
asharife6b72fe2013-02-19 19:58:18 +0000138 if self._public:
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800139 setup_chromeos_args.append('--public')
asharif5fe40e22013-02-19 19:58:50 +0000140 ret = setup_chromeos.Main(setup_chromeos_args)
cmtice7f3190b2015-05-22 14:14:51 -0700141 if ret != 0:
142 raise RuntimeError("Couldn't run setup_chromeos!")
asharif96f59692013-02-16 03:13:36 +0000143
144 def _BuildToolchain(self, config):
cmtice56fb7162014-06-18 11:32:15 -0700145 # Call setup_board for basic, vanilla setup.
146 self._SetupBoard({}, usepkg_flag=True, clobber_flag=False)
147 # Now uninstall the vanilla compiler and setup/build our custom
148 # compiler.
asharif96f59692013-02-16 03:13:36 +0000149 self._UnInstallToolchain()
Manoj Guptaaee96b72016-10-24 13:43:28 -0700150 envdict = {
151 'USE': 'git_gcc',
152 'GCC_GITHASH': config.gcc_config.githash,
153 'EMERGE_DEFAULT_OPTS': '--exclude=gcc'
154 }
cmtice56fb7162014-06-18 11:32:15 -0700155 self._SetupBoard(envdict, usepkg_flag=False, clobber_flag=False)
asharif96f59692013-02-16 03:13:36 +0000156
157
158class ToolchainComparator(ChromeOSCheckout):
Caroline Tice88272d42016-01-13 09:48:29 -0800159 """Main class for running tests and generating reports."""
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800160
161 def __init__(self,
162 board,
163 remotes,
164 configs,
165 clean,
166 public,
167 force_mismatch,
168 noschedv2=False):
asharif96f59692013-02-16 03:13:36 +0000169 self._board = board
170 self._remotes = remotes
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800171 self._chromeos_root = 'chromeos'
asharif96f59692013-02-16 03:13:36 +0000172 self._configs = configs
asharif3e38de02013-02-19 19:34:59 +0000173 self._clean = clean
asharife6b72fe2013-02-19 19:58:18 +0000174 self._public = public
asharif58a8c9f2013-02-19 20:42:43 +0000175 self._force_mismatch = force_mismatch
asharif96f59692013-02-16 03:13:36 +0000176 self._ce = command_executer.GetCommandExecuter()
177 self._l = logger.GetLogger()
cmtice7f3190b2015-05-22 14:14:51 -0700178 timestamp = datetime.datetime.strftime(datetime.datetime.now(),
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800179 '%Y-%m-%d_%H:%M:%S')
Manoj Guptaaee96b72016-10-24 13:43:28 -0700180 self._reports_dir = os.path.join(
181 NIGHTLY_TESTS_DIR,
182 '%s.%s' % (timestamp, board),)
Han Shen43494292015-09-14 10:26:40 -0700183 self._noschedv2 = noschedv2
asharif96f59692013-02-16 03:13:36 +0000184 ChromeOSCheckout.__init__(self, board, self._chromeos_root)
185
cmticea6255d02014-01-10 10:27:22 -0800186 def _FinishSetup(self):
187 # Get correct .boto file
188 current_dir = os.getcwd()
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800189 src = '/usr/local/google/home/mobiletc-prebuild/.boto'
cmticea6255d02014-01-10 10:27:22 -0800190 dest = os.path.join(current_dir, self._chromeos_root,
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800191 'src/private-overlays/chromeos-overlay/'
192 'googlestorage_account.boto')
cmticea6255d02014-01-10 10:27:22 -0800193 # Copy the file to the correct place
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800194 copy_cmd = 'cp %s %s' % (src, dest)
Caroline Tice88272d42016-01-13 09:48:29 -0800195 retv = self._ce.RunCommand(copy_cmd)
196 if retv != 0:
cmtice7f3190b2015-05-22 14:14:51 -0700197 raise RuntimeError("Couldn't copy .boto file for google storage.")
cmticea6255d02014-01-10 10:27:22 -0800198
199 # Fix protections on ssh key
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800200 command = ('chmod 600 /var/cache/chromeos-cache/distfiles/target'
201 '/chrome-src-internal/src/third_party/chromite/ssh_keys'
202 '/testing_rsa')
Caroline Tice88272d42016-01-13 09:48:29 -0800203 retv = self._ce.ChrootRunCommand(self._chromeos_root, command)
204 if retv != 0:
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800205 raise RuntimeError('chmod for testing_rsa failed')
cmticea6255d02014-01-10 10:27:22 -0800206
asharif96f59692013-02-16 03:13:36 +0000207 def _TestLabels(self, labels):
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800208 experiment_file = 'toolchain_experiment.txt'
209 image_args = ''
asharif58a8c9f2013-02-19 20:42:43 +0000210 if self._force_mismatch:
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800211 image_args = '--force-mismatch'
asharif96f59692013-02-16 03:13:36 +0000212 experiment_header = """
213 board: %s
214 remote: %s
cmticed1f03b82015-06-30 15:19:23 -0700215 retries: 1
asharif96f59692013-02-16 03:13:36 +0000216 """ % (self._board, self._remotes)
217 experiment_tests = """
cmtice0c84ea72015-06-25 14:22:36 -0700218 benchmark: all_toolchain_perf {
cmtice04403882013-11-04 16:38:37 -0500219 suite: telemetry_Crosperf
cmtice6de7f8f2014-03-14 14:08:21 -0700220 iterations: 3
asharif96f59692013-02-16 03:13:36 +0000221 }
222 """
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800223
224 with open(experiment_file, 'w') as f:
Caroline Tice88272d42016-01-13 09:48:29 -0800225 f.write(experiment_header)
226 f.write(experiment_tests)
asharif96f59692013-02-16 03:13:36 +0000227 for label in labels:
228 # TODO(asharif): Fix crosperf so it accepts labels with symbols
229 crosperf_label = label
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800230 crosperf_label = crosperf_label.replace('-', '_')
231 crosperf_label = crosperf_label.replace('+', '_')
232 crosperf_label = crosperf_label.replace('.', '')
cmtice56fb7162014-06-18 11:32:15 -0700233
234 # Use the official build instead of building vanilla ourselves.
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800235 if label == 'vanilla':
cmtice56fb7162014-06-18 11:32:15 -0700236 build_name = '%s-release/%s.0.0' % (self._board, self._build_num)
237
238 # Now add 'official build' to test file.
239 official_image = """
240 official_image {
241 chromeos_root: %s
242 build: %s
243 }
244 """ % (self._chromeos_root, build_name)
Caroline Tice88272d42016-01-13 09:48:29 -0800245 f.write(official_image)
cmtice56fb7162014-06-18 11:32:15 -0700246
cmtice94bc4702014-05-29 16:29:04 -0700247 else:
cmtice56fb7162014-06-18 11:32:15 -0700248 experiment_image = """
249 %s {
250 chromeos_image: %s
251 image_args: %s
252 }
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800253 """ % (crosperf_label, os.path.join(
254 misc.GetImageDir(self._chromeos_root, self._board), label,
255 'chromiumos_test_image.bin'), image_args)
Caroline Tice88272d42016-01-13 09:48:29 -0800256 f.write(experiment_image)
cmtice56fb7162014-06-18 11:32:15 -0700257
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800258 crosperf = os.path.join(os.path.dirname(__file__), 'crosperf', 'crosperf')
Han Shen43494292015-09-14 10:26:40 -0700259 noschedv2_opts = '--noschedv2' if self._noschedv2 else ''
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800260 command = ('{crosperf} --no_email=True --results_dir={r_dir} '
261 '--json_report=True {noschedv2_opts} {exp_file}').format(
262 crosperf=crosperf,
263 r_dir=self._reports_dir,
264 noschedv2_opts=noschedv2_opts,
265 exp_file=experiment_file)
cmticeaa700b02015-06-12 13:26:47 -0700266
asharif96f59692013-02-16 03:13:36 +0000267 ret = self._ce.RunCommand(command)
cmtice7f3190b2015-05-22 14:14:51 -0700268 if ret != 0:
Manoj Guptaaee96b72016-10-24 13:43:28 -0700269 raise RuntimeError('Crosperf execution error!')
Caroline Ticeebbc3da2015-09-03 10:27:20 -0700270 else:
271 # Copy json report to pending archives directory.
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800272 command = 'cp %s/*.json %s/.' % (self._reports_dir, PENDING_ARCHIVES_DIR)
Caroline Ticeebbc3da2015-09-03 10:27:20 -0700273 ret = self._ce.RunCommand(command)
cmtice7f3190b2015-05-22 14:14:51 -0700274 return
cmtice56fb7162014-06-18 11:32:15 -0700275
cmtice56fb7162014-06-18 11:32:15 -0700276 def _CopyWeeklyReportFiles(self, labels):
Caroline Tice88272d42016-01-13 09:48:29 -0800277 """Move files into place for creating 7-day reports.
278
279 Create tar files of the custom and official images and copy them
cmtice56fb7162014-06-18 11:32:15 -0700280 to the weekly reports directory, so they exist when the weekly report
281 gets generated. IMPORTANT NOTE: This function must run *after*
282 crosperf has been run; otherwise the vanilla images will not be there.
283 """
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800284 images_path = os.path.join(
285 os.path.realpath(self._chromeos_root), 'src/build/images', self._board)
286 weekday = time.strftime('%a')
cmtice56fb7162014-06-18 11:32:15 -0700287 data_dir = os.path.join(WEEKLY_REPORTS_ROOT, self._board)
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800288 dest_dir = os.path.join(data_dir, weekday)
cmtice56fb7162014-06-18 11:32:15 -0700289 if not os.path.exists(dest_dir):
290 os.makedirs(dest_dir)
cmtice4536ef62014-07-08 11:17:21 -0700291 # Make sure dest_dir is empty (clean out last week's data).
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800292 cmd = 'cd %s; rm -Rf %s_*_image*' % (dest_dir, weekday)
cmtice4536ef62014-07-08 11:17:21 -0700293 self._ce.RunCommand(cmd)
294 # Now create new tar files and copy them over.
cmtice56fb7162014-06-18 11:32:15 -0700295 for l in labels:
296 test_path = os.path.join(images_path, l)
297 if os.path.exists(test_path):
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800298 if l != 'vanilla':
299 label_name = 'test'
cmtice56fb7162014-06-18 11:32:15 -0700300 else:
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800301 label_name = 'vanilla'
302 tar_file_name = '%s_%s_image.tar' % (weekday, label_name)
303 cmd = ('cd %s; tar -cvf %s %s/chromiumos_test_image.bin; '
304 'cp %s %s/.') % (images_path, tar_file_name, l, tar_file_name,
Han Shenfe054f12015-02-18 15:00:13 -0800305 dest_dir)
cmtice56fb7162014-06-18 11:32:15 -0700306 tar_ret = self._ce.RunCommand(cmd)
cmtice7f3190b2015-05-22 14:14:51 -0700307 if tar_ret != 0:
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800308 self._l.LogOutput('Error while creating/copying test tar file(%s).' %
309 tar_file_name)
cmtice56fb7162014-06-18 11:32:15 -0700310
cmtice7f3190b2015-05-22 14:14:51 -0700311 def _SendEmail(self):
312 """Find email msesage generated by crosperf and send it."""
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800313 filename = os.path.join(self._reports_dir, 'msg_body.html')
cmtice7f3190b2015-05-22 14:14:51 -0700314 if (os.path.exists(filename) and
315 os.path.exists(os.path.expanduser(MAIL_PROGRAM))):
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800316 command = ('cat %s | %s -s "Nightly test results, %s" -team -html' %
317 (filename, MAIL_PROGRAM, self._board))
cmtice7f3190b2015-05-22 14:14:51 -0700318 self._ce.RunCommand(command)
asharif96f59692013-02-16 03:13:36 +0000319
320 def DoAll(self):
321 self._CheckoutChromeOS()
asharif96f59692013-02-16 03:13:36 +0000322 labels = []
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800323 labels.append('vanilla')
asharif96f59692013-02-16 03:13:36 +0000324 for config in self._configs:
Caroline Tice88272d42016-01-13 09:48:29 -0800325 label = self._BuildLabelName(config.gcc_config.githash)
326 if not misc.DoesLabelExist(self._chromeos_root, self._board, label):
asharif96f59692013-02-16 03:13:36 +0000327 self._BuildToolchain(config)
328 label = self._BuildAndImage(label)
329 labels.append(label)
cmticea6255d02014-01-10 10:27:22 -0800330 self._FinishSetup()
cmticeb4588092015-05-27 08:07:50 -0700331 self._TestLabels(labels)
cmtice7f3190b2015-05-22 14:14:51 -0700332 self._SendEmail()
333 # Only try to copy the image files if the test runs ran successfully.
334 self._CopyWeeklyReportFiles(labels)
asharif3e38de02013-02-19 19:34:59 +0000335 if self._clean:
336 ret = self._DeleteChroot()
cmtice7f3190b2015-05-22 14:14:51 -0700337 if ret != 0:
338 return ret
asharif67973582013-02-19 20:19:40 +0000339 ret = self._DeleteCcahe()
cmtice7f3190b2015-05-22 14:14:51 -0700340 if ret != 0:
341 return ret
asharif96f59692013-02-16 03:13:36 +0000342 return 0
343
344
345def Main(argv):
346 """The main function."""
347 # Common initializations
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800348 ### command_executer.InitCommandExecuter(True)
asharif96f59692013-02-16 03:13:36 +0000349 command_executer.InitCommandExecuter()
Caroline Tice88272d42016-01-13 09:48:29 -0800350 parser = argparse.ArgumentParser()
Manoj Guptaaee96b72016-10-24 13:43:28 -0700351 parser.add_argument(
352 '--remote', dest='remote', help='Remote machines to run tests on.')
353 parser.add_argument(
354 '--board', dest='board', default='x86-alex', help='The target board.')
355 parser.add_argument(
356 '--githashes',
357 dest='githashes',
358 default='master',
359 help='The gcc githashes to test.')
360 parser.add_argument(
361 '--clean',
362 dest='clean',
363 default=False,
364 action='store_true',
365 help='Clean the chroot after testing.')
366 parser.add_argument(
367 '--public',
368 dest='public',
369 default=False,
370 action='store_true',
371 help='Use the public checkout/build.')
372 parser.add_argument(
373 '--force-mismatch',
374 dest='force_mismatch',
375 default='',
376 help='Force the image regardless of board mismatch')
377 parser.add_argument(
378 '--noschedv2',
379 dest='noschedv2',
380 action='store_true',
381 default=False,
382 help='Pass --noschedv2 to crosperf.')
Caroline Tice88272d42016-01-13 09:48:29 -0800383 options = parser.parse_args(argv)
asharif96f59692013-02-16 03:13:36 +0000384 if not options.board:
Caroline Tice88272d42016-01-13 09:48:29 -0800385 print('Please give a board.')
asharif96f59692013-02-16 03:13:36 +0000386 return 1
387 if not options.remote:
Caroline Tice88272d42016-01-13 09:48:29 -0800388 print('Please give at least one remote machine.')
asharif96f59692013-02-16 03:13:36 +0000389 return 1
390 toolchain_configs = []
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800391 for githash in options.githashes.split(','):
asharif96f59692013-02-16 03:13:36 +0000392 gcc_config = GCCConfig(githash=githash)
393 toolchain_config = ToolchainConfig(gcc_config=gcc_config)
394 toolchain_configs.append(toolchain_config)
asharif3e38de02013-02-19 19:34:59 +0000395 fc = ToolchainComparator(options.board, options.remote, toolchain_configs,
asharif58a8c9f2013-02-19 20:42:43 +0000396 options.clean, options.public,
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800397 options.force_mismatch, options.noschedv2)
asharif96f59692013-02-16 03:13:36 +0000398 return fc.DoAll()
399
400
Luis Lozanof2a3ef42015-12-15 13:49:30 -0800401if __name__ == '__main__':
Rahul Chaudhry748254e2016-01-25 16:49:21 -0800402 retval = Main(sys.argv[1:])
asharif96f59692013-02-16 03:13:36 +0000403 sys.exit(retval)