| # 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 os |
| |
| from autotest_lib.server import utils |
| from autotest_lib.server.cros.servo import servo |
| |
| AUTHOR = 'Chrome OS Team' |
| NAME = 'fwupdate' |
| PURPOSE = 'Servo based firmware updater' |
| TIME = 'MEDIUM' |
| TEST_TYPE = 'server' |
| |
| DOC = """ |
| This test attempts to reprogram both EC and AP firmware. |
| |
| Requires one parameter passed through args: 'fwurl', a string representing the |
| firmware tarball URL on Google storage. |
| """ |
| |
| args_dict = utils.args_to_dict(args) |
| servo_args = hosts.CrosHost.get_servo_arguments(args_dict) |
| |
| # In case this is run by dynamic suite, board and url come from local |
| # variables |
| |
| dut_board = locals().get('board') |
| if dut_board is None: |
| dut_board = args_dict['board'] |
| fwurl = args_dict['fwurl'] |
| AFE = None |
| else: |
| from autotest_lib.server.cros.dynamic_suite import frontend_wrappers |
| from autotest_lib.server.cros.dynamic_suite import constants |
| AFE = frontend_wrappers.RetryingAFE( |
| timeout_min=1, delay_sec=10, debug=False) |
| fwurl = locals().get('image_url') |
| |
| def clear_version_labels(machine): |
| """Clear all build-specific labels, attributes from the target. |
| |
| Following suite after server/site_tests/autoupdate/control |
| |
| @param machine: the host to clear labels, attributes from. |
| """ |
| labels = AFE.get_labels(name__startswith=constants.FW_VERSION_PREFIX, |
| host__hostname__in=[machine]) |
| for label in labels: label.remove_hosts(hosts=[machine]) |
| AFE.set_host_attribute('job_repo_url', None, hostname=machine) |
| |
| def run_fwupdate(machine): |
| if AFE: |
| clear_version_labels(machine) |
| if job.run_test('fwupdate', servo=servo.Servo(**servo_args), |
| board=dut_board, fwurl=fwurl, disable_sysinfo=True) and AFE: |
| label = AFE.get_labels( |
| name__startswith=constants.FW_VERSION_PREFIX + image_name)[0] |
| label.add_hosts([machine]) |
| AFE.set_host_attribute('job_repo_url', fwurl, hostname=machine) |
| |
| parallel_simple(run_fwupdate, machines) |