]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
image_qa: fix error handling
authorLouis Rannou <louis.rannou@non.se.com>
Fri, 13 Sep 2024 12:25:52 +0000 (14:25 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 17 Sep 2024 11:15:57 +0000 (12:15 +0100)
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>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/image.bbclass
meta/lib/oe/utils.py

index 32bafcdbbc3f638afd3ad0da73f94150214ade0e..834ae03f3cdc9713c5c226dc8a4fd2ff60c1bd9d 100644 (file)
@@ -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
 
index 14a7d07ef011b0860404c4d88cb591c6e3dabfeb..83f144088757d87d235c6a9673285e949592f1e5 100644 (file)
@@ -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