1# kernel message checker module
2#
3# Copyright (c) 2013, Intel Corporation
4#
5# Author: Johannes Berg <johannes@sipsolutions.net>
6#
7# This software may be distributed under the terms of the BSD license.
8# See README for more details.
9#
10"""
11Tests for kernel messages to find if there were any issues in them.
12"""
13
14import re
15
16lockdep_messages = [
17  'possible circular locking dependency',
18  '.*-safe -> .*unsafe lock order detected',
19  'possible recursive locking detected',
20  'inconsistent lock state',
21  'possible irq lock inversion dependency',
22  'suspicious RCU usage',
23]
24lockdep = r'(\[\s*)?(INFO|WARNING): (%s)|\*\*\* DEADLOCK \*\*\*' % ('|'.join(lockdep_messages), )
25issue = re.compile(r'(\[[0-9 .]*\] )?(WARNING:|BUG:|UBSAN:|%s|RTNL: assertion failed).*' % lockdep)
26
27def check_kernel(logfile):
28    for line in open(logfile, 'r'):
29        if issue.match(line):
30            return False
31    return True
32