aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2016-05-19 00:28:18 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-19 22:31:34 +0100
commitdd73dcac36b80b3b886a2e9bf575b91c4f60d039 (patch)
tree629776cb7739f5b271a7efa7a3766a8dc3b1b972
parentd6e3477749b1d09d40a773e0ac857a24d5851984 (diff)
downloadopenembedded-core-contrib-dd73dcac36b80b3b886a2e9bf575b91c4f60d039.tar.gz
rootfs.py: Unify _log_check_warn() and _log_check_error()
Use a common _log_check_common() function (based on the old _log_check_warn() function) to implement the logic for both _log_check_warn() and _log_check_error(). The main benefit of this is that now all error messages will be reported again, not just the first one found. Additionally the output will now look the same for both error and warning messages. This removes the context for the error messages. However, since there was no indication in the output that some of the lines were context, they were more confusing than helping. Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oe/rootfs.py52
1 files changed, 14 insertions, 38 deletions
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py
index 479e4ccc5e..f5c465fbd2 100644
--- a/meta/lib/oe/rootfs.py
+++ b/meta/lib/oe/rootfs.py
@@ -40,7 +40,7 @@ class Rootfs(object):
def _log_check(self):
pass
- def _log_check_warn(self):
+ def _log_check_common(self, type, match):
# Ignore any lines containing log_check to avoid recursion, and ignore
# lines beginning with a + since sh -x may emit code which isn't
# actually executed, but may contain error messages
@@ -48,7 +48,7 @@ class Rootfs(object):
if hasattr(self, 'log_check_expected_regexes'):
excludes.extend(self.log_check_expected_regexes)
excludes = [re.compile(x) for x in excludes]
- r = re.compile('^(warn|Warn|WARNING:)')
+ r = re.compile(match)
log_path = self.d.expand("${T}/log.do_rootfs")
messages = []
with open(log_path, 'r') as log:
@@ -65,45 +65,21 @@ class Rootfs(object):
messages.append('[log_check] %s' % line)
if messages:
if len(messages) == 1:
- msg = 'a warning message'
+ msg = '1 %s message' % type
else:
- msg = '%d warning messages' % len(messages)
- bb.warn('[log_check] %s: found %s in the logfile:\n%s'
- % (self.d.getVar('PN', True), msg, ''.join(messages)))
-
- def _log_check_error(self):
- # Ignore any lines containing log_check to avoid recursion, and ignore
- # lines beginning with a + since sh -x may emit code which isn't
- # actually executed, but may contain error messages
- excludes = [ 'log_check', r'^\+' ]
- if hasattr(self, 'log_check_expected_regexes'):
- excludes.extend(self.log_check_expected_regexes)
- excludes = [re.compile(x) for x in excludes]
- r = re.compile(self.log_check_regex)
- log_path = self.d.expand("${T}/log.do_rootfs")
- with open(log_path, 'r') as log:
- found_error = 0
- message = "\n"
- for line in log:
- for ee in excludes:
- m = ee.search(line)
- if m:
- break
- if m:
- continue
-
- m = r.search(line)
- if m:
- found_error = 1
- bb.warn('[log_check] %s: found an error message in the logfile (keyword \'%s\'):\n[log_check] %s'
- % (self.d.getVar('PN', True), m.group(), line))
+ msg = '%d %s messages' % (len(messages), type)
+ msg = '[log_check] %s: found %s in the logfile:\n%s' % \
+ (self.d.getVar('PN', True), msg, ''.join(messages))
+ if type == 'error':
+ bb.fatal(msg)
+ else:
+ bb.warn(msg)
- if found_error >= 1 and found_error <= 5:
- message += line + '\n'
- found_error += 1
+ def _log_check_warn(self):
+ self._log_check_common('warning', '^(warn|Warn|WARNING:)')
- if found_error == 6:
- bb.fatal(message)
+ def _log_check_error(self):
+ self._log_check_common('error', self.log_check_regex)
def _insert_feed_uris(self):
if bb.utils.contains("IMAGE_FEATURES", "package-management",