Home | History | Annotate | Download | only in firmware_TryFwB
      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 from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
      7 
      8 
      9 class firmware_TryFwB(FirmwareTest):
     10     """
     11     Servo based RW firmware B boot test.
     12     """
     13     version = 1
     14 
     15     def initialize(self, host, cmdline_args, dev_mode=False, ec_wp=None):
     16         super(firmware_TryFwB, self).initialize(host, cmdline_args, ec_wp=ec_wp)
     17         self.switcher.setup_mode('dev' if dev_mode else 'normal')
     18         self.setup_usbkey(usbkey=False)
     19         if not self.fw_vboot2:
     20             self.setup_tried_fwb(tried_fwb=False)
     21 
     22     def cleanup(self):
     23         try:
     24             self.setup_tried_fwb(tried_fwb=False)
     25         except Exception as e:
     26             logging.error("Caught exception: %s", str(e))
     27         super(firmware_TryFwB, self).cleanup()
     28 
     29     def run_once(self):
     30         logging.info("Set fwb_tries flag")
     31         self.check_state((self.checkers.fw_tries_checker, 'A'))
     32         self.try_fwb()
     33         self.switcher.mode_aware_reboot()
     34 
     35         logging.info("Expected firmware B boot, reboot")
     36         self.check_state((self.checkers.fw_tries_checker, 'B'))
     37         self.switcher.mode_aware_reboot()
     38 
     39         expected_slot = 'B' if self.fw_vboot2 else 'A'
     40         logging.info("Expected firmware " + expected_slot + " boot, done.")
     41         self.check_state((self.checkers.fw_tries_checker, expected_slot))
     42