1# Copyright (c) 2010 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 5AUTHOR = "Chrome OS Team" 6NAME = "platform_InstallFW" 7TIME = "MEDIUM" 8TEST_CATEGORY = "Install" 9TEST_CLASS = "platform" 10TEST_TYPE = "server" 11 12DOC = """ 13This test install the BIOS/EC on a specified device. 14This is useful for testing firmware. 15Here is the command to install a given firmware, which is either a raw binary 16or a shellball: 17 test_that --args='fw_path=<PATH_TO_FW_FILE> 18 fw_name=<NAME_OF_THE_FILE>' 19 fw_type=<TYPE_OF_FW> 20 --board=<board name> 21 <IP addres> 22 platform_InstallFW 23or install the local shellball (/usr/sbin/chromeos-firmwareupdate) in the 24current client image: 25 test_that --args='fw_path=local 26 fw_type=<bios/ec>' 27 --board=<board name> 28 <IP addres> 29 platform_InstallFW 30""" 31 32import os 33from autotest_lib.client.common_lib import error 34 35# Convert autoserv args to something usable. 36opts = dict([[k, v] for (k, _, v) in [x.partition('=') for x in args]]) 37 38def run_installfw(machine): 39 # Verify FW type in arg. 40 if 'fw_type' not in opts: 41 raise error.TestFail('No --fw_type specified') 42 # Verify fw_type value either 'bios' or 'ec'. 43 if not (opts['fw_type'] == 'bios' or opts['fw_type'] == 'ec'): 44 raise error.TestFail('Wrong --fw_type specified. ' 45 'Correct FW Options are bios or ec.') 46 # Verify FW path arg. 47 if 'fw_path' not in opts: 48 raise error.TestFail('No --fw_path specified') 49 # Verify fw_name. 50 if 'fw_name' not in opts: 51 if opts['fw_path'] == 'local': 52 opts['fw_name'] = None 53 elif os.path.isfile(opts['fw_path']): 54 opts['fw_name'] = os.path.basename(opts['fw_path']) 55 opts['fw_path'] = os.path.dirname(opts['fw_path']) 56 else: 57 raise error.TestFail('No --fw_name specified') 58 # Setup the client machine. 59 host = hosts.create_host(machine) 60 job.run_test("platform_InstallFW", host=host, fw_path=opts['fw_path'], 61 fw_type=opts['fw_type'], fw_name=opts['fw_name'], 62 disable_sysinfo=True) 63 64parallel_simple(run_installfw, machines) 65