firmware_ECWatchdog.py revision a051510c53dbbd01f768a2546098ec73ba325221
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.faftsequence import FAFTSequence 10 11class firmware_ECWatchdog(FAFTSequence): 12 """ 13 Servo based EC watchdog test. 14 """ 15 version = 1 16 17 18 # Delay of spin-wait in ms. Should be long enough to trigger watchdog reset. 19 WATCHDOG_DELAY = 3000 20 21 # Delay of EC power on. 22 EC_BOOT_DELAY = 1000 23 24 25 def setup(self): 26 super(firmware_ECWatchdog, self).setup() 27 # Only run in normal mode 28 self.setup_dev_mode(False) 29 30 31 def reboot_by_watchdog(self): 32 """ 33 Trigger a watchdog reset. 34 """ 35 self.faft_client.system.run_shell_command("sync") 36 self.ec.send_command("waitms %d" % self.WATCHDOG_DELAY) 37 time.sleep((self.WATCHDOG_DELAY + self.EC_BOOT_DELAY) / 1000.0) 38 self.check_lid_and_power_on() 39 40 41 def run_once(self): 42 if not self.check_ec_capability(): 43 raise error.TestNAError("Nothing needs to be tested on this device") 44 self.register_faft_sequence(( 45 { # Step 1, trigger a watchdog reset and power on system again. 46 'reboot_action': self.reboot_by_watchdog, 47 }, 48 { # Step 2, dummy step to make sure step 1 reboots 49 } 50 )) 51 self.run_faft_sequence() 52