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
5
6""" The autotest performing FW update, both EC and AP."""
7
8
9import logging
10
11from autotest_lib.client.common_lib import error
12from autotest_lib.server import test
13
14
15class provision_FirmwareUpdate(test.test):
16    """A test that can provision a machine to the correct firmware version."""
17
18    version = 1
19
20
21    def run_once(self, host, value, rw_only=False):
22        """The method called by the control file to start the test.
23
24        @param host:  a CrosHost object of the machine to update.
25        @param value: the provisioning value, which is the build version
26                      to which we want to provision the machine,
27                      e.g. 'link-firmware/R22-2695.1.144'.
28        @param rw_only: True to only update the RW firmware.
29        """
30        try:
31            host.confirm_servo()
32            host.firmware_install(build=value, rw_only=rw_only)
33        except Exception as e:
34            logging.error(e)
35            raise error.TestFail(str(e))
36