Home | History | Annotate | Download | only in platform_TrackpadStressServer
      1 # Copyright (c) 2009 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 from autotest_lib.client.common_lib import error
      7 from autotest_lib.server import test, autotest
      8 
      9 
     10 class platform_TrackpadStressServer(test.test):
     11     """
     12     Make sure the trackpad continues to operate after a kernel panic.
     13     """
     14     version = 1
     15 
     16     def _run_client_test(self, client_at, verify_only=False):
     17         self.job.set_state('client_passed', None)
     18         client_at.run_test(self.client_test)
     19         return self.job.get_state('client_passed')
     20 
     21     def run_once(self, host=None):
     22         self.client = host
     23         self.client_test = 'platform_TrackpadStress'
     24 
     25         logging.info('TrackpadStressServer: start client test')
     26         client_at = autotest.Autotest(self.client)
     27         if not self._run_client_test(client_at):
     28             raise error.TestFail('Client test failed precheck state')
     29 
     30         # Configure the client to reboot on a kernel panic
     31         self.client.run('sysctl kernel.panic|grep "kernel.panic = -1"')
     32         self.client.run('sysctl kernel.panic_on_oops|'
     33                         'grep "kernel.panic_on_oops = 1"')
     34 
     35         boot_id = self.client.get_boot_id()
     36 
     37         # Make it rain
     38         command  = 'echo BUG > /sys/kernel/debug/provoke-crash/DIRECT'
     39         command += '|| echo bug > /proc/breakme'
     40         logging.info('TrackpadStressServer: executing "%s" on %s',
     41                      command, self.client.hostname)
     42         try:
     43             # Simply writing to the crash interface resets the target
     44             # immediately, leaving files unsaved to disk and the master ssh
     45             # connection wedged for a long time. The sequence below borrowed
     46             # from logging_KernelCrashServer.py makes sure that the test
     47             # proceeds smoothly.
     48             self.client.run(
     49                 'sh -c "sync; sleep 1; %s" >/dev/null 2>&1 &' % command)
     50         except error.AutoservRunError, e:
     51             # It is expected that this will cause a non-zero exit status.
     52             pass
     53 
     54         self.client.wait_for_restart(
     55                     down_timeout=60,
     56                     down_warning=60,
     57                     old_boot_id=boot_id,
     58                     # Extend the default reboot timeout as some targets take
     59                     # longer than normal before ssh is available again.
     60                     timeout=self.client.DEFAULT_REBOOT_TIMEOUT * 4)
     61 
     62         # Check that the trackpad is running
     63         # Todo, need an additional client test.
     64         if not self._run_client_test(client_at, verify_only=True):
     65             raise error.TestFail('Client test failed final state verification.'
     66                                  'The trackpad is not running after kernel '
     67                                  'panic.')
     68 
     69 
     70