All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] image: Combine all the class handling code into a single section
@ 2018-06-19 11:45 Richard Purdie
  2018-06-19 11:45 ` [PATCH 2/3] image/image-live: Improve handling of live/iso/hddimg types (drop NOISO/NOHDD) Richard Purdie
  2018-06-19 11:45 ` [PATCH 3/3] image/testimage: Rework auto image test execution Richard Purdie
  0 siblings, 2 replies; 10+ messages in thread
From: Richard Purdie @ 2018-06-19 11:45 UTC (permalink / raw)
  To: openembedded-core

Right now the code handling class inherits is spread all over and
its hard to get an idea of what is happening overall. Combine all
the code together to make it clearer. There shoould be no functionality
changes.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/image.bbclass | 45 ++++++++++++++------------------------
 1 file changed, 17 insertions(+), 28 deletions(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 16c6b1256e2..cc889cf5dfe 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -1,9 +1,23 @@
-inherit rootfs_${IMAGE_PKGTYPE}
+def build_live(d):
+    if bb.utils.contains("IMAGE_FSTYPES", "live", "live", "0", d) == "0": # live is not set but hob might set iso or hddimg
+        d.setVar('NOISO', bb.utils.contains('IMAGE_FSTYPES', "iso", "0", "1", d))
+        d.setVar('NOHDD', bb.utils.contains('IMAGE_FSTYPES', "hddimg", "0", "1", d))
+        if d.getVar('NOISO') == "0" or d.getVar('NOHDD') == "0":
+            return "image-live"
+        return ""
+    return "image-live"
 
+# Handle inherits of any of the image classes we need
+IMGCLASSES = "rootfs_${IMAGE_PKGTYPE} image_types ${IMAGE_CLASSES}"
 # Only Linux SDKs support populate_sdk_ext, fall back to populate_sdk_base
 # in the non-Linux SDK_OS case, such as mingw32
-SDKEXTCLASS ?= "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
-inherit ${SDKEXTCLASS}
+IMGCLASSES += "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
+IMGCLASSES += "${@build_live(d)}"
+IMGCLASSES += "${@bb.utils.contains('IMAGE_FSTYPES', 'container', 'image-container', '', d)}"
+IMGCLASSES += "image_types_wic"
+IMGCLASSES += "${@oe.utils.conditional('TEST_IMAGE', '1', 'testimage-auto', '', d)}"
+IMGCLASSES += "rootfs-postcommands"
+inherit ${IMGCLASSES}
 
 TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}"
 TOOLCHAIN_TARGET_TASK_ATTEMPTONLY += "${PACKAGE_INSTALL_ATTEMPTONLY}"
@@ -18,9 +32,6 @@ PATH_prepend = "${@":".join(all_multilib_tune_values(d, 'STAGING_BINDIR_CROSS').
 
 INHIBIT_DEFAULT_DEPS = "1"
 
-TESTIMAGECLASS = "${@oe.utils.conditional('TEST_IMAGE', '1', 'testimage-auto', '', d)}"
-inherit ${TESTIMAGECLASS}
-
 # IMAGE_FEATURES may contain any available package group
 IMAGE_FEATURES ?= ""
 IMAGE_FEATURES[type] = "list"
@@ -127,23 +138,6 @@ do_rootfs[vardeps] += "${@rootfs_variables(d)}"
 
 do_build[depends] += "virtual/kernel:do_deploy"
 
-def build_live(d):
-    if bb.utils.contains("IMAGE_FSTYPES", "live", "live", "0", d) == "0": # live is not set but hob might set iso or hddimg
-        d.setVar('NOISO', bb.utils.contains('IMAGE_FSTYPES', "iso", "0", "1", d))
-        d.setVar('NOHDD', bb.utils.contains('IMAGE_FSTYPES', "hddimg", "0", "1", d))
-        if d.getVar('NOISO') == "0" or d.getVar('NOHDD') == "0":
-            return "image-live"
-        return ""
-    return "image-live"
-
-IMAGE_TYPE_live = "${@build_live(d)}"
-inherit ${IMAGE_TYPE_live}
-
-IMAGE_TYPE_container = '${@bb.utils.contains("IMAGE_FSTYPES", "container", "image-container", "", d)}'
-inherit ${IMAGE_TYPE_container}
-
-IMAGE_TYPE_wic = "image_types_wic"
-inherit ${IMAGE_TYPE_wic}
 
 python () {
     def extraimage_getdepends(task):
@@ -178,9 +172,6 @@ python () {
     check_image_features(d)
 }
 
-IMAGE_CLASSES += "image_types"
-inherit ${IMAGE_CLASSES}
-
 IMAGE_POSTPROCESS_COMMAND ?= ""
 
 # some default locales
@@ -192,8 +183,6 @@ LINGUAS_INSTALL ?= "${@" ".join(map(lambda s: "locale-base-%s" % s, d.getVar('IM
 # aren't yet available.
 PSEUDO_PASSWD = "${IMAGE_ROOTFS}:${STAGING_DIR_NATIVE}"
 
-inherit rootfs-postcommands
-
 PACKAGE_EXCLUDE ??= ""
 PACKAGE_EXCLUDE[type] = "list"
 
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] image/image-live: Improve handling of live/iso/hddimg types (drop NOISO/NOHDD)
  2018-06-19 11:45 [PATCH 1/3] image: Combine all the class handling code into a single section Richard Purdie
