Home | History | Annotate | Download | only in firmware_ECWatchdog
      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 
      5 import logging
      6 import time
      7 
      8 from autotest_lib.client.common_lib import error
      9 from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
     10 
     11 class firmware_ECWatchdog(FirmwareTest):
     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 initialize(self, host, cmdline_args):
     26         super(firmware_ECWatchdog, self).initialize(host, cmdline_args)
     27         # Only run in normal mode
     28         self.switcher.setup_mode('normal')
     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 
     45         logging.info("Trigger a watchdog reset and power on system again.")
     46         self.switcher.mode_aware_reboot('custom', self.reboot_by_watchdog)
     47