diff options
author | Ross Burton <ross.burton@arm.com> | 2023-12-04 18:24:17 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-12-06 22:55:49 +0000 |
commit | 41ffa169123c3344d8349061eeca362c03f5f9f8 (patch) | |
tree | d8a5704770b87c73c1c50d9c49ae99324e083a8e /meta/lib/oeqa/runtime | |
parent | 66734b787a1e72dd167e354dbb64478db8d53183 (diff) | |
download | poky-41ffa169123c3344d8349061eeca362c03f5f9f8.tar.gz |
oeqa/runtime/parselogs: load ignores from disk
Instead of hardcoding the list of ignored errors/warnings in the test
itself, read them plain text files on disk.
This uses importlib to try to open a file called
oeqa.runtime.cases.parselogs-ignores-[candidate].txt, where the
candidate will be:
- "common"
- The TARGET_ARCH
- Each of the MACHINEOVERRDES
This allows the common and tune-specific ignores to be retained in
oe-core, and machine-specific ignores added to the layer where the
machine is defined.
[ YOCTO #14604 ]
(From OE-Core rev: 7a04063f7cff243fe2bee09664ad7979612110cb)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/runtime')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/parselogs.py | 40 |
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 | ||
7 | import collections | 7 | import collections |
8 | import os | 8 | import os |
9 | import sys | ||
9 | 10 | ||
10 | from shutil import rmtree | 11 | from shutil import rmtree |
11 | from oeqa.runtime.case import OERuntimeTestCase | 12 | from 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. | ||
198 | if 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 | ||
207 | else: | ||
208 | from importlib.resources import open_text as _open_text | ||
209 | |||
210 | |||
193 | class ParseLogsTest(OERuntimeTestCase): | 211 | class 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 |