summaryrefslogtreecommitdiffstats
path: root/meta/classes/image.bbclass
diff options
context:
space:
mode:
authorJoshua Lock <joshua.g.lock@intel.com>2016-07-14 14:36:32 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-20 10:28:52 +0100
commit45180589422cb49d480830ca373122b484b71494 (patch)
treee11e61f8253451ca63458c4aac4ad4cd42663492 /meta/classes/image.bbclass
parentd1fdd0ad55cbf8908730b1bb104908ded5213a38 (diff)
downloadpoky-45180589422cb49d480830ca373122b484b71494.tar.gz
image: add do_image_qa task to run QA checks on the constructed image
This task runs all functions in IMAGE_QA_COMMANDS after the image construction has completed in order to validate the resulting image. Image sanity checks should either be Python functions which raise bb.build.FuncFailed on failure or shell functions with return a non-zero exit code. Python functions may instead raise an oe.utils.ImageQAFailed Exception which takes an extra argument, a description of the failure. python image_check_python_ok () { if True: raise bb.build.FuncFailed('This check always fails') else: bb.note("Nothing to see here") } image_check_shell_ok () { if true exit 1 else exit 0 fi } [YOCTO #9448] (From OE-Core rev: c9bef2ecf1a30159d11781184829f41844a58c13) Signed-off-by: Joshua Lock <joshua.g.lock@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/image.bbclass')
-rw-r--r--meta/classes/image.bbclass30
1 files changed, 30 insertions, 0 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 30dfd64828..af789f4588 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -275,6 +275,36 @@ do_image_complete[dirs] = "${TOPDIR}"
275do_image_complete[umask] = "022" 275do_image_complete[umask] = "022"
276addtask do_image_complete after do_image before do_build 276addtask do_image_complete after do_image before do_build
277 277
278# Add image-level QA/sanity checks to IMAGE_QA_COMMANDS
279#
280# IMAGE_QA_COMMANDS += " \
281# image_check_everything_ok \
282# "
283# This task runs all functions in IMAGE_QA_COMMANDS after the image
284# construction has completed in order to validate the resulting image.
285fakeroot python do_image_qa () {
286 from oe.utils import ImageQAFailed
287
288 qa_cmds = (d.getVar('IMAGE_QA_COMMANDS', True) or '').split()
289 qamsg = ""
290
291 for cmd in qa_cmds:
292 try:
293 bb.build.exec_func(cmd, d)
294 except oe.utils.ImageQAFailed as e:
295 qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description)
296 except bb.build.FuncFailed as e:
297 qamsg = qamsg + '\tImage QA function %s failed' % e.name
298 if e.logfile:
299 qamsg = qamsg + ' (log file is located at %s)' % e.logfile
300 qamsg = qamsg + '\n'
301
302 if qamsg:
303 imgname = d.getVar('IMAGE_NAME', True)
304 bb.fatal("QA errors found whilst validating image: %s\n%s" % (imgname, qamsg))
305}
306addtask do_image_qa after do_image_complete before do_build
307
278# 308#
279# Write environment variables used by wic 309# Write environment variables used by wic
280# to tmp/sysroots/<machine>/imgdata/<image>.env 310# to tmp/sysroots/<machine>/imgdata/<image>.env