1# Copyright 2014 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 5from autotest_lib.server.cros.faft.firmware_test import FirmwareTest 6 7 8class firmware_FWtries(FirmwareTest): 9 """ 10 Boot with firmware B until fwb_tries/fw_try_count counts down to 11 0. vboot1 only needs to set fwb_tries in order to boot into FWB, 12 but vboot2 needs to set two fields: fw_try_next and fw_try_count 13 in order to do so. 14 15 Setup Steps: 16 1. Make the device in normal/dev mode. 17 18 Test Steps: 19 2. Set # of tries to 2 (through try_fwb) 20 a. For vboot1: 21 set fwb_tries=2 22 [fwb_tries can be > 0 and <= 15. Value will be auto reset to 15 If 23 the value is < 0 or > 15 24 b. For vboot2: 25 set fw_try_next=B fw_try_count=2 26 3. Reboot 1 27 4. Reboot 2 28 5. Reboot 3 29 30 Verification Steps: 31 1. After reboot 1, fw_tries_checker checks that 32 mainfw_act = B 33 fwb_tries/fw_try_count = 1 34 35 2. After reboot 2, fw_tries_checker checks that 36 mainfw_act = B 37 fwb_tries/fw_try_count = 0 38 39 3. After reboot 3, fw_tries_checker 40 mainfw_act = A 41 fwb_tries/fw_try_count = 0 42 """ 43 44 version = 1 45 46 def initialize(self, host, cmdline_args, dev_mode=False): 47 super(firmware_FWtries, self).initialize(host, cmdline_args) 48 self.switcher.setup_mode('dev' if dev_mode else 'normal') 49 50 def run_once(self, host): 51 """Runs a single iteration of the test.""" 52 self.check_state((self.checkers.fw_tries_checker, ('A', True, 0))) 53 54 self.try_fwb(2); 55 56 self.check_state((self.checkers.fw_tries_checker, ('A', True, 2))) 57 self.switcher.mode_aware_reboot() 58 59 # ChromeOS: Blocks init file on bootup from setting try_count to 0 60 # Thus, each reboot is never successful, thus when try_count 61 # decrements to 0, will reboot into FW A due to failure 62 self.check_state((self.checkers.fw_tries_checker, ('B', True, 1))) 63 self.switcher.mode_aware_reboot() 64 self.check_state((self.checkers.fw_tries_checker, ('B', True, 0))) 65 self.switcher.mode_aware_reboot() 66 self.check_state((self.checkers.fw_tries_checker, ('A', True, 0))) 67