Home | History | Annotate | Download | only in kernel_EmptyLines
      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, re
      6 
      7 from autotest_lib.client.common_lib import error
      8 from autotest_lib.server import test
      9 
     10 class kernel_EmptyLines(test.test):
     11     version = 1
     12 
     13     def run_once(self, host=None):
     14         self.client = host
     15 
     16         # Reboot the client
     17         logging.info('kernel_EmptyLines: reboot %s' % self.client.hostname)
     18         self.client.reboot()
     19 
     20         # Get dmesg since boot and check for empty printk lines.
     21         # Format is from start of line: '[   x.yyyyyy] ' where x.y is
     22         # the timestamp.
     23         #
     24         # A typical example for an error:
     25         # [ 3.799802] device-mapper: init: foo bar
     26         # [ 3.799807]
     27         # [ 3.799921] device-mapper: done
     28 
     29         result = self.client.run('dmesg')
     30         match = re.search('^\[[\s0-9\.]+\]\s*$', result.stdout, re.M)
     31 
     32         lines = result.stdout.count('\n')
     33 
     34         if match:
     35             raise error.TestFail("Found an empty line in dmesg: '%s'" %
     36                                  match.group(0))
     37         elif lines < 5:
     38             raise error.TestFail("Only got %d lines of dmesg" % lines)
     39         else:
     40             logging.info('kernel_EmptyLines: checked %d lines' % lines)
     41