@ 2018-06-19 11:45 ` Richard Purdie
  2018-06-19 11:45 ` [PATCH 3/3] image/testimage: Rework auto image test execution Richard Purdie
  1 sibling, 0 replies; 10+ messages in thread
From: Richard Purdie @ 2018-06-19 11:45 UTC (permalink / raw)
  To: openembedded-core

The logic can be improved and the historical NOISO/NOHDD variables
moved into the class and out of common code.

The variables are also then removed in favour of directly controlling
the behaviour from IMAGE_FSTYPES in line with all the other image types.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/image-live.bbclass        |  8 +++-----
 meta/classes/image.bbclass             | 11 +----------
 meta/conf/documentation.conf           |  2 --
 meta/conf/machine/include/x86-base.inc |  3 +--
 4 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/meta/classes/image-live.bbclass b/meta/classes/image-live.bbclass
index 966277c6785..942298a7ce3 100644
--- a/meta/classes/image-live.bbclass
+++ b/meta/classes/image-live.bbclass
@@ -19,8 +19,6 @@
 
 # External variables (also used by syslinux.bbclass)
 # ${INITRD} - indicates a list of filesystem images to concatenate and use as an initrd (optional)
-# ${NOISO}  - skip building the ISO image if set to 1
-# ${NOHDD}  - skip building the HDD image if set to 1
 # ${HDDIMG_ID} - FAT image volume-id
 # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
 
