[OE-core] [PATCH] image: add mechanism to run QA checks on the image once it's built
Joshua Lock
joshua.g.lock at intel.com
Tue Jun 7 14:50:37 UTC 2016
Add a mechanism to run QA checks on a constructed image once it's
complete. All checks will be run with any one failure resulting in
a failed build.
QA checks should be bitbake functions which throw a
NotImplementedError when the check QA fails, with any error
messages passed to the exception.
Specify which checks to run by adding them to IMAGE_QA_COMMANDS.
i.e.
IMAGE_QA_COMMANDS += " \
image_check_everything_ok \
"
python image_check_everything_ok () {
raise NotImplementedError('This check always fails')
}
This code is based heavily on the configuration upgrade code in
sanity.bbclass.
[YOCTO #9448]
Signed-off-by: Joshua Lock <joshua.g.lock at intel.com>
---
meta/classes/image.bbclass | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 9f4c83f..40bcd16 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -260,6 +260,35 @@ do_image_complete[dirs] = "${TOPDIR}"
do_image_complete[umask] = "022"
addtask do_image_complete after do_image before do_build
+# Add image-level QA/sanity checks to IMAGE_QA_COMMANDS
+#
+# IMAGE_QA_COMMANDS += " \
+# image_check_everything_ok \
+# "
+# 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 raise a NotImplementedError when they fail,
+# passing any failure messages to the Exception. For example:
+#
+# python image_check_everything_ok () {
+# raise NotImplementedError('This check always fails')
+# }
+fakeroot python do_image_qa () {
+ qa_cmds = (d.getVar('IMAGE_QA_COMMANDS', True) or '').split()
+ imageqasane = True
+
+ for cmd in qa_cmds:
+ try:
+ bb.build.exec_func(cmd, d, pythonexception=True)
+ except NotImplementedError as e:
+ imageqasane = False
+ bb.error(str(e))
+
+ if not imageqasane:
+ bb.fatal("QA errors found whilst validating image: %s" % d.getVar('IMAGE_NAME', True))
+}
+addtask do_image_qa after do_image_complete before do_build
+
#
# Write environment variables used by wic
# to tmp/sysroots/<machine>/imgdata/<image>.env
--
2.7.4
More information about the Openembedded-core
mailing list