blob: e7e688b9e4108eff203f96f5bdd4a931108e60c5 [file] [log] [blame]
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
import time
from autotest_lib.server import test
from autotest_lib.client.common_lib import error
class platform_InstallRecoveryImage(test.test):
"""Installs a specified recovery image onto a servo-connected DUT."""
version = 1
def initialize(self, host, image=None, local=False):
"""Setup image path.
@param host: Host object representing DUT to be re-imaged.
@param image_url: URL of a test image to be installed.
@param local: bool indicating it's a local run with an image already
on the usb stick of the servo
self.local = local
if not self.local:
self.image = image
if not self.image:
raise error.TestFail('No image path provided, and not run '
'with .local flag to indicate image '
'already on the stick.')
def run_once(self, host):
"""Install recovery image on |host|.
@param host: Host object representing DUT to be re-imaged.
if self.local:
# This indicates the image is already on the stick before
# the test starts, so the only thing required is to boot
# in recovery.
# In this phase, the image is a provided path.
make_image_noninteractive=True)'Running the recovery process on the DUT. '
'Will wait up to %d seconds for recovery to '
'complete.', self._RECOVERY_INSTALL_DELAY)
start_time = time.time()
# Wait for the host to come up.
if host.ping_wait_up(timeout=self._RECOVERY_INSTALL_DELAY):'Recovery process completed successfully in '
'%d seconds.', time.time() - start_time)
raise error.TestFail('Host failed to come back up after '
'%d seconds.' % self._RECOVERY_INSTALL_DELAY)'Removing the usb key from the DUT.')