1# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import logging 6 7from autotest_lib.client.common_lib import error 8from autotest_lib.client.common_lib import utils 9 10NAME = "provision_FactoryImage" 11AUTHOR = "beeps@google.com, chromeos-lab-infrastructure@google.com" 12TIME = "MEDIUM" 13TEST_CATEGORY = "Install" 14TEST_CLASS = "provision" 15TEST_TYPE = "server" 16 17DOC = """ 18This test installs a specified factory image onto a servo-connected DUT. 19It will attempt to retrieve the factory image from the canary branch, and 20as such, the image_name must correspond to the name on that branch. For 21example, to install the daisy_spring image from the canary-channel, one 22would specify an image_name like: "daisy-spring/4262.320.0". 23 24Here is the command to install a recovery image with a locally attached 25servo: 26 test_that <remote_ip> provision_FactoryImage --board=<board> \ 27 --args="image_name=<board>/<build> servo_host=<ip of servo_host>" 28 29where servo_host is the ip of beagle board running servod. If a servo_host 30is not specified and the DUT is in .cros, we will construct the right name 31for its servo, and if the DUT isn't in .cros we will attempt to use localhost 32as the servohost. 33""" 34 35args_dict = utils.args_to_dict(args) 36 37image_name = args_dict.get('image_name') 38servo_host = args_dict.get('servo_host') 39if not image_name: 40 raise error.AutoservError('Please specify --args="image_name=<board>/' 41 '<build> servo_host=<ip of servo_host>" when ' 42 'invoking test_that. Make sure the DUT you are ' 43 'trying to reimage has a beagle-board/servo ' 44 'attached.') 45 46servo_args = hosts.CrosHost.get_servo_arguments(args_dict) 47 48def run(machine): 49 """Create a host stage a factory image and reimage through servo.""" 50 host = hosts.create_host(machine, servo_args=servo_args) 51 image_url = host.stage_factory_image_for_servo(image_name=image_name) 52 job.run_test('provision_FactoryImage', host=host, 53 disable_sysinfo=True, image_url=image_url) 54 55parallel_simple(run, machines) 56