summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/runtime/cases/parselogs.py40
1 files changed, 35 insertions, 5 deletions
diff --git a/meta/lib/oeqa/runtime/cases/parselogs.py b/meta/lib/oeqa/runtime/cases/parselogs.py
index cddb846bdf..5527ebd271 100644
--- a/meta/lib/oeqa/runtime/cases/parselogs.py
+++ b/meta/lib/oeqa/runtime/cases/parselogs.py
@@ -6,6 +6,7 @@
6 6
7import collections 7import collections
8import os 8import os
9import sys
9 10
10from shutil import rmtree 11from shutil import rmtree
11from oeqa.runtime.case import OERuntimeTestCase 12from oeqa.runtime.case import OERuntimeTestCase
@@ -190,6 +191,23 @@ ignore_errors = {
190 ] + common_errors, 191 ] + common_errors,
191} 192}
192 193
194
195# importlib.resources.open_text in Python <3.10 doesn't search all directories
196# when a package is split across multiple directories. Until we can rely on
197# 3.10+, reimplement the searching logic.
198if sys.version_info < (3, 10):
199 def _open_text(package, resource):
200 import importlib, pathlib
201 module = importlib.import_module(package)
202 for path in module.__path__:
203 candidate = pathlib.Path(path) / resource
204 if candidate.exists():
205 return candidate.open(encoding='utf-8')
206 raise FileNotFoundError
207else:
208 from importlib.resources import open_text as _open_text
209
210
193class ParseLogsTest(OERuntimeTestCase): 211class ParseLogsTest(OERuntimeTestCase):
194 212
195 # Which log files should be collected 213 # Which log files should be collected
@@ -198,6 +216,9 @@ class ParseLogsTest(OERuntimeTestCase):
198 # The keywords that identify error messages in the log files 216 # The keywords that identify error messages in the log files
199 errors = ["error", "cannot", "can't", "failed"] 217 errors = ["error", "cannot", "can't", "failed"]
200 218
219 # A list of error messages that should be ignored
220 ignore_errors = []
221
201 @classmethod 222 @classmethod
202 def setUpClass(cls): 223 def setUpClass(cls):
203 # When systemd is enabled we need to notice errors on 224 # When systemd is enabled we need to notice errors on
@@ -212,11 +233,20 @@ class ParseLogsTest(OERuntimeTestCase):
212 233
213 cls.errors = [s.casefold() for s in cls.errors] 234 cls.errors = [s.casefold() for s in cls.errors]
214 235
215 try: 236 cls.load_machine_ignores()
216 cls.ignore_errors = [s.casefold() for s in ignore_errors[cls.td.get('MACHINE')]] 237
217 except KeyError: 238 @classmethod
218 cls.logger.info('No ignore list found for this machine, using default') 239 def load_machine_ignores(cls):
219 cls.ignore_errors = [s.casefold() for s in ignore_errors['default']] 240 # Add TARGET_ARCH explicitly as not every machine has that in MACHINEOVERRDES (eg qemux86-64)
241 for candidate in ["common", cls.td.get("TARGET_ARCH")] + cls.td.get("MACHINEOVERRIDES").split(":"):
242 try:
243 name = f"parselogs-ignores-{candidate}.txt"
244 for line in _open_text("oeqa.runtime.cases", name):
245 line = line.strip()
246 if line and not line.startswith("#"):
247 cls.ignore_errors.append(line.casefold())
248 except FileNotFoundError:
249 pass
220 250
221 # Go through the log locations provided and if it's a folder 251 # Go through the log locations provided and if it's a folder
222 # create a list with all the .log files in it, if it's a file 252 # create a list with all the .log files in it, if it's a file