• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 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
6
7from autotest_lib.client.common_lib import error
8from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
9
10
11class firmware_MiniosPriority(FirmwareTest):
12    """
13    Servo based MiniOS boot priority test.
14
15    This test requires the device support MiniOS. At runtime, this test uses the
16    crossystem tool to modify the MiniOS priority and try to boot MiniOS from
17    firmware manual recovery screen. After booting, this test will verify if the
18    device successfully boot to the MiniOS. This test does not cover verifying
19    if the device successfully boots to the specified partition.
20    """
21    version = 1
22
23    def initialize(self, host, cmdline_args, minios_priority):
24        super(firmware_MiniosPriority, self).initialize(host, cmdline_args)
25
26        self.test_skipped = True
27        if not self.menu_switcher:
28            raise error.TestNAError('Test skipped for menuless UI')
29        if not self.faft_config.chrome_ec:
30            raise error.TestNAError('Cannot check power state without EC')
31        if not self.faft_config.minios_enabled:
32            raise error.TestNAError('MiniOS is not enabled for this board')
33        self.test_skipped = False
34
35        self.host = host
36        self.switcher.setup_mode('normal')
37        self.setup_usbkey(usbkey=False)
38        self.minios_priority = minios_priority
39        self.restored_priority = self.faft_client.system.get_minios_priority()
40
41    def cleanup(self):
42        if not self.test_skipped:
43            try:
44                self.switcher.leave_minios()
45                self.faft_client.system.set_minios_priority(
46                        self.restored_priority)
47            except Exception as e:
48                logging.error('Caught exception: %s', str(e))
49        super(firmware_MiniosPriority, self).cleanup()
50
51    def run_once(self):
52        """Run a single iteration of the test."""
53        self.switcher.launch_minios(self.minios_priority)
54        self.check_state(self.checkers.minios_checker)
55