Home | History | Annotate | Download | only in firmware_CorruptFwSigB
      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             self.restore_firmware()
     26         except ConnectionError:
     27             logging.error("ERROR: DUT did not come up.  Need to cleanup!")
     28         super(firmware_CorruptFwSigB, self).cleanup()
     29 
     30     def run_once(self):
     31         logging.info("Expected firmware A boot and corrupt "
     32                      "firmware signature B.")
     33         self.check_state((self.checkers.fw_tries_checker, 'A'))
     34         self.faft_client.bios.corrupt_sig('b')
     35         self.switcher.mode_aware_reboot()
     36 
     37         logging.info("Expected firmware A boot and set try_fwb flag.")
     38         self.check_state((self.checkers.fw_tries_checker, 'A'))
     39         self.try_fwb()
     40         self.switcher.mode_aware_reboot()
     41 
     42         logging.info("Expected firmware A boot and restore firmware B.")
     43         self.check_state((self.checkers.fw_tries_checker, ('A', False)))
     44         self.faft_client.bios.restore_sig('b')
     45         self.switcher.mode_aware_reboot()
     46 
     47         logging.info("Final check and done.")
     48         self.check_state((self.checkers.fw_tries_checker, 'A'))
     49