From: Louis Rannou <louis.rannou@syslinbit.com>
To: openembedded-core@lists.openembedded.org
Cc: Louis Rannou <louis.rannou@non.se.com>
Subject: [PATCH v2] image_qa: fix error handling
Date: Fri, 13 Sep 2024 14:25:52 +0200 [thread overview]
Message-ID: <20240913-qa-v2-1-f86ae618ed90@syslinbit.com> (raw)
From: Louis Rannou <louis.rannou@non.se.com>
Make ImageQAFailed inherit BBHandledException so exceptions raised in tests are
catched when the actual test function is executed by bb.utils.better_exec.
Change the do_image_qa tasks so errors are handled with oe.qa.handle_error. Add
some comment to explain this requires to list the test in ERROR_QA or WARN_QA.
[YOCTO #14807]
https://bugzilla.yoctoproject.org/show_bug.cgi?id=14807
Signed-off-by: Louis Rannou <louis.rannou@non.se.com>
---
Changes in v2:
- EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v1: https://lore.kernel.org/r/20240913-qa-v1-1-70127fe0d549@syslinbit.com
---
meta/classes-recipe/image.bbclass | 11 ++++++-----
meta/lib/oe/utils.py | 2 +-
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/meta/classes-recipe/image.bbclass b/meta/classes-recipe/image.bbclass
index 32bafcdbbc..834ae03f3c 100644
--- a/meta/classes-recipe/image.bbclass
+++ b/meta/classes-recipe/image.bbclass
@@ -329,23 +329,24 @@ addtask do_image_complete_setscene
#
# The functions should use ${IMAGE_ROOTFS} to find the unpacked rootfs
# directory, which if QA passes will be the basis for the images.
+#
+# The functions should use oe.utils.ImageQAFailed(description, name) to raise
+# errors. The name must be listed in ERROR_QA or WARN_QA to prompt.
fakeroot python do_image_qa () {
from oe.utils import ImageQAFailed
qa_cmds = (d.getVar('IMAGE_QA_COMMANDS') or '').split()
- qamsg = ""
for cmd in qa_cmds:
try:
bb.build.exec_func(cmd, d)
except oe.utils.ImageQAFailed as e:
- qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description)
+ qamsg = 'Image QA function %s failed: %s\n' % (e.name, e.description)
+ oe.qa.handle_error(e.name, qamsg, d)
except Exception as e:
qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (cmd, e)
- if qamsg:
- imgname = d.getVar('IMAGE_NAME')
- bb.fatal("QA errors found whilst validating image: %s\n%s" % (imgname, qamsg))
+ oe.qa.exit_if_errors(d)
}
addtask do_image_qa after do_rootfs before do_image
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 14a7d07ef0..83f1440887 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -482,7 +482,7 @@ def get_multilib_datastore(variant, d):
localdata.setVar("MLPREFIX", "")
return localdata
-class ImageQAFailed(Exception):
+class ImageQAFailed(bb.BBHandledException):
def __init__(self, description, name=None, logfile=None):
self.description = description
self.name = name
---
base-commit: b6af956fe6e876957a49d4abf425e8c789bf0459
change-id: 20240913-qa-7bee7ec010d8
Best regards,
--
Louis Rannou <louis.rannou@syslinbit.com>
reply other threads:[~2024-09-13 12:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240913-qa-v2-1-f86ae618ed90@syslinbit.com \
--to=louis.rannou@syslinbit.com \
--cc=louis.rannou@non.se.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox