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 5import logging 6from autotest_lib.server.cros.faft.firmware_test import FirmwareTest 7 8 9class 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 self.setup_tried_fwb(tried_fwb=False) 24 super(firmware_TryFwB, self).cleanup() 25 26 def run_once(self): 27 logging.info("Set fwb_tries flag") 28 self.check_state((self.checkers.fw_tries_checker, 'A')) 29 self.try_fwb() 30 self.switcher.mode_aware_reboot() 31 32 logging.info("Expected firmware B boot, reboot") 33 self.check_state((self.checkers.fw_tries_checker, 'B')) 34 self.switcher.mode_aware_reboot() 35 36 expected_slot = 'B' if self.fw_vboot2 else 'A' 37 logging.info("Expected firmware " + expected_slot + " boot, done.") 38 self.check_state((self.checkers.fw_tries_checker, expected_slot)) 39