1# Copyright (c) 2014 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 5from autotest_lib.client.common_lib import error 6from autotest_lib.server import autotest 7from autotest_lib.server import test 8from autotest_lib.server.cros.faft.rpc_proxy import RPCProxy 9 10class firmware_CompareInstalledToShellBall(test.test): 11 """Compare the installed BIOS and EC versions to those in the shellball.""" 12 version = 1 13 14 def run_once(self, host): 15 # Make sure the client library is on the device so that the proxy 16 # code is there when we try to call it. 17 client_at = autotest.Autotest(host) 18 client_at.install() 19 20 self.faft_client = RPCProxy(host) 21 installed_ec = self.faft_client.ec.get_version() 22 installed_bios = self.faft_client.system.get_crossystem_value('fwid') 23 24 # Chromeboxes do not have an EC 25 if 'mosys' in installed_ec: 26 installed_ec = None 27 28 available_ec = None 29 available_bios = None 30 shellball = host.run('/usr/sbin/chromeos-firmwareupdate -V').stdout 31 for line in shellball.splitlines(): 32 if line.startswith('BIOS version:'): 33 parts = line.split() 34 available_bios = parts[2].strip() 35 if line.startswith('EC version:'): 36 parts = line.split() 37 available_ec = parts[2].strip() 38 39 error_message = None 40 if installed_bios != available_bios: 41 error_message = str('BIOS versions do not match! Installed: %s ' 42 'Available %s' % (installed_bios, 43 available_bios)) 44 if installed_ec != available_ec: 45 ec_message = str('EC versions do not match! Installed: %s ' 46 'Available %s ' % (installed_ec, available_ec)) 47 if error_message: 48 error_message += '\n' + ec_message 49 else: 50 error_message = ec_message 51 52 if error_message: 53 raise error.TestFail(error_message) 54