Home | History | Annotate | Download | only in platform_LogNonKernelKmsg
      1 # Copyright 2014 The Chromium OS Authors. All rights reserved.  Use of
      2 # this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import time
      6 
      7 from autotest_lib.client.bin import test
      8 from autotest_lib.client.common_lib import error
      9 from autotest_lib.client.common_lib import utils
     10 
     11 class platform_LogNonKernelKmsg(test.test):
     12     """Test that we log non-kernel messages via /dev/kmsg"""
     13     KLOG_PATH = '/dev/kmsg'
     14     SYSLOG_BIN = 'rsyslogd'
     15     SYSLOG_JOB = 'syslog'
     16     SYSTEM_LOG_PATH = '/var/log/messages'
     17     version = 1
     18 
     19 
     20     def run_once(self):
     21         utils.run('truncate -s 0 %s' % self.SYSTEM_LOG_PATH)
     22         our_message = 'non-kernel message generated at %d\n' % time.time()
     23         with open(self.KLOG_PATH, 'w') as outfile:
     24             outfile.write(our_message)
     25 
     26         cmd_result = utils.run(
     27             'grep "%s" %s' % (our_message, self.SYSTEM_LOG_PATH),
     28             ignore_status=True)
     29         if cmd_result.exit_status:
     30             raise error.TestFail(
     31                 'our log message did not appear in %s' % self.SYSTEM_LOG_PATH)
     32