@@ -80,8 +78,8 @@ populate_live() {
 }
 
 build_iso() {
-	# Only create an ISO if we have an INITRD and NOISO was not set
-	if [ -z "${INITRD}" ] || [ "${NOISO}" = "1" ]; then
+	# Only create an ISO if we have an INITRD and the live or iso image type was selected
+	if [ -z "${INITRD}" ] || [ "${@bb.utils.contains_any('IMAGE_FSTYPES', 'live iso', '1', '0', d)}" != "1" ]; then
 		bbnote "ISO image will not be created."
 		return
 	fi
@@ -217,7 +215,7 @@ build_fat_img() {
 
 build_hddimg() {
 	# Create an HDD image
-	if [ "${NOHDD}" != "1" ] ; then
+	if [ "${@bb.utils.contains_any('IMAGE_FSTYPES', 'live hddimg', '1', '0', d)}" = "1" ] ; then
 		populate_live ${HDDDIR}
 
 		if [ "${PCBIOS}" = "1" ]; then
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index cc889cf5dfe..c4fc457985b 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -1,18 +1,9 @@
-def build_live(d):
-    if bb.utils.contains("IMAGE_FSTYPES", "live", "live", "0", d) == "0": # live is not set but hob might set iso or hddimg
-        d.setVar('NOISO', bb.utils.contains('IMAGE_FSTYPES', "iso", "0", "1", d))
-        d.setVar('NOHDD', bb.utils.contains('IMAGE_FSTYPES', "hddimg", "0", "1", d))
-        if d.getVar('NOISO') == "0" or d.getVar('NOHDD') == "0":
-            return "image-live"
-        return ""
-    return "image-live"
-
 # Handle inherits of any of the image classes we need
 IMGCLASSES = "rootfs_${IMAGE_PKGTYPE} image_types ${IMAGE_CLASSES}"
 # Only Linux SDKs support populate_sdk_ext, fall back to populate_sdk_base
 # in the non-Linux SDK_OS case, such as mingw32
 IMGCLASSES += "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
-IMGCLASSES += "${@build_live(d)}"
+IMGCLASSES += "${@bb.utils.contains_any('IMAGE_FSTYPES', 'live iso hddimg', 'image-live', '', d)}"
 IMGCLASSES += "${@bb.utils.contains('IMAGE_FSTYPES', 'container', 'image-container', '', d)}"
 IMGCLASSES += "image_types_wic"
 IMGCLASSES += "${@oe.utils.conditional('TEST_IMAGE', '1', 'testimage-auto', '', d)}"
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index 254f8f19604..3189dd39b72 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -288,8 +288,6 @@ MULTIMACH_TARGET_SYS[doc] = "Separates files for different machines such that yo
 
 NATIVELSBSTRING[doc] = "A string identifying the host distribution."
 NO_RECOMMENDATIONS[doc] = "When set to '1', no recommended packages will be installed. Realize that some recommended packages might be required for certain system functionality, such as kernel-modules. It is up to the user to add packages to IMAGE_INSTALL as needed."
-NOHDD[doc] = "Causes the OpenEmbedded build system to skip building the .hddimg image."
-NOISO[doc] = "Causes the OpenEmbedded build system to skip building the ISO image."
 
 #O
 
diff --git a/meta/conf/machine/include/x86-base.inc b/meta/conf/machine/include/x86-base.inc
index f8aacea64cc..0edcea7f561 100644
--- a/meta/conf/machine/include/x86-base.inc
+++ b/meta/conf/machine/include/x86-base.inc
@@ -10,8 +10,7 @@ MACHINE_FEATURES += "screen keyboard pci usbhost ext2 ext3 x86 \
 
 MACHINE_EXTRA_RRECOMMENDS += "kernel-modules"
 
-IMAGE_FSTYPES ?= "live"
-NOISO ?= "1"
+IMAGE_FSTYPES ?= "hddimg"
 
 KERNEL_IMAGETYPE ?= "bzImage"
 
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] image/testimage: Rework auto image test execution
  2018-06-19 11:45 [PATCH 1/3] image: Combine all the class handling code into a single section Richard Purdie
  2018-06-19 11:45 ` [PATCH 2/3] image/image-live: Improve handling of live/iso/hddimg types (drop NOISO/NOHDD) Richard Purdie
@ 2018-06-19 11:45 ` Richard Purdie
  2018-06-19 13:06   ` Paulo Neves
  2018-06-20  0:47   ` ChenQi
  1 sibling, 2 replies; 10+ messages in thread
From: Richard Purdie @ 2018-06-19 11:45 UTC (permalink / raw)
  To: openembedded-core

The TEST_IMAGE interface has never particularly worked and image testing currently
gets configured manually.

This reworks the interface to better serve the needs of its users, replacing it
with TESTIMAGE_AUTO.

This does away with the need for the separate class due to better bitbake APIs for
changing tasks.

TESTIMAGE_AUTO will automatically boot under qemu any image that is built. It
also adds in dependencies so that any SDK for which testing is requested will
automatically be built first.

The code in bitbake.conf was error prone (e.g. testsdk wasn't considered), this
improves it to standardise on IMAGE_CLASSES as the standard configuration mechanism.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/image.bbclass          |  1 -
 meta/classes/testimage-auto.bbclass | 23 -----------------------
 meta/classes/testimage.bbclass      | 10 +++++++++-
 meta/classes/testsdk.bbclass        |  5 +++++
 meta/conf/bitbake.conf              |  2 +-
 meta/conf/documentation.conf        |  2 +-
 meta/conf/local.conf.sample         | 10 ++++++----
 7 files changed, 22 insertions(+), 31 deletions(-)
 delete mode 100644 meta/classes/testimage-auto.bbclass

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index c4fc457985b..24c1a983f3e 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -6,7 +6,6 @@ IMGCLASSES += "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar(
 IMGCLASSES += "${@bb.utils.contains_any('IMAGE_FSTYPES', 'live iso hddimg', 'image-live', '', d)}"
 IMGCLASSES += "${@bb.utils.contains('IMAGE_FSTYPES', 'container', 'image-container', '', d)}"
 IMGCLASSES += "image_types_wic"
-IMGCLASSES += "${@oe.utils.conditional('TEST_IMAGE', '1', 'testimage-auto', '', d)}"
 IMGCLASSES += "rootfs-postcommands"
 inherit ${IMGCLASSES}
 
diff --git a/meta/classes/testimage-auto.bbclass b/meta/classes/testimage-auto.bbclass
deleted file mode 100644
index e0a22b773c8..00000000000
--- a/meta/classes/testimage-auto.bbclass
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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_image_complete
-do_testimage_auto[depends] += "${TESTIMAGEDEPENDS}"
-do_testimage_auto[lockfiles] += "${TESTIMAGELOCK}"
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index c17a7c604b4..1be22f63047 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -10,6 +10,11 @@
 # - first add IMAGE_CLASSES += "testimage" in local.conf
 # - build a qemu core-image-sato
 # - then bitbake core-image-sato -c testimage. That will run a standard suite of tests.
+#
+# The tests can be run automatically each time an image is built if you set
+# TESTIMAGE_AUTO = "1"
+
+TESTIMAGE_AUTO ??= "0"
 
 # You can set (or append to) TEST_SUITES in local.conf to select the tests
 # which you want to run for your target.
@@ -382,4 +387,7 @@ def package_extraction(d, test_suites):
 
 testimage_main[vardepsexclude] += "BB_ORIGENV DATETIME"
 
-inherit testsdk
+python () {
+    if oe.types.boolean(d.getVar("TESTIMAGE_AUTO")):
+        bb.build.addtask("testimage", "do_build", "do_image_complete", d)
+}
diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass
index 2e43343643e..f12725cbab8 100644
--- a/meta/classes/testsdk.bbclass
+++ b/meta/classes/testsdk.bbclass
@@ -194,3 +194,8 @@ python do_testsdkext() {
 addtask testsdkext
 do_testsdkext[nostamp] = "1"
 
+python () {
+    if oe.types.boolean(d.getVar("TESTIMAGE_AUTO")):
+        bb.build.addtask("testsdk", None, "do_populate_sdk", d)
+        bb.build.addtask("testsdkext", None, "do_populate_sdk_ext", d)
+}
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 3b2ef9fb47c..c4dba61cc6b 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -487,7 +487,7 @@ HOSTTOOLS += " \
 "
 
 # Tools needed to run testimage runtime image testing
-HOSTTOOLS += "${@'ip ping ps scp ssh stty' if (bb.data.inherits_class('testimage', d) or d.getVar('TEST_IMAGE') == '1') else ''}"
+HOSTTOOLS += "${@'ip ping ps scp ssh stty' if (bb.utils.contains_any('IMAGE_CLASSES', 'testimage testsdk', True, False, d)) else ''}"
 
 # Link to these if present
 HOSTTOOLS_NONFATAL += "aws ccache gcc-ar gpg ld.bfd ld.gold nc sftp socat ssh sudo"
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index 3189dd39b72..fc6d008807b 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -415,7 +415,7 @@ TARGET_PREFIX[doc] = "The prefix for the cross-compile toolchain (e.g. arm-linux
 TARGET_SYS[doc] = "The target system is comprised of TARGET_ARCH,TARGET_VENDOR and TARGET_OS."
 TCLIBC[doc] = "Specifies C library (libc) variant to use during the build process. You can select 'baremetal', 'glibc' or 'musl'."
 TCMODE[doc] = "Enables an external toolchain (where provided by an additional layer) if set to a value other than 'default'."
-TEST_IMAGE[doc] = "Enables test booting of virtual machine images under the QEMU emulator after any root filesystems are created and runs tests against those images."
+TESTIMAGE_AUTO[doc] = "Enables test booting of virtual machine images under the QEMU emulator after any root filesystems are created and runs tests against those images each time an image is built."
 TEST_QEMUBOOT_TIMEOUT[doc] = "The time in seconds allowed for an image to boot before automated runtime tests begin to run against an image."
 TEST_SUITES[doc] = "An ordered list of tests (modules) to run against an image when performing automated runtime testing."
 TEST_POWERCONTROL_CMD[doc] = "For automated hardware testing, specifies the command to use to control the power of the target machine under test"
diff --git a/meta/conf/local.conf.sample b/meta/conf/local.conf.sample
index 17cdd7046e5..1ac4156b903 100644
--- a/meta/conf/local.conf.sample
+++ b/meta/conf/local.conf.sample
@@ -135,10 +135,12 @@ USER_CLASSES ?= "buildstats image-mklibs image-prelink"
 # Runtime testing of images
 #
 # The build system can test booting virtual machine images under qemu (an emulator)
-# after any root filesystems are created and run tests against those images. To
-# enable this uncomment this line. See classes/testimage(-auto).bbclass for
-# further details.
-#TEST_IMAGE = "1"
+# after any root filesystems are created and run tests against those images. It can also
+# run tests against any SDK that are built. To enable this uncomment these lines.
+# See classes/test{image,sdk}.bbclass for further details.
+#IMAGE_CLASSES += "testimage testsdk"
+#TESTIMAGE_AUTO_qemuall = "1"
+
 #
 # Interactive shell configuration
 #
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] image/testimage: Rework auto image test execution
  2018-06-19 11:45 ` [PATCH 3/3] image/testimage: Rework auto image test execution Richard Purdie
@ 2018-06-19 13:06   ` Paulo Neves
  2018-06-19 13:13     ` Alexander Kanavin
  2018-06-19 13:19     ` Richard Purdie
  2018-06-20  0:47   ` ChenQi
  1 sibling, 2 replies; 10+ messages in thread
From: Paulo Neves @ 2018-06-19 13:06 UTC (permalink / raw)
  To: Richard Purdie; +Cc: OE-core

I support this patch and I see that one of the problems in sumo is
fixed, namely the HOSTTOOLS missing ip and ping.
Even so there is one HOSTTOOLS that is missing, ifconfig. As far as I
know the automatic network setup scripts of runqemu require ifconfig
for 192.168.7.1 tap setting. Without ifconfig the virtual machine
cannot be spawned.

Also, given the lack of the HOSTTOOLS in the sumo version i have, how
is this being tested?

I also would like to discuss the possibility of testing u-boot in a
virtual machine. I have a setup where I am able to pass to qemu,
u-boot.bin as a bios file, and then I am able to boot from tftp
enabled qemu network device. This allows for unification of test setup
of virtualized and real target booting. Do you have any integration
like this in the plans?

Paulo Neves

On Tue, Jun 19, 2018 at 1:45 PM, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> The TEST_IMAGE interface has never particularly worked and image testing currently
> gets configured manually.
>
> This reworks the interface to better serve the needs of its users, replacing it
> with TESTIMAGE_AUTO.
>
> This does away with the need for the separate class due to better bitbake APIs for
> changing tasks.
>
> TESTIMAGE_AUTO will automatically boot under qemu any image that is built. It
> also adds in dependencies so that any SDK for which testing is requested will
> automatically be built first.
>
> The code in bitbake.conf was error prone (e.g. testsdk wasn't considered), this
> improves it to standardise on IMAGE_CLASSES as the standard configuration mechanism.
>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/classes/image.bbclass          |  1 -
>  meta/classes/testimage-auto.bbclass | 23 -----------------------
>  meta/classes/testimage.bbclass      | 10 +++++++++-
>  meta/classes/testsdk.bbclass        |  5 +++++
>  meta/conf/bitbake.conf              |  2 +-
>  meta/conf/documentation.conf        |  2 +-
>  meta/conf/local.conf.sample         | 10 ++++++----
>  7 files changed, 22 insertions(+), 31 deletions(-)
>  delete mode 100644 meta/classes/testimage-auto.bbclass
>
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index c4fc457985b..24c1a983f3e 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -6,7 +6,6 @@ IMGCLASSES += "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar(
>  IMGCLASSES += "${@bb.utils.contains_any('IMAGE_FSTYPES', 'live iso hddimg', 'image-live', '', d)}"
>  IMGCLASSES += "${@bb.utils.contains('IMAGE_FSTYPES', 'container', 'image-container', '', d)}"
>  IMGCLASSES += "image_types_wic"
> -IMGCLASSES += "${@oe.utils.conditional('TEST_IMAGE', '1', 'testimage-auto', '', d)}"
>  IMGCLASSES += "rootfs-postcommands"
>  inherit ${IMGCLASSES}
>
> diff --git a/meta/classes/testimage-auto.bbclass b/meta/classes/testimage-auto.bbclass
> deleted file mode 100644
> index e0a22b773c8..00000000000
> --- a/meta/classes/testimage-auto.bbclass
> +++ /dev/null
> @@ -1,23 +0,0 @@
> -# 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_image_complete
> -do_testimage_auto[depends] += "${TESTIMAGEDEPENDS}"
> -do_testimage_auto[lockfiles] += "${TESTIMAGELOCK}"
> diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
> index c17a7c604b4..1be22f63047 100644
> --- a/meta/classes/testimage.bbclass
> +++ b/meta/classes/testimage.bbclass
> @@ -10,6 +10,11 @@
>  # - first add IMAGE_CLASSES += "testimage" in local.conf
>  # - build a qemu core-image-sato
>  # - then bitbake core-image-sato -c testimage. That will run a standard suite of tests.
> +#
> +# The tests can be run automatically each time an image is built if you set
> +# TESTIMAGE_AUTO = "1"
> +
> +TESTIMAGE_AUTO ??= "0"
>
>  # You can set (or append to) TEST_SUITES in local.conf to select the tests
>  # which you want to run for your target.
> @@ -382,4 +387,7 @@ def package_extraction(d, test_suites):
>
>  testimage_main[vardepsexclude] += "BB_ORIGENV DATETIME"
>
> -inherit testsdk
> +python () {
> +    if oe.types.boolean(d.getVar("TESTIMAGE_AUTO")):
> +        bb.build.addtask("testimage", "do_build", "do_image_complete", d)
> +}
> diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass
> index 2e43343643e..f12725cbab8 100644
> --- a/meta/classes/testsdk.bbclass
> +++ b/meta/classes/testsdk.bbclass
> @@ -194,3 +194,8 @@ python do_testsdkext() {
>  addtask testsdkext
>  do_testsdkext[nostamp] = "1"
>
> +python () {
> +    if oe.types.boolean(d.getVar("TESTIMAGE_AUTO")):
> +        bb.build.addtask("testsdk", None, "do_populate_sdk", d)
> +        bb.build.addtask("testsdkext", None, "do_populate_sdk_ext", d)
> +}
> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> index 3b2ef9fb47c..c4dba61cc6b 100644
> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -487,7 +487,7 @@ HOSTTOOLS += " \
>  "
>
>  # Tools needed to run testimage runtime image testing
> -HOSTTOOLS += "${@'ip ping ps scp ssh stty' if (bb.data.inherits_class('testimage', d) or d.getVar('TEST_IMAGE') == '1') else ''}"
> +HOSTTOOLS += "${@'ip ping ps scp ssh stty' if (bb.utils.contains_any('IMAGE_CLASSES', 'testimage testsdk', True, False, d)) else ''}"
>
>  # Link to these if present
>  HOSTTOOLS_NONFATAL += "aws ccache gcc-ar gpg ld.bfd ld.gold nc sftp socat ssh sudo"
> diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
> index 3189dd39b72..fc6d008807b 100644
> --- a/meta/conf/documentation.conf
> +++ b/meta/conf/documentation.conf
> @@ -415,7 +415,7 @@ TARGET_PREFIX[doc] = "The prefix for the cross-compile toolchain (e.g. arm-linux
>  TARGET_SYS[doc] = "The target system is comprised of TARGET_ARCH,TARGET_VENDOR and TARGET_OS."
>  TCLIBC[doc] = "Specifies C library (libc) variant to use during the build process. You can select 'baremetal', 'glibc' or 'musl'."
>  TCMODE[doc] = "Enables an external toolchain (where provided by an additional layer) if set to a value other than 'default'."
> -TEST_IMAGE[doc] = "Enables test booting of virtual machine images under the QEMU emulator after any root filesystems are created and runs tests against those images."
> +TESTIMAGE_AUTO[doc] = "Enables test booting of virtual machine images under the QEMU emulator after any root filesystems are created and runs tests against those images each time an image is built."
>  TEST_QEMUBOOT_TIMEOUT[doc] = "The time in seconds allowed for an image to boot before automated runtime tests begin to run against an image."
>  TEST_SUITES[doc] = "An ordered list of tests (modules) to run against an image when performing automated runtime testing."
>  TEST_POWERCONTROL_CMD[doc] = "For automated hardware testing, specifies the command to use to control the power of the target machine under test"
> diff --git a/meta/conf/local.conf.sample b/meta/conf/local.conf.sample
> index 17cdd7046e5..1ac4156b903 100644
> --- a/meta/conf/local.conf.sample
> +++ b/meta/conf/local.conf.sample
> @@ -135,10 +135,12 @@ USER_CLASSES ?= "buildstats image-mklibs image-prelink"
>  # Runtime testing of images
>  #
>  # The build system can test booting virtual machine images under qemu (an emulator)
> -# after any root filesystems are created and run tests against those images. To
> -# enable this uncomment this line. See classes/testimage(-auto).bbclass for
> -# further details.
> -#TEST_IMAGE = "1"
> +# after any root filesystems are created and run tests against those images. It can also
> +# run tests against any SDK that are built. To enable this uncomment these lines.
> +# See classes/test{image,sdk}.bbclass for further details.
> +#IMAGE_CLASSES += "testimage testsdk"
> +#TESTIMAGE_AUTO_qemuall = "1"
> +
>  #
>  # Interactive shell configuration
>  #
> --
> 2.17.1
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] image/testimage: Rework auto image test execution
  2018-06-19 13:06   ` Paulo Neves
@ 2018-06-19 13:13     ` Alexander Kanavin
  2018-06-19 13:32       ` Paulo Neves
  2018-06-19 13:19     ` Richard Purdie
  1 sibling, 1 reply; 10+ messages in thread
From: Alexander Kanavin @ 2018-06-19 13:13 UTC (permalink / raw)
  To: Paulo Neves; +Cc: OE-core

2018-06-19 16:06 GMT+03:00 Paulo Neves <ptsneves@gmail.com>:
> I support this patch and I see that one of the problems in sumo is
> fixed, namely the HOSTTOOLS missing ip and ping.
> Even so there is one HOSTTOOLS that is missing, ifconfig. As far as I
> know the automatic network setup scripts of runqemu require ifconfig
> for 192.168.7.1 tap setting. Without ifconfig the virtual machine
> cannot be spawned.
>
> Also, given the lack of the HOSTTOOLS in the sumo version i have, how
> is this being tested?
>
> I also would like to discuss the possibility of testing u-boot in a
> virtual machine. I have a setup where I am able to pass to qemu,
> u-boot.bin as a bios file, and then I am able to boot from tftp
> enabled qemu network device. This allows for unification of test setup
> of virtualized and real target booting. Do you have any integration
> like this in the plans?

Paulo, I would recommend that you prepare the patches for all of these
things, and send them. Yocto is what you make it, don't expect things
to get fixed for you by other people.

Alex


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] image/testimage: Rework auto image test execution
  2018-06-19 13:06   ` Paulo Neves
  2018-06-19 13:13     ` Alexander Kanavin
@ 2018-06-19 13:19     ` Richard Purdie
  1 sibling, 0 replies; 10+ messages in thread
From: Richard Purdie @ 2018-06-19 13:19 UTC (permalink / raw)
  To: Paulo Neves; +Cc: OE-core

On Tue, 2018-06-19 at 15:06 +0200, Paulo Neves wrote:
> I also would like to discuss the possibility of testing u-boot in a
> virtual machine. I have a setup where I am able to pass to qemu,
> u-boot.bin as a bios file, and then I am able to boot from tftp
> enabled qemu network device. This allows for unification of test
> setup
> of virtualized and real target booting. Do you have any integration
> like this in the plans?

We'd take patches expanding something like the qemuarm machine to do
this assuming the testing costs aren't too high resource wise.

Cheers,

Richard


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] image/testimage: Rework auto image test execution
  2018-06-19 13:13     ` Alexander Kanavin
@ 2018-06-19 13:32       ` Paulo Neves
  0 siblings, 0 replies; 10+ messages in thread
From: Paulo Neves @ 2018-06-19 13:32 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: OE-core

I can, but some of the patches i sent earlier did not have comments.
Maybe I sent them to the wrong place. Furthermore I sometimes have the
feeling that I may have fixed something which, was not in need of
fixing, meaning wrong assumptions on my part.

This HOSTTOOLS case was a case in point: If a stable version (SUMO)
was released like that, I thought it was me who was doing something
wrong, so I added the ip, ping and ifconfing in my layer.conf and
"fixed" it for my case.

I will try to be more active. I am working on a class for the meson
recipes that appends the exe_wrapper of the .cross file to
qemu-${TARGET_ARCH} so that we can run unittests in the build time.
The idea is to left shift and fail the recipe build if tests fail.


Paulo Neves

On Tue, Jun 19, 2018 at 3:13 PM, Alexander Kanavin
<alex.kanavin@gmail.com> wrote:
> 2018-06-19 16:06 GMT+03:00 Paulo Neves <ptsneves@gmail.com>:
>> I support this patch and I see that one of the problems in sumo is
>> fixed, namely the HOSTTOOLS missing ip and ping.
>> Even so there is one HOSTTOOLS that is missing, ifconfig. As far as I
>> know the automatic network setup scripts of runqemu require ifconfig
>> for 192.168.7.1 tap setting. Without ifconfig the virtual machine
>> cannot be spawned.
>>
>> Also, given the lack of the HOSTTOOLS in the sumo version i have, how
>> is this being tested?
>>
>> I also would like to discuss the possibility of testing u-boot in a
>> virtual machine. I have a setup where I am able to pass to qemu,
>> u-boot.bin as a bios file, and then I am able to boot from tftp
>> enabled qemu network device. This allows for unification of test setup
>> of virtualized and real target booting. Do you have any integration
>> like this in the plans?
>
> Paulo, I would recommend that you prepare the patches for all of these
> things, and send them. Yocto is what you make it, don't expect things
> to get fixed for you by other people.
>
> Alex


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] image/testimage: Rework auto image test execution
  2018-06-19 11:45 ` [PATCH 3/3] image/testimage: Rework auto image test execution Richard Purdie
  2018-06-19 13:06   ` Paulo Neves
@ 2018-06-20  0:47   ` ChenQi
  2018-06-20  9:54     ` Richard Purdie
  1 sibling, 1 reply; 10+ messages in thread
From: ChenQi @ 2018-06-20  0:47 UTC (permalink / raw)
  To: openembedded-core


> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -487,7 +487,7 @@ HOSTTOOLS += " \
>   "
>   
>   # Tools needed to run testimage runtime image testing
> -HOSTTOOLS += "${@'ip ping ps scp ssh stty' if (bb.data.inherits_class('testimage', d) or d.getVar('TEST_IMAGE') == '1') else ''}"
> +HOSTTOOLS += "${@'ip ping ps scp ssh stty' if (bb.utils.contains_any('IMAGE_CLASSES', 'testimage testsdk', True, False, d)) else ''}"
>   

Hi Richard,

After this change, testimage and testsdk is limited to be used via 
IMAGE_CLASSES. Using INHERIT directly will cause commands missing when 
testing.
e.g.
INHERIT += "testimage"

Is it designed to be so?

Best Regards,
Chen Qi


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] image/testimage: Rework auto image test execution
  2018-06-20  0:47   ` ChenQi
@ 2018-06-20  9:54     ` Richard Purdie
  2018-06-21  5:34       ` ChenQi
  0 siblings, 1 reply; 10+ messages in thread
From: Richard Purdie @ 2018-06-20  9:54 UTC (permalink / raw)
  To: ChenQi, openembedded-core

On Wed, 2018-06-20 at 08:47 +0800, ChenQi wrote:
> > --- a/meta/conf/bitbake.conf
> > +++ b/meta/conf/bitbake.conf
> > @@ -487,7 +487,7 @@ HOSTTOOLS += " \
> >   "
> >   
> >   # Tools needed to run testimage runtime image testing
> > -HOSTTOOLS += "${@'ip ping ps scp ssh stty' if
> > (bb.data.inherits_class('testimage', d) or d.getVar('TEST_IMAGE')
> > == '1') else ''}"
> > +HOSTTOOLS += "${@'ip ping ps scp ssh stty' if
> > (bb.utils.contains_any('IMAGE_CLASSES', 'testimage testsdk', True,
> > False, d)) else ''}"
>
> After this change, testimage and testsdk is limited to be used via 
> IMAGE_CLASSES. Using INHERIT directly will cause commands missing
> when testing.
> e.g.
> INHERIT += "testimage"
> 
> Is it designed to be so?

Using INHERIT += "testimage" is bad form since it adds the testimage
task to things that it makes no sense with. Consider "bitbake bash -c
testimage" for example.

So yes, it was designed to do this, unfortunately it breaks the
autobuilder though.

I will likely want to fix the autobuilder not to do this and use the
new test code. We're about to change a lot of the autobuilder codebase
around to the new one so it probably makes sense to make that change
after we move to the new codebase.

For that reason I'll probably temporarily fix INHERIT of testimage to
work again but going forward, that support will be removed as it
doesn't make sense and IMAGE_CLASSES is the correct way to do it.

Does that make sense?

Cheers,

Richard





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] image/testimage: Rework auto image test execution
  2018-06-20  9:54     ` Richard Purdie
