• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2011 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# This test isn't really HW specific. It's testing /dev/watchdog API
6# to make sure it works as expected. The most robust implementations is
7# based on real HW but it doesn't have to be.
8
9import logging
10
11# http://docs.python.org/2/library/errno.html
12import errno
13
14from autotest_lib.client.common_lib import error
15from autotest_lib.server import test
16from autotest_lib.server.cros.watchdog_tester import WatchdogTester
17
18
19class platform_HWwatchdog(test.test):
20    """Test to make sure that /dev/watchdog will reboot the system."""
21
22    version = 1
23
24    def _stop_watchdog(self, client, wd_dev):
25        # HW watchdog is open and closed "properly".
26        try:
27            client.run('echo "V" > %s' % wd_dev)
28        except error.AutoservRunError, e:
29            raise error.TestError('write to %s failed (%s)' %
30                                  (wd_dev, errno.errorcode[e.errno]))
31
32    def run_once(self, host=None):
33        tester = WatchdogTester(host)
34        # If watchdog not present, just skip this test
35        if not tester.is_supported():
36            logging.info("INFO: %s not present. Skipping test." % tester.WD_DEV)
37            return
38
39        with tester:
40            self._stop_watchdog(host, tester.WD_DEV)
41            tester.trigger_watchdog()
42