• 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 error
8from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
9
10
11class firmware_ECPowerG3(FirmwareTest):
12    """
13    Servo based EC X86 power G3 drop test.
14    """
15    version = 1
16
17    # Time out range for waiting system drop into G3.
18    G3_RETRIES = 13
19
20    # Record failure event
21    _failed = False
22
23    def initialize(self, host, cmdline_args):
24        super(firmware_ECPowerG3, self).initialize(host, cmdline_args)
25        # Only run in normal mode
26        self.switcher.setup_mode('normal')
27        self.ec.send_command("chan 0")
28
29    def cleanup(self):
30        try:
31            self.ec.send_command("chan 0xffffffff")
32        except Exception as e:
33            logging.error("Caught exception: %s", str(e))
34        super(firmware_ECPowerG3, self).cleanup()
35
36    def check_G3(self):
37        """Shutdown the system and check if X86 drop into G3 correctly."""
38        self.faft_client.system.run_shell_command("shutdown -P now")
39        if not self.wait_power_state("G3", self.G3_RETRIES):
40            logging.error("EC fails to drop into G3")
41            self._failed = True
42        self.servo.power_short_press()
43
44    def check_failure(self):
45        """Check whether any failure has occurred."""
46        return not self._failed
47
48    def run_once(self):
49        if not self.check_ec_capability(['x86']):
50            raise error.TestNAError("Nothing needs to be tested on this device")
51
52        logging.info("Power off and check if system drop into G3 correctly.")
53        self.switcher.mode_aware_reboot('custom', self.check_G3)
54
55        logging.info("Check if failure occurred.")
56        self.check_state(self.check_failure)
57