summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Rannou <louis.rannou@non.se.com>2024-09-13 14:25:52 +0200
committerSteve Sakoman <steve@sakoman.com>2024-10-18 06:04:41 -0700
commit2c09c72cf1e460b50cb2585730b4c946d3cb131b (patch)
tree4d9d987517fd96873404771c9f73b5eff8837fdb
parentcbd445e04485e86ca28ec81b61389efda3dc7f1a (diff)
downloadpoky-2c09c72cf1e460b50cb2585730b4c946d3cb131b.tar.gz
image_qa: fix error handling
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 (From OE-Core rev: 8fe7aef17eefa70e3f7c07077b8c695e5c00ed5e) Signed-off-by: Louis Rannou <louis.rannou@non.se.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 905e224849fbbed1719e0add231b00e2d570b3b4) Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/classes-recipe/image.bbclass11
-rw-r--r--meta/lib/oe/utils.py2
2 files changed, 7 insertions, 6 deletions
diff --git a/meta/classes-recipe/image.bbclass b/meta/classes-recipe/image.bbclass
index 28be6c6362..a682b5f3b2 100644
--- a/meta/classes-recipe/image.bbclass
+++ b/meta/classes-recipe/image.bbclass
@@ -308,23 +308,24 @@ addtask do_image_complete_setscene
308# 308#
309# The functions should use ${IMAGE_ROOTFS} to find the unpacked rootfs 309# The functions should use ${IMAGE_ROOTFS} to find the unpacked rootfs
310# directory, which if QA passes will be the basis for the images. 310# directory, which if QA passes will be the basis for the images.
311#
312# The functions should use oe.utils.ImageQAFailed(description, name) to raise
313# errors. The name must be listed in ERROR_QA or WARN_QA to prompt.
311fakeroot python do_image_qa () { 314fakeroot python do_image_qa () {
312 from oe.utils import ImageQAFailed 315 from oe.utils import ImageQAFailed
313 316
314 qa_cmds = (d.getVar('IMAGE_QA_COMMANDS') or '').split() 317 qa_cmds = (d.getVar('IMAGE_QA_COMMANDS') or '').split()
315 qamsg = ""
316 318
317 for cmd in qa_cmds: 319 for cmd in qa_cmds:
318 try: 320 try:
319 bb.build.exec_func(cmd, d) 321 bb.build.exec_func(cmd, d)
320 except oe.utils.ImageQAFailed as e: 322 except oe.utils.ImageQAFailed as e:
321 qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description) 323 qamsg = 'Image QA function %s failed: %s\n' % (e.name, e.description)
324 oe.qa.handle_error(e.name, qamsg, d)
322 except Exception as e: 325 except Exception as e:
323 qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (cmd, e) 326 qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (cmd, e)
324 327
325 if qamsg: 328 oe.qa.exit_if_errors(d)
326 imgname = d.getVar('IMAGE_NAME')
327 bb.fatal("QA errors found whilst validating image: %s\n%s" % (imgname, qamsg))
328} 329}
329addtask do_image_qa after do_rootfs before do_image 330addtask do_image_qa after do_rootfs before do_image
330 331
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):
482 localdata.setVar("MLPREFIX", "") 482 localdata.setVar("MLPREFIX", "")
483 return localdata 483 return localdata
484 484
485class ImageQAFailed(Exception): 485class ImageQAFailed(bb.BBHandledException):
486 def __init__(self, description, name=None, logfile=None): 486 def __init__(self, description, name=None, logfile=None):
487 self.description = description 487 self.description = description
488 self.name = name 488 self.name = name