• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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        self.check_state((self.checkers.fw_tries_checker, ('A', True, 0)))
52
53        self.try_fwb(2);
54
55        self.check_state((self.checkers.fw_tries_checker, ('A', True, 2)))
56        self.switcher.mode_aware_reboot()
57        if self.faft_client.system.has_host():
58            # Android: Does not have chromeos mechanism to block init file from
59            # resetting try_count to 0 if in testing mode, so we just need to
60            # check if we successfully booted into B
61            self.check_state((self.checkers.fw_tries_checker, ('B', True, 0)))
62            self.switcher.mode_aware_reboot()
63            self.check_state((self.checkers.fw_tries_checker, ('B', True, 0)))
64        else:
65            # ChromeOS: Blocks init file on bootup from setting try_count to 0
66            # Thus, each reboot is never successful, thus when try_count
67            # decrements to 0, will reboot into FW A due to failure
68            self.check_state((self.checkers.fw_tries_checker, ('B', True, 1)))
69            self.switcher.mode_aware_reboot()
70            self.check_state((self.checkers.fw_tries_checker, ('B', True, 0)))
71            self.switcher.mode_aware_reboot()
72            self.check_state((self.checkers.fw_tries_checker, ('A', True, 0)))
73