summaryrefslogtreecommitdiffstats
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:32:07 +0100
commit18eccfa3834dd0bf1f043c2583a2e655ce96eb62 (patch)
tree4e43860467fdc5d60b0b8bbf6ff1ffd833567fdc
parent9948e0d3cb1f9aa04cf6c33d6fe4ba3bdea4e77a (diff)
downloadpoky-18eccfa3834dd0bf1f043c2583a2e655ce96eb62.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. (From OE-Core rev: dd73dcac36b80b3b886a2e9bf575b91c4f60d039) 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):
40 def _log_check(self): 40 def _log_check(self):
41 pass 41 pass
42 42
43 def _log_check_warn(self): 43 def _log_check_common(self, type, match):
44 # Ignore any lines containing log_check to avoid recursion, and ignore 44 # Ignore any lines containing log_check to avoid recursion, and ignore
45 # lines beginning with a + since sh -x may emit code which isn't 45 # lines beginning with a + since sh -x may emit code which isn't
46 # actually executed, but may contain error messages 46 # actually executed, but may contain error messages
@@ -48,7 +48,7 @@ class Rootfs(object):
48 if hasattr(self, 'log_check_expected_regexes'): 48 if hasattr(self, 'log_check_expected_regexes'):
49 excludes.extend(self.log_check_expected_regexes) 49 excludes.extend(self.log_check_expected_regexes)
50 excludes = [re.compile(x) for x in excludes] 50 excludes = [re.compile(x) for x in excludes]
51 r = re.compile('^(warn|Warn|WARNING:)') 51 r = re.compile(match)
52 log_path = self.d.expand("${T}/log.do_rootfs") 52 log_path = self.d.expand("${T}/log.do_rootfs")
53 messages = [] 53 messages = []
54 with open(log_path, 'r') as log: 54 with open(log_path, 'r') as log:
@@ -65,45 +65,21 @@ class Rootfs(object):
65 messages.append('[log_check] %s' % line) 65 messages.append('[log_check] %s' % line)
66 if messages: 66 if messages:
67 if len(messages) == 1: 67 if len(messages) == 1:
68 msg = 'a warning message' 68 msg = '1 %s message' % type
69 else: 69 else:
70 msg = '%d warning messages' % len(messages) 70 msg = '%d %s messages' % (len(messages), type)
71 bb.warn('[log_check] %s: found %s in the logfile:\n%s' 71 msg = '[log_check] %s: found %s in the logfile:\n%s' % \
72 % (self.d.getVar('PN', True), msg, ''.join(messages))) 72 (self.d.getVar('PN', True), msg, ''.join(messages))
73 73 if type == 'error':
74 def _log_check_error(self): 74 bb.fatal(msg)
75 # Ignore any lines containing log_check to avoid recursion, and ignore 75 else:
76 # lines beginning with a + since sh -x may emit code which isn't 76 bb.warn(msg)
77 # actually executed, but may contain error messages
78 excludes = [ 'log_check', r'^\+' ]
79 if hasattr(self, 'log_check_expected_regexes'):
80 excludes.extend(self.log_check_expected_regexes)
81 excludes = [re.compile(x) for x in excludes]
82 r = re.compile(self.log_check_regex)
83 log_path = self.d.expand("${T}/log.do_rootfs")
84 with open(log_path, 'r') as log:
85 found_error = 0
86 message = "\n"
87 for line in log:
88 for ee in excludes:
89 m = ee.search(line)
90 if m:
91 break
92 if m:
93 continue
94
95 m = r.search(line)
96 if m:
97 found_error = 1
98 bb.warn('[log_check] %s: found an error message in the logfile (keyword \'%s\'):\n[log_check] %s'
99 % (self.d.getVar('PN', True), m.group(), line))
100 77
101 if found_error >= 1 and found_error <= 5: 78 def _log_check_warn(self):
102 message += line + '\n' 79 self._log_check_common('warning', '^(warn|Warn|WARNING:)')
103 found_error += 1
104 80
105 if found_error == 6: 81 def _log_check_error(self):
106 bb.fatal(message) 82 self._log_check_common('error', self.log_check_regex)
107 83
108 def _insert_feed_uris(self): 84 def _insert_feed_uris(self):
109 if bb.utils.contains("IMAGE_FEATURES", "package-management", 85 if bb.utils.contains("IMAGE_FEATURES", "package-management",