YB #6375 #6254
v2 cover YB #6375 #6254
This series of patches affects the automated runtime tests and introduces the following changes/features:
YB #6375: Add support for more rootfs compression formats
- The target controller dynamically determines what IMAGE_FSTYPES to use based on the value of supported_image_fstypes that each target controller defines or inherits. This is needed for:
* givint the targer controllers the possibility to choose an image fstype that is actually built instead of relying on a hard-coded value
* enable external scripts to predict the name of the rootfs file.
- Added bzip2 to the core-image-testmaster that decompresses the test roofs files. This is needed ATM for BSPs like beaglebone and edgeruter.
YB #6254: Set up automated testing of autobuilder images on real hardware
We need a script that fetches images from a remote http server(for now) and uses them to conduct runtime tests. For this we needed:
- to be able to import and use the testargetloader.py module to find the target controller beying used
- create and access classmethods from the target controllers that would give information about the images needed for download (like rootfs type and extra files)
- unify the kernel file naming scheme used throughout testimage(qemu use bzImage-qemux86.bin and the others use just bzImage for example).
- a script that could use the above, run the runtime tests and return the results
NOTE: This script relies on the merge of "[PATCH] oeqa/utils/commands.py: add support for postconfig option" allready on the mailing list.
*** BLURB HERE ***
Corneliu Stoicescu (7):
targetcontrol.py: make possible dynamical determination of rootfs type masterimage.py: enable dynamical determination of rootfs type core-image-testmaster.bb: add bzip2 to image targetcontrol.py: Add a classmethod to get extra files needed by the
target controllers
oeqa/controllers/testtargetloader.py: add 'import os' controllers/masterimage.py: Make testimage kernel naming pattern
universal
scripts/test-remote-image: Add script for running runtime tests on
remotely built images
meta/lib/oeqa/controllers/masterimage.py | 11 +- meta/lib/oeqa/controllers/testtargetloader.py | 1 + meta/lib/oeqa/targetcontrol.py | 23 +- .../images/core-image-testmaster.bb | 2 +- scripts/test-remote-image | 340 +++++++++++++++++++++ 5 files changed, 370 insertions(+), 7 deletions(-) create mode 100755 scripts/test-remote-image
Signature · 1 line
1.8.3.2
PATCH v2 1/7 targetcontrol.py: make possible dynamical determination of rootfs type
YB: #6375
Added a new method get_image_fstype() that autodetermines what fstype to use for the rootfs file.
This method uses a new list variable 'supported_image_fstypes' that contains image fstypes supported by the target controller.
This method is also a classmethod which means outside scripts can get the image fstype.
--- meta/lib/oeqa/targetcontrol.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
meta/lib/oeqa/targetcontrol.py +17 -2
@@ -44,6 +44,8 @@ class BaseTarget(object): __metaclass__ = ABCMeta + supported_image_fstypes = [] + def __init__(self, d): self.connection = None self.ip = None
@@ -70,6 +72,16 @@ class BaseTarget(object): def stop(self): pass + @classmethod + def get_image_fstype(self, d, image_fstypes=None): + if not image_fstypes: + image_fstypes = d.getVar('IMAGE_FSTYPES', True).split(' ') + possible_image_fstypes = [fstype for fstype in self.supported_image_fstypes if fstype in image_fstypes] + if possible_image_fstypes: + return possible_image_fstypes[0] + else: + bb.fatal("no possible image_fstype could not be determined. IMAGE_FSTYPES=\"%s\" and supported_image_fstypes=\"%s\": " % (', '.join(map(str, image_fstypes)), ', '.join(map(str, self.supported_image_fstypes)))) + def restart(self, params=None): self.stop() self.start(params)
@@ -87,13 +99,16 @@ class BaseTarget(object): class QemuTarget(BaseTarget): + supported_image_fstypes = ['ext3'] + def __init__(self, d): super(QemuTarget, self).__init__(d) + self.image_fstype = self.get_image_fstype(d) self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime) - self.origrootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + '.ext3') - self.rootfs = os.path.join(self.testdir, d.getVar("IMAGE_LINK_NAME", True) + '-testimage.ext3') + self.origrootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + '.' + self.image_fstype) + self.rootfs = os.path.join(self.testdir, d.getVar("IMAGE_LINK_NAME", True) + '-testimage.' + self.image_fstype) self.runner = QemuRunner(machine=d.getVar("MACHINE", True), rootfs=self.rootfs,
Signature · 1 line
1.8.3.2
Re: [PATCH V2 1/7] targetcontrol.py: make possible dynamical determination of rootfs type
Hi Corneliu,
Quoted 26 lines · Corneliu Stoicescu
YB: #6375
Added a new method
get_image_fstype()that autodetermines what fstype to use for the rootfs file.
This method uses a new list variable 'supported_image_fstypes' that contains image fstypes supported by the target controller.This method is also a classmethod which means outside scripts can get the image fstype.
Signed-off-by Corneliu Stoicescu <[email protected]>--- meta/lib/oeqa/targetcontrol.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)meta/lib/oeqa/targetcontrol.py +2
-0@@ -44,6 +44,8 @@ class BaseTarget(object): __metaclass__ = ABCMeta + supported_image_fstypes = [] + def __init__(self, d): self.connection = None self.ip = None
meta/lib/oeqa/targetcontrol.py class BaseTarget(object): · line 76
Quoted 5 lines
meta/lib/oeqa/targetcontrol.py +2
-0@@ -70,6 +72,16 @@ class BaseTarget(object): def stop(self): pass + @classmethod + def get_image_fstype(self, d, image_fstypes=None):
You made this a static method so you can call it from an external script? Hmm.. But then you wouldn't be able to pass d, so what's the point? Adding support for more fs is nice, but you should do that for testimage, ie make it configurable and let the use choose from local.conf (with a reasonable default). Right now you are configuring the test bits from outside...
Cheers,
Stefan
Quoted 38 lines
meta/lib/oeqa/targetcontrol.py +13
-3+ if not image_fstypes: + image_fstypes = d.getVar('IMAGE_FSTYPES', True).split(' ') + possible_image_fstypes = [fstype for fstype in self.supported_image_fstypes if fstype in image_fstypes] + if possible_image_fstypes: + return possible_image_fstypes[0] + else: + bb.fatal("no possible image_fstype could not be determined. IMAGE_FSTYPES=\"%s\" and supported_image_fstypes=\"%s\": " % (', '.join(map(str, image_fstypes)), ', '.join(map(str, self.supported_image_fstypes)))) + def restart(self, params=None): self.stop() self.start(params)@@ -87,13 +99,16 @@ class BaseTarget(object): class QemuTarget(BaseTarget): + supported_image_fstypes = ['ext3'] + def __init__(self, d): super(QemuTarget, self).__init__(d) + self.image_fstype = self.get_image_fstype(d) self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime) - self.origrootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + '.ext3') - self.rootfs = os.path.join(self.testdir, d.getVar("IMAGE_LINK_NAME", True) + '-testimage.ext3') + self.origrootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + '.' + self.image_fstype) + self.rootfs = os.path.join(self.testdir, d.getVar("IMAGE_LINK_NAME", True) + '-testimage.' + self.image_fstype) self.runner = QemuRunner(machine=d.getVar("MACHINE", True), rootfs=self.rootfs, --1.8.3.2
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Re: [PATCH V2 1/7] targetcontrol.py: make possible dynamical determination of rootfs type
Quoted 55 lines
-----Original Message-----
From: Stefan Stanacar [mailto:[email protected]]
Sent: Saturday, June 07, 2014 2:38 PM
To: Stoicescu, CorneliuX
Cc: [email protected]
Subject: Re: [OE-core] [PATCH V2 1/7]targetcontrol.py: make possible dynamical determination of rootfs typeHi Corneliu,
Quoted 3 lines · Corneliu Stoicescu
YB: #6375
Added a new method
get_image_fstype()that autodetermines what fstypeto use for the rootfs file.
Quoted 1 line
This method uses a new list variable '
supported_image_fstypes' thatcontains image fstypes supported by the target controller.
Quoted 2 lines
This method is also a classmethod which means outside scripts can get the
image fstype.
Quoted 20 lines
Signed-off-by Corneliu Stoicescu <[email protected]>--- meta/lib/oeqa/targetcontrol.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/meta/lib/oeqa/targetcontrol.pyindex ff1bb89..866c414 100644meta/lib/oeqa/targetcontrol.py +2
-0@@ -44,6 +44,8 @@ class BaseTarget(object): __metaclass__ = ABCMeta + supported_image_fstypes = [] + def __init__(self, d): self.connection = None self.ip = Nonemeta/lib/oeqa/targetcontrol.py class BaseTarget(object): · line 76
Quoted 5 lines
meta/lib/oeqa/targetcontrol.py +2
-0@@ -70,6 +72,16 @@ class BaseTarget(object): def stop(self): pass + @classmethod + def get_image_fstype(self, d, image_fstypes=None):You made this a static method so you can call it from an external script? Hmm.. But then you wouldn't be able to pass d, so what's the point? Adding support for more fs is nice, but you should do that for testimage, ie make it configurable and let the use choose from local.conf (with a reasonable default). Right now you are configuring the test bits from outside...
Quoted 2 lines
Cheers,
Stefan
This method can use d to get the IMAGE_FSTYPES value or it can be directly given that value and bypass d. See in the test-remote-image script how we used it.
Again, these patches are made with the possibility of using the target controllers to get as much information, both internally and externally, in mind. We try to process the information (like image fstype used) in one place and get if rom there wherever we need it. Also we would like to keep the user configurable variables to a minimum and automatically determine as much as we can(I should have included this in the cover letter). And where can we do this better than in the target controllers themselves?
I hope I this is a little more clear now.
Regards,
Corneliu
PATCH v2 2/7 masterimage.py: enable dynamical determination of rootfs type
In reply to Corneliu StoicescuYB: #6375
Adding support for get_image_fstype() in the MasterImageHardwareTarget and GummibootTarget classes.
--- meta/lib/oeqa/controllers/masterimage.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
meta/lib/oeqa/controllers/masterimage.py +6 -3
@@ -28,6 +28,8 @@ class MasterImageHardwareTarget(oeqa.targetcontrol.BaseTarget): __metaclass__ = ABCMeta + supported_image_fstypes = ['tar.gz', 'tar.bz2'] + def __init__(self, d): super(MasterImageHardwareTarget, self).__init__(d)
@@ -48,7 +50,8 @@ class MasterImageHardwareTarget(oeqa.targetcontrol.BaseTarget): bb.note("Server IP: %s" % self.server_ip) # test rootfs + kernel - self.rootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + '.tar.gz') + self.image_fstype = self.get_image_fstype(d) + self.rootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + '.' + self.image_fstype) self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("KERNEL_IMAGETYPE")) if not os.path.isfile(self.rootfs): # we could've checked that IMAGE_FSTYPES contains tar.gz but the config for running testimage might not be
@@ -177,7 +180,7 @@ class GummibootTarget(MasterImageHardwareTarget): 'mount -t efivarfs efivarfs /sys/firmware/efi/efivars', 'cp ~/test-kernel /boot', 'rm -rf /mnt/testrootfs/*', - 'tar xzvf ~/test-rootfs.tar.gz -C /mnt/testrootfs', + 'tar xvf ~/test-rootfs.%s -C /mnt/testrootfs' % self.image_fstype, 'printf "%s" > /sys/firmware/efi/efivars/LoaderEntryOneShot-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f' % self.efivarvalue ]
@@ -187,7 +190,7 @@ class GummibootTarget(MasterImageHardwareTarget): # from now on, every deploy cmd should return 0 # else an exception will be thrown by sshcontrol self.master.ignore_status = False - self.master.copy_to(self.rootfs, "~/test-rootfs.tar.gz") + self.master.copy_to(self.rootfs, "~/test-rootfs." + self.image_fstype) self.master.copy_to(self.kernel, "~/test-kernel") for cmd in self.deploy_cmds: self.master.run(cmd)
Signature · 1 line
1.8.3.2
PATCH v2 3/7 core-image-testmaster.bb: add bzip2 to image
In reply to Corneliu StoicescuYB: #6375
Some test image fstypes require bzip2 decompression.
--- meta/recipes-extended/images/core-image-testmaster.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-extended/images/core-image-testmaster.bb +1 -1
@@ -7,7 +7,7 @@ inherit core-image # the deploy code requires bash and # normal linux utilities not busybox ones IMAGE_INSTALL += "\ - bash coreutils util-linux tar gzip kmod \ + bash coreutils util-linux tar gzip bzip2 kmod \ python-modules python-misc \ e2fsprogs e2fsprogs-mke2fs parted \ "
Signature · 1 line
1.8.3.2
PATCH v2 4/7 targetcontrol.py: Add a classmethod to get extra files needed by the target controllers
In reply to Corneliu StoicescuYB: #6254
Add a new classmethod that can be used by outside scripts to get the extra files needed by the target controllers. An outside script can predict rootfs, manifest and kernel files needed by a target controller, but sometimes there are other files needed.
--- meta/lib/oeqa/targetcontrol.py | 4 ++++ 1 file changed, 4 insertions(+)
meta/lib/oeqa/targetcontrol.py +4 -0
@@ -73,6 +73,10 @@ class BaseTarget(object): pass @classmethod + def get_extra_files(self): + return None + + @classmethod def get_image_fstype(self, d, image_fstypes=None): if not image_fstypes: image_fstypes = d.getVar('IMAGE_FSTYPES', True).split(' ')
Signature · 1 line
1.8.3.2
PATCH v2 5/7 oeqa/controllers/testtargetloader.py: add 'import os'
In reply to Corneliu StoicescuYB: #6254
This module uses os but relies on other modules to import it. Adding 'import os' in order to be self-sustained.
--- meta/lib/oeqa/controllers/testtargetloader.py | 1 + 1 file changed, 1 insertion(+)
meta/lib/oeqa/controllers/testtargetloader.py +1 -0
@@ -1,5 +1,6 @@ import types import bb +import os # This class is responsible for loading a test target controller class TestTargetLoader:
Signature · 1 line
1.8.3.2
PATCH v2 6/7 controllers/masterimage.py: Make testimage kernel naming pattern universal
In reply to Corneliu StoicescuYB: #6254
The QemuTargetControl class does not specify any kernel naming but the runqemu script it uses uses the " KERNEL_IMAGETYPE + MACHINE + '.bin' " naming scheme. Modifying the other major target controller class, MasterImageHardwareTarget, to use the same kernel naming scheme.
This is usefull also to outside scripts that want to anticipate the kernel file name for all target controllers.
--- meta/lib/oeqa/controllers/masterimage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oeqa/controllers/masterimage.py +1 -1
@@ -52,7 +52,7 @@ class MasterImageHardwareTarget(oeqa.targetcontrol.BaseTarget): # test rootfs + kernel self.image_fstype = self.get_image_fstype(d) self.rootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + '.' + self.image_fstype) - self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("KERNEL_IMAGETYPE")) + self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("KERNEL_IMAGETYPE") + '-' + d.getVar('MACHINE') + '.bin') if not os.path.isfile(self.rootfs): # we could've checked that IMAGE_FSTYPES contains tar.gz but the config for running testimage might not be # the same as the config with which the image was build, ie
Signature · 1 line
1.8.3.2
Re: [PATCH V2 6/7] controllers/masterimage.py: Make testimage kernel naming pattern universal
Quoted 4 lines · Corneliu Stoicescu
YB: #6254
The QemuTargetControl class does not specify any kernel naming but the
runqemu script it uses uses the " KERNEL_IMAGETYPE + MACHINE + '.bin' " naming scheme.
Quoted 1 line
Modifying the other major target controller class,
MasterImageHardwareTarget, to use the same kernel naming scheme.
Quoted 1 line
You can't do that because not all targets (bbb, nuc, etc) use a bin kernel...
Quoted 1 line
This is usefull also to outside scripts that want to anticipate the
kernel file name for all target controllers.
And what's wrong with the link? Bitbake will always take care of that and point to the real file why can't the script dereference that?
Cheers,
Stefan
Review
Quoted 7 lines
Signed-off-by Corneliu Stoicescu <[email protected]>--- meta/lib/oeqa/controllers/masterimage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/meta/lib/oeqa/controllers/masterimage.py
meta/lib/oeqa/controllers/masterimage.py class
Quoted 4 lines
index b03c5bf..311f0cf 100644
meta/lib/oeqa/controllers/masterimage.py +0
-0@@ -52,7 +52,7 @@ class
MasterImageHardwareTarget(oeqa.targetcontrol.BaseTarget):
meta/lib/oeqa/controllers/masterimage.py class MasterImageHardwareTarget(oeqa.targetcontrol.BaseTarget):
Quoted 3 lines
meta/lib/oeqa/controllers/masterimage.py +0
-0# test rootfs + kernel self.image_fstype = self.get_image_fstype(d) self.rootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True),
d.getVar("IMAGE_LINK_NAME", True) + '.' + self.image_fstype)
meta/lib/oeqa/controllers/masterimage.py class · line 55
Quoted 1 line
meta/lib/oeqa/controllers/masterimage.py +0
-1- self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True),
d.getVar("KERNEL_IMAGETYPE"))
meta/lib/oeqa/controllers/masterimage.py class · line 55
Quoted 1 line
meta/lib/oeqa/controllers/masterimage.py +1
-0+ self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True),
d.getVar("KERNEL_IMAGETYPE") + '-' + d.getVar('MACHINE') + '.bin')
meta/lib/oeqa/controllers/masterimage.py class · line 57
Quoted 2 lines
meta/lib/oeqa/controllers/masterimage.py +0
-0if not os.path.isfile(self.rootfs): # we could've checked that IMAGE_FSTYPES contains tar.gz but
the config for running testimage might not be
Quoted 9 lines
meta/lib/oeqa/controllers/masterimage.py +0
-1# the same as the config with which the image was build, ie --1.8.3.2
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Re: [PATCH V2 6/7] controllers/masterimage.py: Make testimage kernel naming pattern universal
Quoted 13 lines · Stefan Stanacar
Quoted 9 lines · Corneliu Stoicescu
YB: #6254
The QemuTargetControl class does not specify any kernel naming but the runqemu script it uses uses the "
KERNEL_IMAGETYPE+ MACHINE + '.bin' " naming scheme.
Modifying the other major target controller class, MasterImageHardwareTarget, to use the same kernel naming scheme.
Quoted 3 lines
You can't do that because not all targets (bbb, nuc, etc) use a bin kernel...
Ah, misunderstood... right, there is .bin link too
Quoted 42 lines
Quoted 2 lines
This is usefull also to outside scripts that want to anticipate the kernel file name for all target controllers.
And what's wrong with the link? Bitbake will always take care of that and point to the real file why can't the script dereference that?
Cheers,
StefanQuoted 33 lines
Signed-off-by Corneliu Stoicescu <[email protected]>--- meta/lib/oeqa/controllers/masterimage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta/lib/oeqa/controllers/masterimage.py +0
-0@@ -52,7 +52,7 @@ classMasterImageHardwareTarget(oeqa.targetcontrol.BaseTarget):
# test rootfs + kernel self.image_fstype = self.get_image_fstype(d) self.rootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + '.' + self.image_fstype) - self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("KERNEL_IMAGETYPE")) + self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("KERNEL_IMAGETYPE") + '-' + d.getVar('MACHINE') + '.bin') if not os.path.isfile(self.rootfs): # we could've checked that IMAGE_FSTYPES contains tar.gz but the config for running testimage might not be # the same as the config with which the image was build, ie -- 1.8.3.2--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Re: [PATCH V2 6/7] controllers/masterimage.py: Make testimage kernel naming pattern universal
Quoted 26 lines
-----Original Message-----
From: Stefan Stanacar [mailto:[email protected]]
Sent: Saturday, June 07, 2014 3:39 PM
To: Stoicescu, CorneliuX
Cc: [email protected]
Subject: Re: [OE-core] [PATCH V2 6/7]controllers/masterimage.py: Make testimage kernel naming pattern universalQuoted 9 lines · Stefan Stanacar
Quoted 5 lines · Corneliu Stoicescu
YB: #6254
The QemuTargetControl class does not specify any kernel naming but the runqemu script it uses uses the "
KERNEL_IMAGETYPE+ MACHINE +'.bin' "
Quoted 5 lines
Quoted 4 lines
naming scheme.
Modifying the other major target controller class, MasterImageHardwareTarget, to use the same kernel naming scheme.
Quoted 11 lines
Quoted 3 lines
You can't do that because not all targets (bbb, nuc, etc) use a bin kernel...
Ah, misunderstood... right, there is .bin link too
Quoted 6 lines
Quoted 2 lines
This is usefull also to outside scripts that want to anticipate the kernel file name for all target controllers.
And what's wrong with the link? Bitbake will always take care of that and point to the real file why can't the script dereference that?
The link would be fine but:
- the link is not unique, there are at 2.
- the link used by testimage(without this patch) is not always the same. The script can create a link from one to the other but that is not necessary when we can have one name format for all target controllers to use. Also having the setup without links simplifies the setup of the images on the script side.
- using the current kernel name for machines that use the same KERNEL_IMAGETYPE would override the kernel of the previous machine during the same test cycle. This could introduce complications, especially if we decide in the future to create a common download directories for multiple script instances.
I believe this is not a big change but introduces some simplification setup wise. I see no advantage leaving it as is aside avoiding making changes.
Regards,
Corneliu
Quoted 38 lines
Quoted 38 lines
Cheers,
StefanQuoted 35 lines
Signed-off-by Corneliu Stoicescu <[email protected]>--- meta/lib/oeqa/controllers/masterimage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta/lib/oeqa/controllers/masterimage.py +0
-0@@ -52,7 +52,7 @@ classMasterImageHardwareTarget(oeqa.targetcontrol.BaseTarget):
# test rootfs + kernel self.image_fstype = self.get_image_fstype(d) self.rootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + '.' + self.image_fstype) - self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("KERNEL_IMAGETYPE")) + self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", + True), d.getVar("KERNEL_IMAGETYPE") + '-' + d.getVar('MACHINE') + '.bin') if not os.path.isfile(self.rootfs): # we could've checked that IMAGE_FSTYPES contains tar.gz but the config for running testimage might not be # the same as the config with which the image was build, ie -- 1.8.3.2--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
PATCH v2 7/7 scripts/test-remote-image: Add script for running runtime tests on remotely built images
In reply to Corneliu StoicescuYB: #6254
Adding a new script that will fetch image files from a remote images repository. These images will then be used for local runtime testing.
Use the '-h' option for more details on usage.
--- scripts/test-remote-image | 340 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 340 insertions(+) create mode 100755 scripts/test-remote-image
scripts/test-remote-image new file +340 -0
@@ -0,0 +1,340 @@ +#!/usr/bin/env python + +# Copyright (c) 2014 Intel Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# DESCRIPTION +# This script is used to test public autobuilder images on remote hardware. +# The script is called from a machine that is able download the images from the remote images repository and to connect to the test hardware. +# +# test-remote-image --image-type core-image-sato --repo-link http://192.168.10.2/images --required-packages rpm psplash +# +# Translation: Build the 'rpm' and 'pslash' packages and test a remote core-image-sato image using the http://192.168.10.2/images repository. +# +# You can also use the '-h' option to see some help information. + +import os +import sys +import argparse +import logging +import shutil +from abc import ABCMeta, abstractmethod + +# Add meta/lib to sys.path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'meta/lib'))) + +import oeqa.utils.ftools as ftools +from oeqa.utils.commands import runCmd, bitbake, get_bb_var + +# Add all lib paths relative to BBPATH to sys.path; this is used to find and import the target controllers. +for path in get_bb_var('BBPATH').split(":"): + sys.path.insert(0, os.path.abspath(os.path.join(path, 'lib'))) + +# In order to import modules that contain target controllers, we need the bitbake libraries in sys.path . +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'bitbake/lib'))) + +# create a logger +def logger_create(): + log = logging.getLogger('hwauto') + log.setLevel(logging.DEBUG) + + fh = logging.FileHandler(filename='hwauto.log', mode='w') + fh.setLevel(logging.DEBUG) + + ch = logging.StreamHandler(sys.stdout) + ch.setLevel(logging.INFO) + + formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') + fh.setFormatter(formatter) + ch.setFormatter(formatter) + + log.addHandler(fh) + log.addHandler(ch) + + return log + +# instantiate the logger +log = logger_create() + + +# Define and return the arguments parser for the script +def get_args_parser(): + description = "This script is used to run automated runtime tests using remotely published image files. You should prepare the build environment just like building local images and running the tests." + parser = argparse.ArgumentParser(description=description) + parser.add_argument('--image-types', required=True, action="store", nargs='*', dest="image_types", default=None, help='The image types to test(ex: core-image-minimal).') + parser.add_argument('--repo-link', required=True, action="store", type=str, dest="repo_link", default=None, help='The link to the remote images repository.') + parser.add_argument('--required-packages', required=False, action="store", nargs='*', dest="required_packages", default=None, help='Required packages for the tests. They will be built before the testing begins.') + parser.add_argument('--targetprofile', required=False, action="store", nargs=1, dest="targetprofile", default='AutoTargetProfile', help='The target profile to be used.') + parser.add_argument('--repoprofile', required=False, action="store", nargs=1, dest="repoprofile", default='PublicAB', help='The repo profile to be used.') + return parser + +class BaseTargetProfile(object): + """ + This class defines the meta profile for a specific target (MACHINE type + image type). + """ + + __metaclass__ = ABCMeta + + def __init__(self, image_type): + self.image_type = image_type + + self.kernel_file = None + self.rootfs_file = None + self.manifest_file = None + self.extra_download_files = [] # Extra files (full name) to be downloaded. They should be situated in repo_link + + # This method is used as the standard interface with the target profile classes. + # It returns a dictionary containing a list of files and their meaning/description. + def get_files_dict(self): + files_dict = {} + + if self.kernel_file: + files_dict['kernel_file'] = self.kernel_file + else: + log.error('The target profile did not set a kernel file.') + sys.exit(1) + + if self.rootfs_file: + files_dict['rootfs_file'] = self.rootfs_file + else: + log.error('The target profile did not set a rootfs file.') + sys.exit(1) + + if self.manifest_file: + files_dict['manifest_file'] = self.manifest_file + else: + log.error('The target profile did not set a manifest file.') + sys.exit(1) + + for idx, f in enumerate(self.extra_download_files): + files_dict['extra_download_file' + str(idx)] = f + + return files_dict + +class AutoTargetProfile(BaseTargetProfile): + + def __init__(self, image_type): + super(AutoTargetProfile, self).__init__(image_type) + self.image_name = get_bb_var('IMAGE_LINK_NAME', target=image_type) + self.kernel_type = get_bb_var('KERNEL_IMAGETYPE', target=image_type) + self.controller = self.get_controller() + + self.set_kernel_file() + self.set_rootfs_file() + self.set_manifest_file() + self.set_extra_download_files() + + + def get_controller(self): + from oeqa.controllers.testtargetloader import TestTargetLoader + + target_controller = get_bb_var('TEST_TARGET') + bbpath = get_bb_var('BBPATH').split(':') + + if target_controller == "qemu": + from oeqa.targetcontrol import QemuTarget + controller = QemuTarget + else: + testtargetloader = TestTargetLoader() + controller = testtargetloader.get_controller_module(target_controller, bbpath) + return controller + + def set_kernel_file(self): + postconfig = "QA_GET_MACHINE = \"${MACHINE}\"" + machine = get_bb_var('QA_GET_MACHINE', postconfig=postconfig) + self.kernel_file = self.kernel_type + '-' + machine + '.bin' + + def set_rootfs_file(self): + image_fstypes = get_bb_var('IMAGE_FSTYPES').split(' ') + fstype = self.controller.get_image_fstype(d=None, image_fstypes=image_fstypes) + self.rootfs_file = self.image_name + '.' + fstype + + def set_manifest_file(self): + self.manifest_file = self.image_name + ".manifest" + + def set_extra_download_files(self): + self.extra_download_files = self.get_controller_extra_files() + if not self.extra_download_files: + self.extra_download_files = [] + + def get_controller_extra_files(self): + controller = self.get_controller() + return controller.get_extra_files() + + +class BaseRepoProfile(object): + """ + This class defines the meta profile for an images repository. + """ + + __metaclass__ = ABCMeta + + def __init__(self, repolink, localdir): + self.localdir = localdir + self.repolink = repolink + + # The following abstract methods are the interfaces to the repository profile classes derived from this abstract class. + + # This method should check the file named 'file_name' if it is different than the upstream one. + # Should return False if the image is the same as the upstream and True if it differs. + @abstractmethod + def check_old_file(self, file_name): + pass + + # This method should fetch file_name and create a symlink to localname if set. + @abstractmethod + def fetch(self, file_name, localname=None): + pass + +class PublicAB(BaseRepoProfile): + + def __init__(self, repolink, localdir=None): + super(PublicAB, self).__init__(repolink, localdir) + if localdir is None: + self.localdir = os.path.join(os.environ['BUILDDIR'], 'PublicABMirror') + + # Not yet implemented. Always returning True. + def check_old_file(self, file_name): + return True + + def get_repo_path(self): + path = '/machines/' + + postconfig = "QA_GET_MACHINE = \"${MACHINE}\"" + machine = get_bb_var('QA_GET_MACHINE', postconfig=postconfig) + if 'qemu' in machine: + path += 'qemu/' + + postconfig = "QA_GET_DISTRO = \"${DISTRO}\"" + distro = get_bb_var('QA_GET_DISTRO', postconfig=postconfig) + path += distro.replace('poky', machine) + '/' + return path + + + def fetch(self, file_name, localname=None): + repo_path = self.get_repo_path() + link = self.repolink + repo_path + file_name + + self.wget(link, self.localdir, localname) + + def wget(self, link, localdir, localname=None, extraargs=None): + wget_cmd = '/usr/bin/env wget -t 2 -T 30 -nv --passive-ftp --no-check-certificate ' + + if localname: + wget_cmd += ' -O ' + localname + ' ' + + if extraargs: + wget_cmd += ' ' + extraargs + ' ' + + wget_cmd += " -P %s '%s'" % (localdir, link) + runCmd(wget_cmd) + +class HwAuto(): + + def __init__(self, image_types, repolink, required_packages, targetprofile, repoprofile): + log.info('Initializing..') + self.image_types = image_types + self.repolink = repolink + self.required_packages = required_packages + self.targetprofile = targetprofile + self.repoprofile = repoprofile + self.repo = self.get_repo_profile(self.repolink) + + # Get the repository profile; for now we only look inside this module. + def get_repo_profile(self, *args, **kwargs): + repo = getattr(sys.modules[__name__], self.repoprofile)(*args, **kwargs) + log.info("Using repo profile: %s" % repo.__class__.__name__) + return repo + + # Get the target profile; for now we only look inside this module. + def get_target_profile(self, *args, **kwargs): + target = getattr(sys.modules[__name__], self.targetprofile)(*args, **kwargs) + log.info("Using target profile: %s" % target.__class__.__name__) + return target + + # Run the testimage task on a build while redirecting DEPLOY_DIR_IMAGE to repo.localdir, where the images are downloaded. + def runTestimageBuild(self, image_type): + log.info("Running the runtime tests for %s.." % image_type) + postconfig = "DEPLOY_DIR_IMAGE = \"%s\"" % self.repo.localdir + result = bitbake("%s -c testimage" % image_type, ignore_status=True, postconfig=postconfig) + testimage_results = ftools.read_file(os.path.join(get_bb_var("T", image_type), "log.do_testimage")) + log.info('Runtime tests results for %s:' % image_type) + print testimage_results + return result + + # Start the procedure! + def run(self): + if self.required_packages: + # Build the required packages for the tests + log.info("Building the required packages: %s ." % ', '.join(map(str, self.required_packages))) + result = bitbake(self.required_packages, ignore_status=True) + if result.status != 0: + log.error("Could not build required packages: %s. Output: %s" % (self.required_packages, result.output)) + sys.exit(1) + + # Build the package repository meta data. + log.info("Building the package index.") + result = bitbake("package-index", ignore_status=True) + if result.status != 0: + log.error("Could not build 'package-index'. Output: %s" % result.output) + sys.exit(1) + + # Create the directory structure for the images to be downloaded + log.info("Creating directory structure %s" % self.repo.localdir) + if not os.path.exists(self.repo.localdir): + os.makedirs(self.repo.localdir) + + # For each image type, download the needed files and run the tests. + noissuesfound = True + for image_type in self.image_types: + target = self.get_target_profile(image_type) + files_dict = target.get_files_dict() + log.info("Downloading files for %s" % image_type) + for f in files_dict: + if self.repo.check_old_file(files_dict[f]): + filepath = os.path.join(self.repo.localdir, files_dict[f]) + if os.path.exists(filepath): + os.remove(filepath) + self.repo.fetch(files_dict[f]) + + result = self.runTestimageBuild(image_type) + if result.status != 0: + noissuesfound = False + + if noissuesfound: + log.info('Finished. No issues found.') + else: + log.error('Finished. Some runtime tests have failed. Returning non-0 status code.') + sys.exit(1) + + + +def main(): + + parser = get_args_parser() + args = parser.parse_args() + + hwauto = HwAuto(image_types=args.image_types, repolink=args.repo_link, required_packages=args.required_packages, targetprofile=args.targetprofile, repoprofile=args.repoprofile) + + hwauto.run() + +if __name__ == "__main__": + try: + ret = main() + except Exception: + ret = 1 + import traceback + traceback.print_exc(5) + sys.exit(ret)
Signature · 1 line
1.8.3.2
Re: [PATCH V2 7/7] scripts/test-remote-image: Add script for running runtime tests on remotely built images
Hi Corneliu,
I haven't carefully reviewed this series so if I didn't quite got the point of some things, sorry...
At a first look, here are my thoughts (this is actually a reply to the entire series, I seem to have lost the cover letter):
- It seems wierd that you instantiate the target controllers classes here... You do that so you can get the extra files, but that has nothing to do with testimage anyway. Let bitbake/testimage do it's part and it's configuration. Similar for image fs types (see my other reply)
- I wouldn't mix the download stuff with the test/deploy stuff (bitbake's job). You already have command line configuration knobs, I'm sure you could add one for extra files... Surely the user know it's testing BBB and core-image-minimal and it needs to download the dtbs (because you need the dtbs only for minimal).
- the support for other fs types should be separate from the "test external built image". E.g bbb uses tar.bz2, so even at this point you can still test external images only with tar.gz (adding IMAGE_FSTYPES += "tar.gz" to the Autobuilder config is a easy task). What I'm trying to say is that this is a user/build config option and this script shouldn't deal with every little thing
- What's with the postconfig stuff? QA_MACHINE = MACHINE? Same for distro.. I really don't get that part...
- I'm missing the bigger picture here with all the profiles stuff (plus some classes are unnecessarily abstract ).
So the whole point of this was to replace (assume default local.conf and MACHINE="beaglebone" here)
this:
---
$ vi conf/local.conf INHERIT += "testimage" TEST_TARGET_IP = "10.11.12.2" TEST_TARGET = "BeagleBoneTarget" TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200" $ bitbake core-image-minimal # (or sato / sato-sdk) $ bitbake <image> -c testimage --- with this (except the local.conf part which should already be there, it is not the job of this script to add that): ---- $ bitbake rpm psplash # rpm/smart tests require these, else skip $ bitbake package-index $ wget -r -l0 -nd -np -P "tmp/deploy/images" http://autobuilder.yoctoproject.org/pub/nightly/20140606-3/machines/beaglebone/ $ bitbake <image> -c testimage --- #yes, I cheated there, getting all the files, but you get the point.. alternatively: wget -r -l0 -nd -np -P "tmp/deploy/images" -A "*boneblack*.dtb" http://autobuilder.yoctoproject.org/pub/nightly/20140606-3/machines/beaglebone/ wget -P "tmp/deploy/images" http://autobuilder.yoctoproject.org/pub/nightly/20140606-3/machines/beaglebone/core-image-minimal-beaglebone.manifest wget -P "tmp/deploy/images" http://autobuilder.yoctoproject.org/pub/nightly/20140606-3/machines/beaglebone/core-image-minimal-beaglebone.tar.gz wget -P "tmp/deploy/images" http://autobuilder.yoctoproject.org/pub/nightly/20140606-3/machines/beaglebone/uImage
It seems to me that you are doing a lot more with this series and adding unnecessary complications. I guess I'm missing some pieces here...
Cheers,
Stefan
Quoted 367 lines · Corneliu Stoicescu
YB: #6254
Adding a new script that will fetch image files from a remote images repository. These images will then be used for local runtime testing.
Use the '-h' option for more details on usage.
Signed-off-by Corneliu Stoicescu <[email protected]>--- scripts/test-remote-image | 340 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 340 insertions(+) create mode 100755 scripts/test-remote-imagescripts/test-remote-image new file +340
-1@@ -0,0 +1,340 @@ +#!/usr/bin/env python + +# Copyright (c) 2014 Intel Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# DESCRIPTION +# This script is used to test public autobuilder images on remote hardware. +# The script is called from a machine that is able download the images from the remote images repository and to connect to the test hardware. +# +# test-remote-image --image-type core-image-sato --repo-link http://192.168.10.2/images --required-packages rpm psplash +# +# Translation: Build the 'rpm' and 'pslash' packages and test a remote core-image-sato image using the http://192.168.10.2/images repository. +# +# You can also use the '-h' option to see some help information. + +import os +import sys +import argparse +import logging +import shutil +from abc import ABCMeta, abstractmethod + +# Add meta/lib to sys.path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'meta/lib'))) + +import oeqa.utils.ftools as ftools +from oeqa.utils.commands import runCmd, bitbake, get_bb_var + +# Add all lib paths relative to BBPATH to sys.path; this is used to find and import the target controllers. +for path in get_bb_var('BBPATH').split(":"): + sys.path.insert(0, os.path.abspath(os.path.join(path, 'lib'))) + +# In order to import modules that contain target controllers, we need the bitbake libraries in sys.path . +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'bitbake/lib'))) + +# create a logger +def logger_create(): + log = logging.getLogger('hwauto') + log.setLevel(logging.DEBUG) + + fh = logging.FileHandler(filename='hwauto.log', mode='w') + fh.setLevel(logging.DEBUG) + + ch = logging.StreamHandler(sys.stdout) + ch.setLevel(logging.INFO) + + formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') + fh.setFormatter(formatter) + ch.setFormatter(formatter) + + log.addHandler(fh) + log.addHandler(ch) + + return log + +# instantiate the logger +log = logger_create() + + +# Define and return the arguments parser for the script +def get_args_parser(): + description = "This script is used to run automated runtime tests using remotely published image files. You should prepare the build environment just like building local images and running the tests." + parser = argparse.ArgumentParser(description=description) + parser.add_argument('--image-types', required=True, action="store", nargs='*', dest="image_types", default=None, help='The image types to test(ex: core-image-minimal).') + parser.add_argument('--repo-link', required=True, action="store", type=str, dest="repo_link", default=None, help='The link to the remote images repository.') + parser.add_argument('--required-packages', required=False, action="store", nargs='*', dest="required_packages", default=None, help='Required packages for the tests. They will be built before the testing begins.') + parser.add_argument('--targetprofile', required=False, action="store", nargs=1, dest="targetprofile", default='AutoTargetProfile', help='The target profile to be used.') + parser.add_argument('--repoprofile', required=False, action="store", nargs=1, dest="repoprofile", default='PublicAB', help='The repo profile to be used.') + return parser + +class BaseTargetProfile(object): + """ + This class defines the meta profile for a specific target (MACHINE type + image type). + """ + + __metaclass__ = ABCMeta + + def __init__(self, image_type): + self.image_type = image_type + + self.kernel_file = None + self.rootfs_file = None + self.manifest_file = None + self.extra_download_files = [] # Extra files (full name) to be downloaded. They should be situated in repo_link + + # This method is used as the standard interface with the target profile classes. + # It returns a dictionary containing a list of files and their meaning/description. + def get_files_dict(self): + files_dict = {} + + if self.kernel_file: + files_dict['kernel_file'] = self.kernel_file + else: + log.error('The target profile did not set a kernel file.') + sys.exit(1) + + if self.rootfs_file: + files_dict['rootfs_file'] = self.rootfs_file + else: + log.error('The target profile did not set a rootfs file.') + sys.exit(1) + + if self.manifest_file: + files_dict['manifest_file'] = self.manifest_file + else: + log.error('The target profile did not set a manifest file.') + sys.exit(1) + + for idx, f in enumerate(self.extra_download_files): + files_dict['extra_download_file' + str(idx)] = f + + return files_dict + +class AutoTargetProfile(BaseTargetProfile): + + def __init__(self, image_type): + super(AutoTargetProfile, self).__init__(image_type) + self.image_name = get_bb_var('IMAGE_LINK_NAME', target=image_type) + self.kernel_type = get_bb_var('KERNEL_IMAGETYPE', target=image_type) + self.controller = self.get_controller() + + self.set_kernel_file() + self.set_rootfs_file() + self.set_manifest_file() + self.set_extra_download_files() + + + def get_controller(self): + from oeqa.controllers.testtargetloader import TestTargetLoader + + target_controller = get_bb_var('TEST_TARGET') + bbpath = get_bb_var('BBPATH').split(':') + + if target_controller == "qemu": + from oeqa.targetcontrol import QemuTarget + controller = QemuTarget + else: + testtargetloader = TestTargetLoader() + controller = testtargetloader.get_controller_module(target_controller, bbpath) + return controller + + def set_kernel_file(self): + postconfig = "QA_GET_MACHINE = \"${MACHINE}\"" + machine = get_bb_var('QA_GET_MACHINE', postconfig=postconfig) + self.kernel_file = self.kernel_type + '-' + machine + '.bin' + + def set_rootfs_file(self): + image_fstypes = get_bb_var('IMAGE_FSTYPES').split(' ') + fstype = self.controller.get_image_fstype(d=None, image_fstypes=image_fstypes) + self.rootfs_file = self.image_name + '.' + fstype + + def set_manifest_file(self): + self.manifest_file = self.image_name + ".manifest" + + def set_extra_download_files(self): + self.extra_download_files = self.get_controller_extra_files() + if not self.extra_download_files: + self.extra_download_files = [] + + def get_controller_extra_files(self): + controller = self.get_controller() + return controller.get_extra_files() + + +class BaseRepoProfile(object): + """ + This class defines the meta profile for an images repository. + """ + + __metaclass__ = ABCMeta + + def __init__(self, repolink, localdir): + self.localdir = localdir + self.repolink = repolink + + # The following abstract methods are the interfaces to the repository profile classes derived from this abstract class. + + # This method should check the file named 'file_name' if it is different than the upstream one. + # Should return False if the image is the same as the upstream and True if it differs. + @abstractmethod + def check_old_file(self, file_name): + pass + + # This method should fetch file_name and create a symlink to localname if set. + @abstractmethod + def fetch(self, file_name, localname=None): + pass + +class PublicAB(BaseRepoProfile): + + def __init__(self, repolink, localdir=None): + super(PublicAB, self).__init__(repolink, localdir) + if localdir is None: + self.localdir = os.path.join(os.environ['BUILDDIR'], 'PublicABMirror') + + # Not yet implemented. Always returning True. + def check_old_file(self, file_name): + return True + + def get_repo_path(self): + path = '/machines/' + + postconfig = "QA_GET_MACHINE = \"${MACHINE}\"" + machine = get_bb_var('QA_GET_MACHINE', postconfig=postconfig) + if 'qemu' in machine: + path += 'qemu/' + + postconfig = "QA_GET_DISTRO = \"${DISTRO}\"" + distro = get_bb_var('QA_GET_DISTRO', postconfig=postconfig) + path += distro.replace('poky', machine) + '/' + return path + + + def fetch(self, file_name, localname=None): + repo_path = self.get_repo_path() + link = self.repolink + repo_path + file_name + + self.wget(link, self.localdir, localname) + + def wget(self, link, localdir, localname=None, extraargs=None): + wget_cmd = '/usr/bin/env wget -t 2 -T 30 -nv --passive-ftp --no-check-certificate ' + + if localname: + wget_cmd += ' -O ' + localname + ' ' + + if extraargs: + wget_cmd += ' ' + extraargs + ' ' + + wget_cmd += " -P %s '%s'" % (localdir, link) + runCmd(wget_cmd) + +class HwAuto(): + + def __init__(self, image_types, repolink, required_packages, targetprofile, repoprofile): + log.info('Initializing..') + self.image_types = image_types + self.repolink = repolink + self.required_packages = required_packages + self.targetprofile = targetprofile + self.repoprofile = repoprofile + self.repo = self.get_repo_profile(self.repolink) + + # Get the repository profile; for now we only look inside this module. + def get_repo_profile(self, *args, **kwargs): + repo = getattr(sys.modules[__name__], self.repoprofile)(*args, **kwargs) + log.info("Using repo profile: %s" % repo.__class__.__name__) + return repo + + # Get the target profile; for now we only look inside this module. + def get_target_profile(self, *args, **kwargs): + target = getattr(sys.modules[__name__], self.targetprofile)(*args, **kwargs) + log.info("Using target profile: %s" % target.__class__.__name__) + return target + + # Run the testimage task on a build while redirecting DEPLOY_DIR_IMAGE to repo.localdir, where the images are downloaded. + def runTestimageBuild(self, image_type): + log.info("Running the runtime tests for %s.." % image_type) + postconfig = "DEPLOY_DIR_IMAGE = \"%s\"" % self.repo.localdir + result = bitbake("%s -c testimage" % image_type, ignore_status=True, postconfig=postconfig) + testimage_results = ftools.read_file(os.path.join(get_bb_var("T", image_type), "log.do_testimage")) + log.info('Runtime tests results for %s:' % image_type) + print testimage_results + return result + + # Start the procedure! + def run(self): + if self.required_packages: + # Build the required packages for the tests + log.info("Building the required packages: %s ." % ', '.join(map(str, self.required_packages))) + result = bitbake(self.required_packages, ignore_status=True) + if result.status != 0: + log.error("Could not build required packages: %s. Output: %s" % (self.required_packages, result.output)) + sys.exit(1) + + # Build the package repository meta data. + log.info("Building the package index.") + result = bitbake("package-index", ignore_status=True) + if result.status != 0: + log.error("Could not build 'package-index'. Output: %s" % result.output) + sys.exit(1) + + # Create the directory structure for the images to be downloaded + log.info("Creating directory structure %s" % self.repo.localdir) + if not os.path.exists(self.repo.localdir): + os.makedirs(self.repo.localdir) + + # For each image type, download the needed files and run the tests. + noissuesfound = True + for image_type in self.image_types: + target = self.get_target_profile(image_type) + files_dict = target.get_files_dict() + log.info("Downloading files for %s" % image_type) + for f in files_dict: + if self.repo.check_old_file(files_dict[f]): + filepath = os.path.join(self.repo.localdir, files_dict[f]) + if os.path.exists(filepath): + os.remove(filepath) + self.repo.fetch(files_dict[f]) + + result = self.runTestimageBuild(image_type) + if result.status != 0: + noissuesfound = False + + if noissuesfound: + log.info('Finished. No issues found.') + else: + log.error('Finished. Some runtime tests have failed. Returning non-0 status code.') + sys.exit(1) + + + +def main(): + + parser = get_args_parser() + args = parser.parse_args() + + hwauto = HwAuto(image_types=args.image_types, repolink=args.repo_link, required_packages=args.required_packages, targetprofile=args.targetprofile, repoprofile=args.repoprofile) + + hwauto.run() + +if __name__ == "__main__": + try: + ret = main() + except Exception: + ret = 1 + import traceback + traceback.print_exc(5) + sys.exit(ret) --1.8.3.2
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Re: [PATCH V2 7/7] scripts/test-remote-image: Add script for running runtime tests on remotely built images
Quoted 17 lines
-----Original Message-----
From: Stefan Stanacar [mailto:[email protected]]
Sent: Saturday, June 07, 2014 5:09 PM
To: Stoicescu, CorneliuX
Cc: [email protected]
Subject: Re: [OE-core] [PATCH V2 7/7]scripts/test-remote-image: Add script for running runtime tests on remotely built imagesHi Corneliu,
I haven't carefully reviewed this series so if I didn't quite got the point of some things, sorry...
At a first look, here are my thoughts (this is actually a reply to the entire series, I seem to have lost the cover letter):
Quoted 5 lines
- It seems wierd that you instantiate the target controllers classes here... You do that so you can get the extra files, but that has nothing to do with testimage anyway. Let bitbake/testimage do it's part and it's configuration. Similar for image fs types (see my other
reply)
- I believe it's a good idea to use the target controllers to get information from them using class methods. This way we use the same source to get the information we need both internally and externally.
Quoted 5 lines
- I wouldn't mix the download stuff with the test/deploy stuff (bitbake's job). You already have command line configuration knobs, I'm sure you could add one for extra files... Surely the user know it's testing BBB and core-image- minimal and it needs to download the dtbs (because you need the dtbs only for minimal).
- This feature required keeping the user configuration to a minimum(we did not want to introduce any more TEST_ variables and have as few required command line options for the script as possible). The way it is, all target controllers use predictable image files and the missing piece was the so called "extra files" that some special target controllers need. This method, along with the other new class methods, can be used by any kind of external script needing information on what testimage needs/uses.
Quoted 6 lines
- the support for other fs types should be separate from the "test external built image". E.g bbb uses tar.bz2, so even at this point you can still test external images only with tar.gz (adding
IMAGE_FSTYPES
+= "tar.gz" to the Autobuilder config is a easy task). What I'm trying to say is that this is a user/build config option and this script shouldn't deal with every little thing
- We wanted to use the current default IMAGE_FSTYPES as much as possible(this is why the bug was opened). For this we had to enable the master image to decompress tar.bz2 and make the target controllers use them. Having IMAGE_FTYPES += "tar.gz" for all test images was not desired.
- We wanted to make the way the rootfs image fstype was chosen need as little maintenance as possible. For this we just define what image_fstypes a target controller can handle and the choose one from the available IMAGE_FSTYPES. Also having a classmethod decide this makes it easy to get this information from external sources, with higher accuracy.
Quoted 2 lines
- What's with the postconfig stuff?
QA_MACHINE= MACHINE? Same for distro.. I really don't get that part...
Bitbake does not export the MACHINE variable so in order to get this information we had to use this trick (the runqemu script also uses it, if I remember right). We do QA_MACHINE = MACHINE and then the QA_MACHINE variable is exported by bitbake and we can get it from 'bitbake -e'. :D
Quoted 2 lines
- I'm missing the bigger picture here with all the profiles stuff (plus some classes are unnecessarily abstract ).
The same way we have a BaseTarget class for the target controllers, we also have base target/repo profiles. These classes are abstract and define the bits and pieces that the script will actually use. We don't care how they are implemented. You can see them as interfaces to the target and images repo.
Also we wanted classes so they can be extended/modified easily by new ones. For example we have an AutoTargetProfile class that auto determines the images needed, but say a target controller cannot be predicted at all with the information we can access. We just create a new target profile extending the base target profile and add new functionality and information sources but still use the 'interfaces' defined.
Quoted 38 lines
So the whole point of this was to replace (assume default local.conf and MACHINE="beaglebone" here)
this:
---$ vi conf/local.conf INHERIT += "testimage" TEST_TARGET_IP = "10.11.12.2" TEST_TARGET = "BeagleBoneTarget" TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200" $ bitbake core-image-minimal # (or sato / sato-sdk) $ bitbake <image> -c testimage --- with this (except the local.conf part which should already be there, it is not the job of this script to add that): ---- $ bitbake rpm psplash # rpm/smart tests require these, else skip $ bitbake package-index $ wget -r -l0 -nd -np -P "tmp/deploy/images" http://autobuilder.yoctoproject.org/pub/nightly/20140606- 3/machines/beaglebone/ $ bitbake <image> -c testimage --- #yes, I cheated there, getting all the files, but you get the point.. alternatively:wget -r -l0 -nd -np -P "tmp/deploy/images" -A "*boneblack*.dtb"
http://autobuilder.yoctoproject.org/pub/nightly/20140606-
3/machines/beaglebone/
wget -P "tmp/deploy/images"
http://autobuilder.yoctoproject.org/pub/nightly/20140606-
3/machines/beaglebone/core-image-minimal-beaglebone.manifest wget -P "tmp/deploy/images"
http://autobuilder.yoctoproject.org/pub/nightly/20140606-
3/machines/beaglebone/core-image-minimal-beaglebone.tar.gz wget -P "tmp/deploy/images"
http://autobuilder.yoctoproject.org/pub/nightly/20140606-
3/machines/beaglebone/uImage
Quoted 3 lines
It seems to me that you are doing a lot more with this series and adding unnecessary complications. I guess I'm missing some pieces here...
THB the first version of this script did mainly what you pointed out it should do. But after a few talks among the team (here in RO QA and Paul), we decided we need to automate some configuration (like deciding what images we need, downloading them, checking if they are different than upstream, etc.) and also we need to make this easily extendable and thus the abstract classes and interfaces.
This series, apart from adding this script, addresses other issues too. Not everything is for the script, you can see them as issues found along the way (like hard coded image fstypes, multiple kernel files naming). These should have been fixed independently but I added them here because of lack of time(see below) and they are related somehow(especially to the script). The only change introduced that only helps the script (and other outside script that will want this information) is the get_extra_files method. If the only use case was to build the images locally and run the tests locally, this would have been easily avoided but unfortunately we need to use the AB images on remote hardware testing racks.
Finally, why this series of patches was needed instead of standalone small patches. These bugs have been marked for 1.7 M1 and even though we tried to finish earlier some changes affected the others and there was no point to send something and then repair/change it. I will be OOO this week and the cutoff for M1 is on the 13-th. I am sorry for the large set and I hope, through the cover letter and these answers, I managed to point out what we intend to add and change.
I will not be able to answer any more mails until the 17-th but I hope Paul can help with any more questions/issues that appear. If we did extend too much with this and some changes proposed are not indeed needed, I will revise the script and make it work without them when I get back, though the features should be moved to M2.
Regards,
Corneliu
Re: [PATCH V2 7/7] scripts/test-remote-image: Add script for running runtime tests on remotely built images
Quoted 10 lines · CorneliuX
Quoted 5 lines · Stefan Stanacar
- It seems wierd that you instantiate the target controllers classes here... You do that so you can get the extra files, but that has nothing to do with testimage anyway. Let bitbake/testimage do it's part and it's configuration. Similar for image fs types (see my other reply)
- I believe it's a good idea to use the target controllers to get information from them using class methods. This way we use the same source to get the information we need both internally and externally.
Right, the intention was to avoid duplicating the code for handling machine- specific behaviours. We aren't instantiating the target controllers, just using them as classes and call class functions on them.
Quoted 11 lines
Quoted 6 lines
- the support for other fs types should be separate from the "test external built image". E.g bbb uses tar.bz2, so even at this point you can still test external images only with tar.gz (adding
IMAGE_FSTYPES+= "tar.gz" to the Autobuilder config is a easy task). What I'm trying to say is that this is a user/build config option and this script shouldn't deal with every little thing- We wanted to use the current default
IMAGE_FSTYPESas much as possible(this is why the bug was opened). For this we had to enable the master image to decompress tar.bz2 and make the target controllers use them. HavingIMAGE_FTYPES+= "tar.gz" for all test images was not desired.
At the moment Beth is trying to reduce the number of artifacts produced by the autobuilder; it just seemed a bit wasteful to add another tarball format when we could simply handle whatever format is already produced (assuming it is a tarball, of course).
Quoted 7 lines
Quoted 2 lines
- What's with the postconfig stuff?
QA_MACHINE= MACHINE? Same for distro.. I really don't get that part...Bitbake does not export the MACHINE variable so in order to get this information we had to use this trick (the runqemu script also uses it, if I remember right). We do
QA_MACHINE= MACHINE and then theQA_MACHINEvariable is exported by bitbake and we can get it from 'bitbake -e'. :D
This is unfortunately part of the pain of how oe-selftest and other external scripts like it query variables using bitbake -e. What bitbake -e does is to report variables broadly as they would be exported to the environment; if a variable is marked "unexport" (as MACHINE is) then you won't see its final value in bitbake -e output other than in comments. There are other ways we could deal with this, and maybe bitbake -e shouldn't pay attention to unexport, however the method this new script uses, whilst a little hacky, is the least disruptive.
Quoted 9 lines
Quoted 2 lines
- I'm missing the bigger picture here with all the profiles stuff (plus some classes are unnecessarily abstract ).
The same way we have a BaseTarget class for the target controllers, we also have base target/repo profiles. These classes are abstract and define the bits and pieces that the script will actually use. We don't care how they are implemented. You can see them as interfaces to the target and images repo.
Quoted 6 lines
Also we wanted classes so they can be extended/modified easily by new ones. For example we have an AutoTargetProfile class that auto determines the images needed, but say a target controller cannot be predicted at all with the information we can access. We just create a new target profile extending the base target profile and add new functionality and information sources but still use the 'interfaces' defined.
We'll have to wait and see how useful this ends up being in practice, but the intention is to allow for some flexibility in future.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Quoted 42 lines · On Friday 06 June 2014 22:14:31 Corneliu Stoicescu wrote:
This series of patches affects the automated runtime tests and introduces the following changes/features:
YB #6375: Add support for more rootfs compression formats
- The target controller dynamically determines whatIMAGE_FSTYPESto use based on the value ofsupported_image_fstypesthat each target controller defines or inherits. This is needed for: * givint the targer controllers the possibility to choose an image fstype that is actually built instead of relying on a hard-coded value * enable external scripts to predict the name of the rootfs file. - Added bzip2 to the core-image-testmaster that decompresses the test roofs files. This is needed ATM for BSPs like beaglebone and edgeruter.YB #6254: Set up automated testing of autobuilder images on real hardware We need a script that fetches images from a remote http server(for now) and uses them to conduct runtime tests. For this we needed: - to be able to import and use the
testargetloader.pymodule to find the target controller beying used - create and access classmethods from the target controllers that would give information about the images needed for download (like rootfs type and extra files) - unify the kernel file naming scheme used throughout testimage(qemu use bzImage-qemux86.bin and the others use just bzImage for example). - a script that could use the above, run the runtime tests and return the resultsNOTE: This script relies on the merge of "[PATCH]
oeqa/utils/commands.py:
add support for postconfig option" allready on the mailing list.*** BLURB HERE ***
Corneliu Stoicescu (7):
targetcontrol.py: make possible dynamical determination of rootfs typemasterimage.py: enable dynamical determination of rootfs type core-image-testmaster.bb: add bzip2 to imagetargetcontrol.py: Add a classmethod to get extra files needed by the
target controllers
oeqa/controllers/testtargetloader.py: add 'import os'controllers/masterimage.py: Make testimage kernel naming pattern
universal
scripts/test-remote-image: Add script for running runtime tests on
remotely built images
Quoted 7 lines
meta/lib/oeqa/controllers/masterimage.py | 11 +- meta/lib/oeqa/controllers/testtargetloader.py | 1 + meta/lib/oeqa/targetcontrol.py | 23 +- .../images/core-image-testmaster.bb | 2 +- scripts/test-remote-image | 340 +++++++++++++++++++++ 5 files changed, 370 insertions(+), 7 deletions(-) create mode 100755 scripts/test-remote-image
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre