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 6import time 7 8from autotest_lib.client.common_lib import error 9from autotest_lib.server.cros.faft.firmware_test import FirmwareTest 10 11 12class firmware_ECWakeSource(FirmwareTest): 13 """ 14 Servo based EC wake source test. 15 """ 16 version = 1 17 18 # Delay for waiting client to shut down 19 SHUTDOWN_DELAY = 10 20 21 def initialize(self, host, cmdline_args): 22 super(firmware_ECWakeSource, self).initialize(host, cmdline_args) 23 # Only run in normal mode 24 self.switcher.setup_mode('normal') 25 26 def hibernate_and_wake_by_power_button(self): 27 """Shutdown and hibernate EC. Then wake by power button.""" 28 self.faft_client.system.run_shell_command("shutdown -P now") 29 time.sleep(self.SHUTDOWN_DELAY) 30 self.ec.send_command("hibernate 1000") 31 time.sleep(self.WAKE_DELAY) 32 self.servo.power_short_press() 33 34 def run_once(self): 35 # TODO(victoryang): make this test run on both x86 and arm 36 if not self.check_ec_capability(['x86', 'lid']): 37 raise error.TestNAError("Nothing needs to be tested on this device") 38 39 logging.info("Suspend and wake by power button.") 40 self.switcher.mode_aware_reboot( 41 'custom', 42 lambda:self.suspend_as_reboot(self.wake_by_power_button)) 43 44 logging.info("Suspend and wake by lid switch.") 45 self.switcher.mode_aware_reboot( 46 'custom', 47 lambda:self.suspend_as_reboot(self.wake_by_lid_switch)) 48 49 logging.info("EC hibernate and wake by power button.") 50 self.switcher.mode_aware_reboot( 51 'custom', 52 lambda:self.hibernate_and_wake_by_power_button()) 53