• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2012 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 utils
8from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
9
10
11class firmware_ConsecutiveBootPowerButton(FirmwareTest):
12    """
13    Servo based consecutive boot test via power button for both on and off.
14
15    This test is intended to be run with many iterations to ensure that the DUT
16    does boot into Chrome OS and then does power off later.
17
18    The iteration should be specified by the parameter -a "faft_iterations=10".
19    """
20    version = 1
21
22
23    def initialize(self, host, cmdline_args, dev_mode=False):
24        # Parse arguments from command line
25        dict_args = utils.args_to_dict(cmdline_args)
26        self.faft_iterations = int(dict_args.get('faft_iterations', 1))
27        super(firmware_ConsecutiveBootPowerButton,
28              self).initialize(host, cmdline_args)
29        self.switcher.setup_mode('dev' if dev_mode else 'normal')
30        self.setup_usbkey(usbkey=False)
31
32
33    def run_once(self, dev_mode=False):
34        for i in xrange(self.faft_iterations):
35            logging.info('======== Running FAFT ITERATION %d/%s ========',
36                         i+1, self.faft_iterations)
37            logging.info("Expected boot fine, full power off DUT and on.")
38            self.check_state((self.checkers.crossystem_checker, {
39                        'mainfw_type': 'developer' if dev_mode else 'normal',
40                        }))
41            self.full_power_off_and_on()
42            self.switcher.wait_for_client()
43
44            logging.info("Expected boot fine.")
45            self.check_state((self.checkers.crossystem_checker, {
46                        'mainfw_type': 'developer' if dev_mode else 'normal',
47                        }))
48