@ 2018-06-21  5:34       ` ChenQi
  0 siblings, 0 replies; 10+ messages in thread
From: ChenQi @ 2018-06-21  5:34 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core

On 06/20/2018 05:54 PM, Richard Purdie wrote:
> On Wed, 2018-06-20 at 08:47 +0800, ChenQi wrote:
>>> --- a/meta/conf/bitbake.conf
>>> +++ b/meta/conf/bitbake.conf
>>> @@ -487,7 +487,7 @@ HOSTTOOLS += " \
>>>    "
>>>    
>>>    # Tools needed to run testimage runtime image testing
>>> -HOSTTOOLS += "${@'ip ping ps scp ssh stty' if
>>> (bb.data.inherits_class('testimage', d) or d.getVar('TEST_IMAGE')
>>> == '1') else ''}"
>>> +HOSTTOOLS += "${@'ip ping ps scp ssh stty' if
>>> (bb.utils.contains_any('IMAGE_CLASSES', 'testimage testsdk', True,
>>> False, d)) else ''}"
>> After this change, testimage and testsdk is limited to be used via
>> IMAGE_CLASSES. Using INHERIT directly will cause commands missing
>> when testing.
>> e.g.
>> INHERIT += "testimage"
>>
>> Is it designed to be so?
> Using INHERIT += "testimage" is bad form since it adds the testimage
> task to things that it makes no sense with. Consider "bitbake bash -c
> testimage" for example.
>
> So yes, it was designed to do this, unfortunately it breaks the
> autobuilder though.
>
> I will likely want to fix the autobuilder not to do this and use the
> new test code. We're about to change a lot of the autobuilder codebase
> around to the new one so it probably makes sense to make that change
> after we move to the new codebase.
>
> For that reason I'll probably temporarily fix INHERIT of testimage to
> work again but going forward, that support will be removed as it
> doesn't make sense and IMAGE_CLASSES is the correct way to do it.
>
> Does that make sense?
>
> Cheers,
>
> Richard
>
>
>
>
Yes. Thanks for explaining this in detail.

Best Regards,
Chen Qi


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-06-21  5:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-19 11:45 [PATCH 1/3] image: Combine all the class handling code into a single section Richard Purdie
2018-06-19 11:45 ` [PATCH 2/3] image/image-live: Improve handling of live/iso/hddimg types (drop NOISO/NOHDD) Richard Purdie
2018-06-19 11:45 ` [PATCH 3/3] image/testimage: Rework auto image test execution Richard Purdie
2018-06-19 13:06   ` Paulo Neves
2018-06-19 13:13     ` Alexander Kanavin
2018-06-19 13:32       ` Paulo Neves
2018-06-19 13:19     ` Richard Purdie
2018-06-20  0:47   ` ChenQi
2018-06-20  9:54     ` Richard Purdie
2018-06-21  5:34       ` ChenQi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.