Home | History | Annotate | Download | only in firmware_CorruptBothFwSigAB
      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 import vboot_constants as vboot
      8 from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
      9 
     10 
     11 class firmware_CorruptBothFwSigAB(FirmwareTest):
     12     """
     13     Servo based both firmware signature A and B corruption test.
     14 
     15     This test requires a USB disk plugged-in, which contains a Chrome OS test
     16     image (built by "build_image --test"). On runtime, this test corrupts
     17     both firmware signature A and B. On next reboot, the firmware verification
     18     fails and enters recovery mode. This test then checks the success of the
     19     recovery boot.
     20     """
     21     version = 1
     22 
     23     def initialize(self, host, cmdline_args, dev_mode=False):
     24         super(firmware_CorruptBothFwSigAB, self).initialize(host, cmdline_args)
     25         self.backup_firmware()
     26         self.switcher.setup_mode('dev' if dev_mode else 'normal')
     27         self.setup_usbkey(usbkey=True, host=False)
     28 
     29     def cleanup(self):
     30         self.restore_firmware()
     31         super(firmware_CorruptBothFwSigAB, self).cleanup()
     32 
     33     def run_once(self, dev_mode=False):
     34         logging.info("Corrupt both firmware signature A and B.")
     35         self.check_state((self.checkers.crossystem_checker, {
     36                           'mainfw_type': 'developer' if dev_mode else 'normal',
     37                           }))
     38         self.faft_client.bios.corrupt_sig(('a', 'b'),)
     39         self.switcher.mode_aware_reboot()
     40 
     41         logging.info("Expected recovery boot and set fwb_tries flag.")
     42         self.check_state((self.checkers.crossystem_checker, {
     43                           'mainfw_type': 'recovery',
     44                           'recovery_reason': (
     45                               vboot.RECOVERY_REASON['RO_INVALID_RW'],
     46                               vboot.RECOVERY_REASON['RW_VERIFY_KEYBLOCK']),
     47                           }))
     48         self.faft_client.system.set_try_fw_b()
     49         self.switcher.mode_aware_reboot()
     50 
     51         logging.info("Still expected recovery boot and restore firmware.")
     52         self.check_state((self.checkers.crossystem_checker, {
     53                           'mainfw_type': 'recovery',
     54                           'recovery_reason': (
     55                               vboot.RECOVERY_REASON['RO_INVALID_RW'],
     56                               vboot.RECOVERY_REASON['RW_VERIFY_KEYBLOCK']),
     57                           }))
     58         self.faft_client.bios.restore_sig(('a', 'b'),)
     59         self.switcher.mode_aware_reboot()
     60 
     61         logging.info("Expected normal boot, done.")
     62         self.check_state((self.checkers.crossystem_checker, {
     63                           'mainfw_type': 'developer' if dev_mode else 'normal',
     64                           }))
     65