Patchwork [2/5] classes/testimage-auto: add class to allow automatically running image tests

login
register
mail settings
Submitter Paul Eggleton
Date Sept. 20, 2013, 9:27 a.m.
Message ID <ceb65c408a19ce7c1b5223b5a3029a0ebfb39a9b.1379669217.git.paul.eggleton@linux.intel.com>
Download mbox | patch
Permalink /patch/58425/
State New
Headers show

Comments

Paul Eggleton - Sept. 20, 2013, 9:27 a.m.
Setting TEST_IMAGE = "1" alone will now automatically run tests on the
image immediately after the image is built instead of having to add
INHERIT += "testimage" and run bitbake -c testimage <image> manually
(but that will still work). This restores functionality that was
present in the older imagetest-qemu class with IMAGETEST.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 meta/classes/image.bbclass          |  3 +++
 meta/classes/testimage-auto.bbclass | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 meta/classes/testimage-auto.bbclass
Paul Eggleton - Sept. 20, 2013, 9:41 a.m.
On Friday 20 September 2013 10:27:50 Paul Eggleton wrote:
> +do_testimage_auto[nostamp] = "1"

Oops, this is erroneous; I have removed it on the branch.

Cheers,
Paul

Patch

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 889547a..246a4db 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -16,6 +16,9 @@  RRECOMMENDS += "${PACKAGE_INSTALL_ATTEMPTONLY}"
 
 INHIBIT_DEFAULT_DEPS = "1"
 
+TESTIMAGECLASS = "${@base_conditional('TEST_IMAGE', '1', 'testimage-auto', '', d)}"
+inherit ${TESTIMAGECLASS}
+
 # IMAGE_FEATURES may contain any available package group
 IMAGE_FEATURES ?= ""
 IMAGE_FEATURES[type] = "list"
diff --git a/meta/classes/testimage-auto.bbclass b/meta/classes/testimage-auto.bbclass
new file mode 100644
index 0000000..1fc7593
--- /dev/null
+++ b/meta/classes/testimage-auto.bbclass
@@ -0,0 +1,24 @@ 
+# Copyright (C) 2013 Intel Corporation
+#
+# Released under the MIT license (see COPYING.MIT)
+
+
+# Run tests automatically on an image after the image is constructed
+# (as opposed to testimage.bbclass alone where tests must be called
+# manually using bitbake -c testimage <image>).
+#
+# NOTE: to use this class, simply set TEST_IMAGE = "1" - no need to
+# inherit it since that will be done in image.bbclass when this variable
+# has been set.
+#
+# See testimage.bbclass for the test implementation.
+
+inherit testimage
+
+python do_testimage_auto() {
+    testimage_main(d)
+}
+addtask testimage_auto before do_build after do_rootfs
+do_testimage_auto[nostamp] = "1"
+do_testimage_auto[depends] += "qemu-native:do_populate_sysroot"
+do_testimage_auto[depends] += "qemu-helper-native:do_populate_sysroot"