• 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
9from __future__ import print_function
10
11import logging
12
13# http://docs.python.org/2/library/errno.html
14import errno
15
16from autotest_lib.client.common_lib import error
17from autotest_lib.server import test
18from autotest_lib.server.cros.watchdog_tester import WatchdogTester
19
20
21class platform_HWwatchdog(test.test):
22    """Test to make sure that /dev/watchdog will reboot the system."""
23
24    version = 1
25
26    def _stop_watchdog(self, client, wd_dev):
27        # HW watchdog is open and closed "properly".
28        try:
29            client.run('echo "V" > %s' % wd_dev)
30        except error.AutoservRunError as e:
31            raise error.TestError('write to %s failed (%s)' %
32                                  (wd_dev, errno.errorcode[e.errno]))
33
34    def run_once(self, host=None):
35        tester = WatchdogTester(host)
36        # If watchdog not present, just skip this test
37        if not tester.is_supported():
38            error.TestNAError('%s or %s not present. Skipping test.' %
39                              (tester.WD_DEV, tester.DAISYDOG_PATH))
40            return
41
42        with tester:
43            self._stop_watchdog(host, tester.WD_DEV)
44            tester.trigger_watchdog()
45