Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1993)

Side by Side Diff: bin/ctest.py

Issue 6482017: Update test harness to take in optional public and private keys to sign payloads. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Fix asserts after testing Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bin/cros_run_vm_update ('k') | image_to_vm.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Wrapper for tests that are run on builders.""" 7 """Wrapper for tests that are run on builders."""
8 8
9 import fileinput 9 import fileinput
10 import optparse 10 import optparse
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 fh.close() 218 fh.close()
219 219
220 version = zip_url.split('/')[-2] 220 version = zip_url.split('/')[-2]
221 if not _GreaterVersion(version, _NEW_STYLE_VERSION) == version: 221 if not _GreaterVersion(version, _NEW_STYLE_VERSION) == version:
222 # If the version isn't ready for new style, touch file to use old style. 222 # If the version isn't ready for new style, touch file to use old style.
223 old_style_touch_path = os.path.join(download_folder, '.use_e1000') 223 old_style_touch_path = os.path.join(download_folder, '.use_e1000')
224 fh = open(old_style_touch_path, 'w+') 224 fh = open(old_style_touch_path, 'w+')
225 fh.close() 225 fh.close()
226 226
227 227
228 def WipeDevServerCache():
229 """Wipes the cache of the dev server."""
230 RunCommand(['sudo',
231 './start_devserver',
232 '--clear_cache',
233 '--exit',
234 ], enter_chroot=True)
235
236
237 def RunAUTestHarness(board, channel, latest_url_base, zip_server_base, 228 def RunAUTestHarness(board, channel, latest_url_base, zip_server_base,
238 no_graphics, type, remote): 229 no_graphics, type, remote, clean):
239 """Runs the auto update test harness. 230 """Runs the auto update test harness.
240 231
241 The auto update test harness encapsulates testing the auto-update mechanism 232 The auto update test harness encapsulates testing the auto-update mechanism
242 for the latest image against the latest official image from the channel. This 233 for the latest image against the latest official image from the channel. This
243 also tests images with suite_Smoke (built-in as part of its verification 234 also tests images with suite_Smoke (built-in as part of its verification
244 process). 235 process).
245 236
246 Args: 237 Args:
247 board: the board for the latest image. 238 board: the board for the latest image.
248 channel: the channel to run the au test harness against. 239 channel: the channel to run the au test harness against.
249 latest_url_base: base url for getting latest links. 240 latest_url_base: base url for getting latest links.
250 zip_server_base: base url for zipped images. 241 zip_server_base: base url for zipped images.
251 no_graphics: boolean - If True, disable graphics during vm test. 242 no_graphics: boolean - If True, disable graphics during vm test.
252 type: which test harness to run. Possible values: real, vm. 243 type: which test harness to run. Possible values: real, vm.
253 remote: ip address for real test harness run. 244 remote: ip address for real test harness run.
245 clean: Clean the state of test harness before running.
254 """ 246 """
255 crosutils_root = os.path.join(os.path.dirname(__file__), '..') 247 crosutils_root = os.path.join(os.path.dirname(__file__), '..')
256 download_folder = os.path.abspath('latest_download') 248 download_folder = os.path.abspath('latest_download')
257 zip_url = GetLatestZipUrl(board, channel, latest_url_base, zip_server_base) 249 zip_url = GetLatestZipUrl(board, channel, latest_url_base, zip_server_base)
258 GrabZipAndExtractImage(zip_url, download_folder, _IMAGE_TO_EXTRACT) 250 GrabZipAndExtractImage(zip_url, download_folder, _IMAGE_TO_EXTRACT)
259 251
260 # Tests go here. 252 # Tests go here.
261 latest_image = RunCommand(['./get_latest_image.sh', '--board=%s' % board], 253 latest_image = RunCommand(['./get_latest_image.sh', '--board=%s' % board],
262 cwd=crosutils_root, redirect_stdout=True, 254 cwd=crosutils_root, redirect_stdout=True,
263 print_cmd=True).strip() 255 print_cmd=True).strip()
264 256
257 update_engine_path = os.path.join(crosutils_root, '..', 'platform',
258 'update_engine')
259
265 cmd = ['bin/cros_au_test_harness', 260 cmd = ['bin/cros_au_test_harness',
266 '--base_image=%s' % os.path.join(download_folder, 261 '--base_image=%s' % os.path.join(download_folder,
267 _IMAGE_TO_EXTRACT), 262 _IMAGE_TO_EXTRACT),
268 '--target_image=%s' % os.path.join(latest_image, 263 '--target_image=%s' % os.path.join(latest_image,
269 _IMAGE_TO_EXTRACT), 264 _IMAGE_TO_EXTRACT),
270 '--board=%s' % board, 265 '--board=%s' % board,
271 '--type=%s' % type, 266 '--type=%s' % type,
272 '--remote=%s' % remote, 267 '--remote=%s' % remote,
268 '--private_key=%s' % os.path.join(update_engine_path,
269 'unittest_key.pem'),
270 '--public_key=%s' % os.path.join(update_engine_path,
271 'unittest_key.pub.pem'),
273 ] 272 ]
274 if no_graphics: cmd.append('--no_graphics') 273 if no_graphics: cmd.append('--no_graphics')
274 if clean: cmd.append('--clean')
275 275
276 RunCommand(cmd, cwd=crosutils_root) 276 RunCommand(cmd, cwd=crosutils_root)
277 277
278 278
279 def main(): 279 def main():
280 parser = optparse.OptionParser() 280 parser = optparse.OptionParser()
281 parser.add_option('-b', '--board', 281 parser.add_option('-b', '--board',
282 help='board for the image to compare against.') 282 help='board for the image to compare against.')
283 parser.add_option('-c', '--channel', 283 parser.add_option('-c', '--channel',
284 help='channel for the image to compare against.') 284 help='channel for the image to compare against.')
285 parser.add_option('--cache', default=False, action='store_true', 285 parser.add_option('--cache', default=False, action='store_true',
286 help='Cache payloads') 286 help='Cache payloads')
287 parser.add_option('-l', '--latestbase', 287 parser.add_option('-l', '--latestbase',
288 help='Base url for latest links.') 288 help='Base url for latest links.')
289 parser.add_option('-z', '--zipbase', 289 parser.add_option('-z', '--zipbase',
290 help='Base url for hosted images.') 290 help='Base url for hosted images.')
291 parser.add_option('--no_graphics', action='store_true', default=False, 291 parser.add_option('--no_graphics', action='store_true', default=False,
292 help='Disable graphics for the vm test.') 292 help='Disable graphics for the vm test.')
293 parser.add_option('--type', default='vm', 293 parser.add_option('--type', default='vm',
294 help='type of test to run: [vm, real]. Default: vm.') 294 help='type of test to run: [vm, real]. Default: vm.')
295 parser.add_option('--remote', default='0.0.0.0', 295 parser.add_option('--remote', default='0.0.0.0',
296 help='For real tests, ip address of the target machine.') 296 help='For real tests, ip address of the target machine.')
297 297
298 # Set the usage to include flags. 298 # Set the usage to include flags.
299 parser.set_usage(parser.format_help()) 299 parser.set_usage(parser.format_help())
300 (options, args) = parser.parse_args() 300 (options, args) = parser.parse_args()
301 301
302 if args: 302 if args: parser.error('Extra args found %s.' % args)
303 parser.error('Extra args found %s.' % args) 303 if not options.board: parser.error('Need board for image to compare against.')
304 304 if not options.channel: parser.error('Need channel e.g. dev-channel.')
305 if not options.board: 305 if not options.zipbase: parser.error('Need zip url base to get images.')
306 parser.error('Need board for image to compare against.')
307
308 if not options.channel:
309 parser.error('Need channel for image to compare against.')
310
311 if not options.zipbase:
312 parser.error('Need zip url base to get images.')
313
314 if not options.cache:
315 Info('Wiping dev server cache.')
316 WipeDevServerCache()
317 306
318 RunAUTestHarness(options.board, options.channel, options.latestbase, 307 RunAUTestHarness(options.board, options.channel, options.latestbase,
319 options.zipbase, options.no_graphics, options.type, 308 options.zipbase, options.no_graphics, options.type,
320 options.remote) 309 options.remote, not options.cache)
321 310
322 311
323 if __name__ == '__main__': 312 if __name__ == '__main__':
324 main() 313 main()
325 314
OLDNEW
« no previous file with comments | « bin/cros_run_vm_update ('k') | image_to_vm.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698