1# Lint as: python2, python3 2# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6# This test isn't really HW specific. It's testing /dev/watchdog API 7# to make sure it works as expected. The most robust implementations is 8# based on real HW but it doesn't have to be. 9 10from __future__ import print_function 11 12# http://docs.python.org/2/library/errno.html 13import errno 14 15from autotest_lib.client.common_lib import error 16from autotest_lib.server import test 17from autotest_lib.server.cros.watchdog_tester import WatchdogTester 18 19 20class platform_HWwatchdog(test.test): 21 """Test to make sure that /dev/watchdog will reboot the system.""" 22 23 version = 1 24 25 def _stop_watchdog(self, client, wd_dev): 26 # HW watchdog is open and closed "properly". 27 try: 28 client.run('echo "V" > %s' % wd_dev) 29 except error.AutoservRunError as e: 30 raise error.TestError('write to %s failed (%s)' % 31 (wd_dev, errno.errorcode[e.errno])) 32 33 def run_once(self, host=None): 34 tester = WatchdogTester(host) 35 # If watchdog not present, just skip this test 36 if not tester.is_supported(): 37 error.TestNAError('%s or %s not present. Skipping test.' % 38 (tester.WD_DEV, tester.DAISYDOG_PATH)) 39 return 40 41 with tester: 42 self._stop_watchdog(host, tester.WD_DEV) 43 tester.trigger_watchdog() 44