summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe
diff options
context:
space:
mode:
authorLouis Rannou <louis.rannou@non.se.com>2024-09-13 14:25:52 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-09-17 12:16:01 +0100
commit48a898fdfbb85e35edd4342321d7be0393624934 (patch)
treefe5ce732fb1522e2833aaed667a780ee89c147f7 /meta/classes-recipe
parent099c09be3c37743425486664c6457bd0301c74f0 (diff)
downloadpoky-48a898fdfbb85e35edd4342321d7be0393624934.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: 905e224849fbbed1719e0add231b00e2d570b3b4) Signed-off-by: Louis Rannou <louis.rannou@non.se.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe')
-rw-r--r--meta/classes-recipe/image.bbclass11
1 files changed, 6 insertions, 5 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
329# 329#
330# The functions should use ${IMAGE_ROOTFS} to find the unpacked rootfs 330# The functions should use ${IMAGE_ROOTFS} to find the unpacked rootfs
331# directory, which if QA passes will be the basis for the images. 331# directory, which if QA passes will be the basis for the images.
332#
333# The functions should use oe.utils.ImageQAFailed(description, name) to raise
334# errors. The name must be listed in ERROR_QA or WARN_QA to prompt.
332fakeroot python do_image_qa () { 335fakeroot python do_image_qa () {
333 from oe.utils import ImageQAFailed 336 from oe.utils import ImageQAFailed
334 337
335 qa_cmds = (d.getVar('IMAGE_QA_COMMANDS') or '').split() 338 qa_cmds = (d.getVar('IMAGE_QA_COMMANDS') or '').split()
336 qamsg = ""
337 339
338 for cmd in qa_cmds: 340 for cmd in qa_cmds:
339 try: 341 try:
340 bb.build.exec_func(cmd, d) 342 bb.build.exec_func(cmd, d)
341 except oe.utils.ImageQAFailed as e: 343 except oe.utils.ImageQAFailed as e:
342 qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description) 344 qamsg = 'Image QA function %s failed: %s\n' % (e.name, e.description)
345 oe.qa.handle_error(e.name, qamsg, d)
343 except Exception as e: 346 except Exception as e:
344 qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (cmd, e) 347 qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (cmd, e)
345 348
346 if qamsg: 349 oe.qa.exit_if_errors(d)
347 imgname = d.getVar('IMAGE_NAME')
348 bb.fatal("QA errors found whilst validating image: %s\n%s" % (imgname, qamsg))
349} 350}
350addtask do_image_qa after do_rootfs before do_image 351addtask do_image_qa after do_rootfs before do_image
351 352