• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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
6import time
7
8from autotest_lib.server import autotest
9from autotest_lib.server import test
10from autotest_lib.client.common_lib import error
11from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
12
13
14class power_BootUpTime(FirmwareTest):
15    """Checks the device boot up time"""
16    version = 1
17    _WAIT_TIME_OPEN_LID = _WAIT_TIME_CLOSE_LID = 10
18
19    def initialize(self, host, cmdline_args, ec_wp=None):
20        """Autotest initialize method"""
21        self.host = host
22        super(power_BootUpTime, self).initialize(self.host, cmdline_args,
23                                                 ec_wp=ec_wp)
24        self.switcher.setup_mode('normal')
25
26    def run_once(self, bootup_time=8, boot_type='reboot'):
27        """Checks the boot up time
28
29        @param bootup_time: Expected boot up time
30        @param boot_type: Reboot type, Ex: Reboot, lid_close_open etc
31        """
32        autotest_client = autotest.Autotest(self.host)
33
34        # Assume that running the test case after immediate flash and
35        # keeping the DUT at logout screen.
36        autotest_client.run_test('login_LoginSuccess', disable_sysinfo=True)
37        if boot_type == 'reboot':
38            self.host.reboot()
39        elif boot_type == 'lid_close_open':
40            logging.info("Closing lid")
41            self.host.servo.lid_close()
42            self.switcher.wait_for_client_offline(
43                    timeout=self._WAIT_TIME_CLOSE_LID)
44            logging.info('Opening lid')
45            self.host.servo.lid_open()
46            if not self.faft_config.lid_wake_from_power_off:
47                logging.info('Pressing power button')
48                self.host.servo.power_normal_press()
49            self.switcher.wait_for_client(timeout=self._WAIT_TIME_OPEN_LID)
50        else:
51            raise error.TestError("Invalid boot_type, check the boot_type"
52                                  " in control file")
53
54        autotest_client.run_test('platform_BootPerf', constraints=[
55                'seconds_power_on_to_login <= %d' % bootup_time])
56