Home | History | Annotate | Download | only in firmware_CorruptFwSigA
      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_CorruptFwSigA(FirmwareTest):
     12     """
     13     Servo based firmware signature A corruption test.
     14     """
     15     version = 1
     16 
     17     def initialize(self, host, cmdline_args, dev_mode=False):
     18         super(firmware_CorruptFwSigA, 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_CorruptFwSigA, self).cleanup()
     29 
     30     def run_once(self):
     31         logging.info("Corrupt firmware signature A.")
     32         self.check_state((self.checkers.fw_tries_checker, 'A'))
     33         self.faft_client.bios.corrupt_sig('a')
     34         self.switcher.mode_aware_reboot()
     35 
     36         logging.info("Expected firmware B boot and set fwb_tries flag.")
     37         self.check_state((self.checkers.fw_tries_checker, ('B', False)))
     38 
     39         self.try_fwb()
     40         self.switcher.mode_aware_reboot()
     41 
     42         logging.info("Still expected firmware B boot and restore firmware A.")
     43         self.check_state((self.checkers.fw_tries_checker, 'B'))
     44         self.faft_client.bios.restore_sig('a')
     45         self.switcher.mode_aware_reboot()
     46 
     47         expected_slot = 'B' if self.fw_vboot2 else 'A'
     48         logging.info("Expected firmware " + expected_slot + " boot, done.")
     49         self.check_state((self.checkers.fw_tries_checker, expected_slot))
     50