1 # Copyright (c) 2011 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 import logging 6 7 from autotest_lib.server.cros.faft.firmware_test import FirmwareTest 8 from autotest_lib.server.cros.faft.firmware_test import ConnectionError 9 10 11 class firmware_CorruptFwSigB(FirmwareTest): 12 """ 13 Servo based firmware signature B corruption test. 14 """ 15 version = 1 16 17 def initialize(self, host, cmdline_args, dev_mode=False): 18 super(firmware_CorruptFwSigB, self).initialize(host, cmdline_args) 19 self.backup_firmware() 20 self.switcher.setup_mode('dev' if dev_mode else 'normal') 21 self.setup_usbkey(usbkey=False) 22 23 def cleanup(self): 24 try: 25 if self.is_firmware_saved(): 26 self.restore_firmware() 27 except ConnectionError: 28 logging.error("ERROR: DUT did not come up. Need to cleanup!") 29 super(firmware_CorruptFwSigB, self).cleanup() 30 31 def run_once(self): 32 logging.info("Expected firmware A boot and corrupt " 33 "firmware signature B.") 34 self.check_state((self.checkers.fw_tries_checker, 'A')) 35 self.faft_client.bios.corrupt_sig('b') 36 self.switcher.mode_aware_reboot() 37 38 logging.info("Expected firmware A boot and set try_fwb flag.") 39 self.check_state((self.checkers.fw_tries_checker, 'A')) 40 self.try_fwb() 41 self.switcher.mode_aware_reboot() 42 43 logging.info("Expected firmware A boot and restore firmware B.") 44 self.check_state((self.checkers.fw_tries_checker, ('A', False))) 45 self.faft_client.bios.restore_sig('b') 46 self.switcher.mode_aware_reboot() 47 48 logging.info("Final check and done.") 49 self.check_state((self.checkers.fw_tries_checker, 'A')) 50