[OE-core] [PATCH v2] oeqa/selftest/kernel.py: Add new file destined for kernel related tests
[YP#7202]: Test for linux-dummy The new kernel.py file is intended for kernel related test cases. The test for linux-dummy will ensure it is in good shape and can be used as a kernel replacement at build time. To do this, the test will first clean sstate for linux-dummy target, ensuring no file is present in the stamps directory. After, core-image-minimal is built, ensuring linux-dummy can be used as a kernel substitute. Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/kernel.py | 29 + 1 file changed, 29 insertions(+) create mode 100644 meta/lib/oeqa/selftest/kernel.py diff --git a/meta/lib/oeqa/selftest/kernel.py b/meta/lib/oeqa/selftest/kernel.py new file mode 100644 index 000..3fe3517 --- /dev/null +++ b/meta/lib/oeqa/selftest/kernel.py @@ -0,0 +1,29 @@ +import os +import oeqa.utils.ftools as ftools +from oeqa.selftest.base import oeSelfTest +from oeqa.utils.commands import runCmd, bitbake, get_bb_var +from oeqa.utils.decorators import testcase + +class KernelTests(oeSelfTest): +def test_dummy_kernel(self): +""" +[YP#7202] +- test that linux-dummy target can be used as kernel provider for an image +- check no "multiple providers are available for" message is received while building the image +""" +config_param = 'PREFERRED_PROVIDER_virtual/kernel = "linux-dummy"' +self.append_config(config_param) +arch_dir = get_bb_var('MULTIMACH_TARGET_SYS', target='linux-dummy') +stamps_dir = os.path.join(os.getenv('BUILDDIR'), "tmp/stamps") +lnx_dmy_stamps_dir = os.path.join(stamps_dir, arch_dir, 'linux-dummy') +res = bitbake("linux-dummy -ccleansstate") # ensure we have nothing related to linux-dummy in stamps dir. +self.assertFalse(os.listdir(lnx_dmy_stamps_dir), msg='linux-dummy stamps dir. should have been cleaned. Something \ + happened with bitbake linux-dummy -ccleansstate') +res = bitbake("core-image-minimal")# testing linux-dummy is both buildable and usable within an image +self.remove_config(config_param) +self.assertEqual(res.status, 0, msg="core-image-minimal failed to build. Please check logs. ") +self.assertNotIn("multiple providers are available for", res.output, msg="'multiple providers are available for\ +linux-dummy' message received during buildtime.") +self.assertTrue(os.listdir(lnx_dmy_stamps_dir), msg="linux-dummy didn't build correctly. No stamp present in stamps \ +dir. %s" % lnx_dmy_stamps_dir) + -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH v2] oe-selftest: Add support for lib/oeqa/selftest subdirectories
This patch adds functionality to allow creating subdirectories inside lib/oeqa/selftest for all layers present in BBLAYERS. Like this, test cases can be grouped into organized directories. Addresses [YOCTO #7865] Signed-off-by: Costin Constantin --- scripts/oe-selftest | 53 - 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index 4eb404b..8b35a2b 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -159,19 +159,33 @@ def remove_inc_files(): except: pass + +def get_tests_modules(include_hidden=False): +modules_list = list() +for modules_path in oeqa.selftest.__path__: +for (p, d, f) in os.walk(modules_path): +files = sorted([f for f in os.listdir(p) if f.endswith('.py') and not (f.startswith('_') and not include_hidden) and not f.startswith('__') and f != 'base.py']) +for f in files: +submodules = p.split("selftest")[-1] +module = "" +if submodules: +module = 'oeqa.selftest' + submodules.replace("/",".") + "." + f.split('.py')[0] +else: +module = 'oeqa.selftest.' + f.split('.py')[0] +if module not in modules_list: +modules_list.append(module) +return modules_list + + def get_tests(exclusive_modules=[], include_hidden=False): -testslist = [] +test_modules = list() for x in exclusive_modules: -testslist.append('oeqa.selftest.' + x) -if not testslist: -for testpath in oeqa.selftest.__path__: -files = sorted([f for f in os.listdir(testpath) if f.endswith('.py') and not (f.startswith('_') and not include_hidden) and not f.startswith('__') and f != 'base.py']) -for f in files: -module = 'oeqa.selftest.' + f[:-3] -if module not in testslist: -testslist.append(module) +test_modules.append('oeqa.selftest.' + x) +if not test_modules: +inc_hidden = include_hidden +test_modules = get_tests_modules(inc_hidden) -return testslist +return test_modules class Tc: @@ -218,23 +232,12 @@ def get_tests_from_module(tmod): def get_all_tests(): -tmodules = set() -testlist = [] -prefix = 'oeqa.selftest.' - # Get all the test modules (except the hidden ones) -for tpath in oeqa.selftest.__path__: -files = sorted([f for f in os.listdir(tpath) if f.endswith('.py') and not -f.startswith(('_', '__')) and f != 'base.py']) -for f in files: -tmodules.add(prefix + f.rstrip('.py')) - +testlist = [] +tests_modules = get_tests_modules() # Get all the tests from modules -tmodules = sorted(list(tmodules)) - -for tmod in tmodules: +for tmod in sorted(tests_modules): testlist += get_tests_from_module(tmod) - return testlist @@ -463,7 +466,7 @@ def main(): log.info('Listing all available test modules:') testslist = get_tests(include_hidden=True) for test in testslist: -module = test.split('.')[-1] +module = test.split('oeqa.selftest.')[-1] info = '' if module.startswith('_'): info = ' (hidden)' -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest/kernel.py: Add new file destined for kernel related tests [YP#7202]: Test for linux-dummy The new kernel.py file is intended for kernel related test cases. The test for
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/kernel.py | 29 + 1 file changed, 29 insertions(+) create mode 100644 meta/lib/oeqa/selftest/kernel.py diff --git a/meta/lib/oeqa/selftest/kernel.py b/meta/lib/oeqa/selftest/kernel.py new file mode 100644 index 000..3fe3517 --- /dev/null +++ b/meta/lib/oeqa/selftest/kernel.py @@ -0,0 +1,29 @@ +import os +import oeqa.utils.ftools as ftools +from oeqa.selftest.base import oeSelfTest +from oeqa.utils.commands import runCmd, bitbake, get_bb_var +from oeqa.utils.decorators import testcase + +class KernelTests(oeSelfTest): +def test_dummy_kernel(self): +""" +[YP#7202] +- test that linux-dummy target can be used as kernel provider for an image +- check no "multiple providers are available for" message is received while building the image +""" +config_param = 'PREFERRED_PROVIDER_virtual/kernel = "linux-dummy"' +self.append_config(config_param) +arch_dir = get_bb_var('MULTIMACH_TARGET_SYS', target='linux-dummy') +stamps_dir = os.path.join(os.getenv('BUILDDIR'), "tmp/stamps") +lnx_dmy_stamps_dir = os.path.join(stamps_dir, arch_dir, 'linux-dummy') +res = bitbake("linux-dummy -ccleansstate") # ensure we have nothing related to linux-dummy in stamps dir. +self.assertFalse(os.listdir(lnx_dmy_stamps_dir), msg='linux-dummy stamps dir. should have been cleaned. Something \ + happened with bitbake linux-dummy -ccleansstate') +res = bitbake("core-image-minimal")# testing linux-dummy is both buildable and usable within an image +self.remove_config(config_param) +self.assertEqual(res.status, 0, msg="core-image-minimal failed to build. Please check logs. ") +self.assertNotIn("multiple providers are available for", res.output, msg="'multiple providers are available for\ +linux-dummy' message received during buildtime.") +self.assertTrue(os.listdir(lnx_dmy_stamps_dir), msg="linux-dummy didn't build correctly. No stamp present in stamps \ +dir. %s" % lnx_dmy_stamps_dir) + -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/utils/commands.py: eliminate import bb error [YP#9136] added bitbake/lib to sys.path
Signed-off-by: Costin Constantin --- meta/lib/oeqa/utils/commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py index 32e001c..8220169 100644 --- a/meta/lib/oeqa/utils/commands.py +++ b/meta/lib/oeqa/utils/commands.py @@ -18,6 +18,7 @@ from oeqa.utils import CommandError from oeqa.utils import ftools import re import contextlib +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..', 'bitbake/lib'))) import bb class Command(object): -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oe-selftest: Add support for lib/oeqa/selftest subdirectories
This patch adds functionality to allow creating subdirectories inside lib/oeqa/selftest for all layers present in BBLAYERS. Like this, test cases can be grouped into organized directories. Addresses [YOCTO #7865] Signed-off-by: Costin Constantin --- scripts/oe-selftest | 55 + 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index 4eb404b..6a3181c 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -159,19 +159,35 @@ def remove_inc_files(): except: pass + +def get_tests_modules(include_hidden=False): +modules_list = list() +for modules_path in oeqa.selftest.__path__: +for (p, d, f) in os.walk(modules_path): +files = sorted([f for f in os.listdir(p) if f.endswith('.py') and not (f.startswith('_') and not include_hidden) and not f.startswith('__') and f != 'base.py']) +for f in files: +submodules = p.split("selftest")[-1] +module = "" +if submodules: +module = 'oeqa.selftest' + submodules.replace("/",".") + "." + f.rstrip('.py') +else: +module = 'oeqa.selftest.' + f.rstrip('.py') +if module not in modules_list: +modules_list.append(module) + +return modules_list + + + def get_tests(exclusive_modules=[], include_hidden=False): -testslist = [] +test_modules = list() for x in exclusive_modules: -testslist.append('oeqa.selftest.' + x) -if not testslist: -for testpath in oeqa.selftest.__path__: -files = sorted([f for f in os.listdir(testpath) if f.endswith('.py') and not (f.startswith('_') and not include_hidden) and not f.startswith('__') and f != 'base.py']) -for f in files: -module = 'oeqa.selftest.' + f[:-3] -if module not in testslist: -testslist.append(module) +test_modules.append('oeqa.selftest.' + x) +if not test_modules: +inc_hidden = include_hidden +test_modules = get_tests_modules(inc_hidden) -return testslist +return test_modules class Tc: @@ -218,23 +234,12 @@ def get_tests_from_module(tmod): def get_all_tests(): -tmodules = set() -testlist = [] -prefix = 'oeqa.selftest.' - # Get all the test modules (except the hidden ones) -for tpath in oeqa.selftest.__path__: -files = sorted([f for f in os.listdir(tpath) if f.endswith('.py') and not -f.startswith(('_', '__')) and f != 'base.py']) -for f in files: -tmodules.add(prefix + f.rstrip('.py')) - +testlist = [] +tests_modules = get_tests_modules() # Get all the tests from modules -tmodules = sorted(list(tmodules)) - -for tmod in tmodules: +for tmod in sorted(tests_modules): testlist += get_tests_from_module(tmod) - return testlist @@ -463,7 +468,7 @@ def main(): log.info('Listing all available test modules:') testslist = get_tests(include_hidden=True) for test in testslist: -module = test.split('.')[-1] +module = test.split('oeqa.selftest.')[-1] info = '' if module.startswith('_'): info = ' (hidden)' -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 12/13] buildtools-with-tc.bb: extend buildtools-tarball to include test cases
recipes-core/meta/buildtools-with-tc.bb is a new recipe that uses all buildtools-tarball has to offer and adds test cases support. Signed-off-by: Costin Constantin --- meta/recipes-core/meta/buildtools-with-tc.bb | 37 1 file changed, 37 insertions(+) create mode 100644 meta/recipes-core/meta/buildtools-with-tc.bb diff --git a/meta/recipes-core/meta/buildtools-with-tc.bb b/meta/recipes-core/meta/buildtools-with-tc.bb new file mode 100644 index 000..84a57ee --- /dev/null +++ b/meta/recipes-core/meta/buildtools-with-tc.bb @@ -0,0 +1,37 @@ +DESCRIPTION = "This recipe is used to extend the functionality of buildtools-tarball \ + by adding the test harness plus binaries that might be required for DUTs.\ + " + +require ${COREBASE}/meta/recipes-core/meta/buildtools-tarball.bb +inherit testimage + +SDK_TITLE += "with test cases and binaries" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ + file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" + +TEST_EXPORT_ONLY = "1" +TEST_TARGET = "simpleremote" +IMAGE_NO_MANIFEST = "1" + +addtask testimage before do_populate_sdk + +tar_sdk_prepend () { + mkdir ${SDK_OUTPUT}${SDKPATH}/exported_tests 2>/dev/null + for i in $(ls ${TEST_EXPORT_DIR}) + do +if [ ${i} != "tar_files" ] +then + cp -r ${TEST_EXPORT_DIR}/${i} ${SDK_OUTPUT}${SDKPATH}/exported_tests +fi + done + sed -i 's/\"pkgmanifest\": \"\"/\"pkgmanifest\": \"\\ndropbear\\n\"/' ${SDK_OUTPUT}${SDKPATH}/exported_tests/testdata.json + cp ${SDK_OUTPUT}${SDKPATH}/exported_tests/testdata.json ${TEST_EXPORT_DIR} +} + +create_shar_append () { + message='echo "To run exported tests, go into exported_tests directory and run ./runexported.py"' + sed -i "/exit\ 0/i \ +${message}" ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh +} + -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 13/13] Files to test the patch set.
Please don't include these files. Their sole purpose is to provide necessary ground to easily test the patch set. Signed-off-by: Costin Constantin --- meta/lib/oeqa/runtime/mytest.py| 25 + meta/recipes-test/hello-dut/files/hello.c | 8 meta/recipes-test/hello-dut/hello-dut_0.1.bb | 15 +++ meta/recipes-test/hello-native/files/hello.c | 9 + meta/recipes-test/hello-native/hello_0.1.bb| 16 meta/recipes-test/hello-test/files/hello.c | 9 + meta/recipes-test/hello-test/hello-test_0.1.bb | 16 7 files changed, 98 insertions(+) create mode 100644 meta/lib/oeqa/runtime/mytest.py create mode 100644 meta/recipes-test/hello-dut/files/hello.c create mode 100644 meta/recipes-test/hello-dut/hello-dut_0.1.bb create mode 100644 meta/recipes-test/hello-native/files/hello.c create mode 100644 meta/recipes-test/hello-native/hello_0.1.bb create mode 100644 meta/recipes-test/hello-test/files/hello.c create mode 100644 meta/recipes-test/hello-test/hello-test_0.1.bb diff --git a/meta/lib/oeqa/runtime/mytest.py b/meta/lib/oeqa/runtime/mytest.py new file mode 100644 index 000..6afb79e --- /dev/null +++ b/meta/lib/oeqa/runtime/mytest.py @@ -0,0 +1,25 @@ +import os +from time import sleep +from oeqa.oetest import oeRuntimeTest +from oeqa.utils.decorators import TestNeedsBin + +class mytest(oeRuntimeTest): + +### A simple test for the DUT ## + +@TestNeedsBin(("hello-dut","rm"), + ("hello-test","rm"), + ("hello-test","rpm","rm"), + ("hello-dut","rpm"), + ("hello","native") + ) +def test_hello_on_DUT_3(self): + (status, output) = self.target.run("hello") + self.a=5 + print("For hello: " + str(output) + "\n") + (status1,output1) = self.target.run("hello-test") + print("For hello-test: " + str(output1) + "\n") + self.assertEqual(status, 0, "failed for hello") + self.assertEqual(status1, 0, "failed for hello-test") + + diff --git a/meta/recipes-test/hello-dut/files/hello.c b/meta/recipes-test/hello-dut/files/hello.c new file mode 100644 index 000..fb89415 --- /dev/null +++ b/meta/recipes-test/hello-dut/files/hello.c @@ -0,0 +1,8 @@ +#include + +int main(int argc, char** argv) +{ + printf("Hello world on DUT \n"); + return 0; + +} diff --git a/meta/recipes-test/hello-dut/hello-dut_0.1.bb b/meta/recipes-test/hello-dut/hello-dut_0.1.bb new file mode 100644 index 000..832b62f --- /dev/null +++ b/meta/recipes-test/hello-dut/hello-dut_0.1.bb @@ -0,0 +1,15 @@ +SUMMARY = "Hello world recipe" +DESCRIPTION = "test application" +LICENSE = "CLOSED" +SRC_URI = "file://hello.c \ +" +S = "${WORKDIR}" +do_compile() { +${CC} hello.c -o hello +} + +do_install() { +install -d ${D}/${bindir} +install -m 0755 hello ${D}/${bindir} +} + diff --git a/meta/recipes-test/hello-native/files/hello.c b/meta/recipes-test/hello-native/files/hello.c new file mode 100644 index 000..ed30d69 --- /dev/null +++ b/meta/recipes-test/hello-native/files/hello.c @@ -0,0 +1,9 @@ +#include + +int main(int argc, char** argv) +{ + printf("Hello world on host machine \n"); + + return 0; + +} diff --git a/meta/recipes-test/hello-native/hello_0.1.bb b/meta/recipes-test/hello-native/hello_0.1.bb new file mode 100644 index 000..42659b9 --- /dev/null +++ b/meta/recipes-test/hello-native/hello_0.1.bb @@ -0,0 +1,16 @@ +SUMMARY = "Hello world recipe" +DESCRIPTION = "test application" +LICENSE = "CLOSED" +SRC_URI = "file://hello.c \ +" +S = "${WORKDIR}" +do_compile() { +${CC} hello.c -o hello +} + +do_install() { +install -d ${D}/${bindir} +install -m 0755 hello ${D}/${bindir} +} + +BBCLASSEXTEND = "nativesdk native" diff --git a/meta/recipes-test/hello-test/files/hello.c b/meta/recipes-test/hello-test/files/hello.c new file mode 100644 index 000..405aed1 --- /dev/null +++ b/meta/recipes-test/hello-test/files/hello.c @@ -0,0 +1,9 @@ +#include + +int main(int argc, char** argv) +{ + printf("Hello test \n"); + + return 0; + +} diff --git a/meta/recipes-test/hello-test/hello-test_0.1.bb b/meta/recipes-test/hello-test/hello-test_0.1.bb new file mode 100644 index 000..9832eb0 --- /dev/null +++ b/meta/recipes-test/hello-test/hello-test_0.1.bb @@ -0,0 +1,16 @@ +SUMMARY = "Hello world recipe" +DESCRIPTION = "test application" +LICENSE = "CLOSED" +SRC_URI = "file://hello.c \ +" +S = "${WORKDIR}" +do_compile() { +${CC} hello.c -o hello-test +} + +do_install() { +install -d ${D}/${bindir} +install -m 0755 hello-test ${D}/${bindir} +} + +BBCLASSEXTEND = "nativesdk native" -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 10/13] oeqa/testimage: Added export features.
From: Lucian Musat It is now possible to export tests from all the layers that are added in bblayers even when grouped in folders. They are exported in another folder called "extralayers" and nicely grouped per layer so the test files won't mingle. If a layer contains a conf/test folder then export that as well. Signed-off-by: Lucian Musat --- meta/classes/testimage.bbclass | 113 ++--- 1 file changed, 96 insertions(+), 17 deletions(-) diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index 400d16d..e3793ab 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass @@ -164,6 +164,11 @@ def get_tests_list(d, type="runtime"): testslist.append("oeqa." + type + "." + testname) found = True break +elif os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname.split(".")[0]))\ +and os.path.isdir(os.path.join(p, 'lib', 'oeqa', type, testname.split(".")[0])): +testslist.append("oeqa." + type + "." + testname) +found = True +break if not found: bb.fatal('Test %s specified in TEST_SUITES could not be found in lib/oeqa/runtime under BBPATH' % testname) @@ -184,6 +189,24 @@ def get_tests_list(d, type="runtime"): add_auto_list(testpath) return testslist +def get_extra_layers(d): +default_layers = ['meta-yocto','meta-yocto-bsp'] +extra_layers = [] + +layer_list = [var for var in d.getVar("BBLAYERS", True).split(" ") if var] + +for layer in layer_list: +if (os.path.basename(os.path.normpath(layer)) not in default_layers)\ +and os.path.exists(os.path.join(layer,"lib","oeqa")): +extra_layers.append(layer) +return extra_layers + +def get_layer(fullpath): +try: +layer = os.path.basename(fullpath.split(os.path.join("lib","oeqa"))[0].rstrip(os.sep)) +except IndexError: +layer = None +return layer def exportTests(d,tc): import json @@ -239,6 +262,13 @@ def exportTests(d,tc): # - __init__.py files bb.utils.mkdirhier(os.path.join(exportpath, "oeqa/runtime/files")) bb.utils.mkdirhier(os.path.join(exportpath, "oeqa/utils")) +if len(get_extra_layers(d)) > 1: +bb.utils.mkdirhier(os.path.join(exportpath, "extralayers")) +for layer in get_extra_layers(d): +if os.path.basename(os.path.normpath(layer)) != "meta": +bb.utils.mkdirhier(os.path.join(exportpath, "extralayers/%s/oeqa/runtime/files" % os.path.basename(os.path.normpath(layer +bb.utils.mkdirhier(os.path.join(exportpath, "extralayers/%s/oeqa/utils" % os.path.basename(os.path.normpath(layer + # copy test modules, this should cover tests in other layers too bbpath = d.getVar("BBPATH", True).split(':') for t in tc.testslist: @@ -246,6 +276,18 @@ def exportTests(d,tc): if re.search("\w+\.\w+\.test_\S+", t): t = '.'.join(t.split('.')[:3]) mod = pkgutil.get_loader(t) +if (str(os.path.join("meta","lib","oeqa")) not in mod.filename): +if get_layer(mod.filename): +layerpath = os.path.join(exportpath, "extralayers", get_layer(mod.filename)) +else: +layerpath = exportpath +else: +layerpath = exportpath + +if os.path.isdir(mod.filename): +isfolder = True +else: +shutil.copy2(mod.filename, os.path.join(layerpath, "oeqa/runtime")) # More depth than usual? if (t.count('.') > 2): for p in bbpath: @@ -255,24 +297,61 @@ def exportTests(d,tc): target_folder = os.path.join(exportpath, "oeqa", "runtime", os.path.basename(foldername)) if not os.path.exists(target_folder): shutil.copytree(foldername, target_folder) -if not isfolder: -shutil.copy2(mod.filename, os.path.join(exportpath, "oeqa/runtime")) +if isfolder: +target_folder = os.path.join(layerpath, "oeqa", "runtime", os.path.basename(mod.filename)) +if not os.path.exists(target_folder): +shutil.copytree(mod.filename, target_folder) + + if not isfolder: +shutil.copy2(mod.filename, os.path.join(layerpath, "oeqa/runtime")) # copy __init__.py files -oeqadir = pkgutil.get_loader("oeqa").filename -shutil.copy2(os.path.join(oeqadir, "__init__.py"), os.path.join(exportpath, "oeqa")) -shutil.copy2(os.path.join(oeqadir, "runtime/__init__.py"), os.path.join(exportpath, "oeqa/runtime")) -# copy oeqa/oetest.py and oeqa/runexported.py -shutil.copy2(os.path.join(oeqadir, "oetest.py"), os.path.join(exportpath, "oeqa")) -shutil.copy2(os.path.join(oeqadir, "runexported.py"), exportpath) -# copy o
[OE-core] [PATCH 11/13] oeqa/runtime: Copy all __init__.py files from all layers.
From: Lucian Musat Copy all the __init__.py files from all the extra layers also, specified in bblayers.conf, in accordance to TEST_SUITES variable. Signed-off-by: Lucian Musat --- meta/classes/testimage.bbclass | 67 +++--- meta/lib/oeqa/runexported.py | 2 +- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index e3793ab..0391fbf 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass @@ -213,6 +213,7 @@ def exportTests(d,tc): import shutil import pkgutil import re +import oeqa.utils.testexport as te exportpath = d.getVar("TEST_EXPORT_DIR", True) @@ -302,37 +303,37 @@ def exportTests(d,tc): if not os.path.exists(target_folder): shutil.copytree(mod.filename, target_folder) - if not isfolder: +if not isfolder: shutil.copy2(mod.filename, os.path.join(layerpath, "oeqa/runtime")) -# copy __init__.py files -for _oeqadir in get_extra_layers(d): -oeqadir = os.path.join(_oeqadir,"lib","oeqa") -# copy oeqa/oetest.py and oeqa/runexported.py -if os.path.basename(_oeqadir) == "meta": -layerpath = exportpath -# Make sure we always copy the minimum required files from meta -shutil.copy2(os.path.join(oeqadir, "oetest.py"), os.path.join(layerpath, "oeqa")) -shutil.copy2(os.path.join(oeqadir, "__init__.py"), os.path.join(layerpath, "oeqa")) -shutil.copy2(os.path.join(oeqadir, "runtime", "__init__.py"), os.path.join(layerpath, "oeqa", "runtime")) -shutil.copy2(os.path.join(oeqadir, "runexported.py"), layerpath) -for root, dirs, files in os.walk(os.path.join(oeqadir, "utils")): -for f in files: -if f.endswith(".py"): -shutil.copy2(os.path.join(root, f), os.path.join(layerpath, "oeqa/utils")) -else: -if oeqadir in mod.filename: -layerpath = os.path.join(exportpath, "extralayers", get_layer(mod.filename)) - -try: -if oeqadir in mod.filename: +# copy __init__.py files +for _oeqadir in get_extra_layers(d): +oeqadir = os.path.join(_oeqadir,"lib","oeqa") +# copy oeqa/oetest.py and oeqa/runexported.py +if os.path.basename(_oeqadir) == "meta": +layerpath = exportpath +# Make sure we always copy the minimum required files from meta +shutil.copy2(os.path.join(oeqadir, "oetest.py"), os.path.join(layerpath, "oeqa")) shutil.copy2(os.path.join(oeqadir, "__init__.py"), os.path.join(layerpath, "oeqa")) -except IOError: -pass -try: -if oeqadir in mod.filename: -shutil.copy2(os.path.join(oeqadir, "runtime/__init__.py"), os.path.join(layerpath, "oeqa/runtime")) -except IOError: -pass +shutil.copy2(os.path.join(oeqadir, "runtime", "__init__.py"), os.path.join(layerpath, "oeqa", "runtime")) +shutil.copy2(os.path.join(oeqadir, "runexported.py"), layerpath) +for root, dirs, files in os.walk(os.path.join(oeqadir, "utils")): +for f in files: +if f.endswith(".py"): +shutil.copy2(os.path.join(root, f), os.path.join(layerpath, "oeqa/utils")) +else: +if oeqadir in mod.filename: +layerpath = os.path.join(exportpath, "extralayers", get_layer(mod.filename)) + +try: +if oeqadir in mod.filename: +shutil.copy2(os.path.join(oeqadir, "__init__.py"), os.path.join(layerpath, "oeqa")) +except IOError: +pass +try: +if oeqadir in mod.filename: +shutil.copy2(os.path.join(oeqadir, "runtime/__init__.py"), os.path.join(layerpath, "oeqa/runtime")) +except IOError: +pass # copy oeqa/utils/*.py for root, dirs, files in os.walk(os.path.join(oeqadir, "utils")): for f in files: @@ -349,13 +350,19 @@ def exportTests(d,tc): bb.utils.mkdirhier(os.path.join(exportpath, "conf/test")) else: bb.utils.mkdirhier(os.path.join(exportpath, "extralayers/%s/conf/test" % os.path.basename(os.path.normpath(layer +layerpath = os.path.join(exportpath, "extralayers", os.path.basename(os.path.normpath(layer))) for root, dirs, files in os.walk(os.path.join(_oeqadir, "conf", "test")): for f in files: shutil.copy2(os.path.join(root, f), os.path.join(layerpath, "conf/test")) #integrating binaries too # creting needed directory structure -arch = te.get_des
[OE-core] [PATCH 09/13] oeqa/runexported: Add parameter support for machine arch.
From: Lucian Musat Added support to change machine architecture on the fly and support for future TestNeedsBin decorator for tests that need binaries. Signed-off-by: Lucian Musat Signed-off-by: Costin Constantin --- meta/lib/oeqa/runexported.py | 22 ++ 1 file changed, 22 insertions(+) diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py index b8d621c..3a6bad7 100755 --- a/meta/lib/oeqa/runexported.py +++ b/meta/lib/oeqa/runexported.py @@ -22,6 +22,9 @@ import sys import os import time import argparse +import re + +from oeqa.utils.testsexport import get_dest_folder try: import simplejson as json @@ -88,10 +91,13 @@ def main(): the current dir is used. This is used for usually creating a ssh log file and a scp test file.") parser.add_argument("--list-tests", dest="list_tests", help="This lists the current TEST_SUITES that will be run.", action='store_true') parser.add_argument("-r","--run-tests", dest="run_tests", help="Overwrite TEST_SUITES from the json file with custom list of tests.", nargs = '*') +parser.add_argument("-m","--machine", dest="machine", help="Overwrite MACHINE from the json file ") parser.add_argument("json", help="The json file exported by the build system", default="testdata.json", nargs='?') args = parser.parse_args() +os.environ["bin_dir"] = os.path.join(os.getcwd(), "binaries") # exporting bin_dir path + if os.path.isdir("extralayers"): extrapaths = [x[0] for x in os.walk('extralayers')] for path in extrapaths: @@ -137,6 +143,22 @@ def main(): if key != "d" and key != "target" and key != "host_dumper": setattr(tc, key, loaded[key]) +if args.machine: +d['MACHINE'] = args.machine +bin_dir = os.getenv("bin_dir") +found = False +if os.path.exists(bin_dir): +for item in os.listdir(bin_dir): +if not re.search("native", item) and os.path.exists(os.path.join(bin_dir, item, "mapping.cfg")): +with open(os.path.join(bin_dir, item, "mapping.cfg"), "r") as mapping_file: +mapping = eval(mapping_file.read()) +if args.machine in mapping.keys(): +d['TARGET_SYS'] = mapping[args.machine][0] +d['TUNE_FEATURES'] = mapping[args.machine][1] +found = True +if not found: +print("WARNING: Cannot find binaries for provided machine %s." % args.machine) + if args.run_tests: tc.testslist = args.run_tests -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 08/13] oeqa/runexported: The runner supports tests from other layers.
From: Lucian Musat It looks in "extralayers" folder if it can't find the test that needs to be run. Signed-off-by: Lucian Musat --- meta/lib/oeqa/runexported.py | 14 ++ 1 file changed, 14 insertions(+) diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py index c3ce79a..b8d621c 100755 --- a/meta/lib/oeqa/runexported.py +++ b/meta/lib/oeqa/runexported.py @@ -92,6 +92,12 @@ def main(): args = parser.parse_args() +if os.path.isdir("extralayers"): +extrapaths = [x[0] for x in os.walk('extralayers')] +for path in extrapaths: +if os.path.isdir(os.path.join(path,"oeqa")) and (os.path.join(path,"oeqa") not in sys.path): +sys.path.append(os.path.abspath(path)) + with open(args.json, "r") as f: loaded = json.load(f) @@ -144,6 +150,14 @@ def main(): for files in os.listdir(os.sep.join(test.split('.'))): if (files.endswith(".py")) and not files.startswith("_"): tc.testslist.insert(index, test+'.'+files.split('.')[0]) +elif not os.path.isfile(os.path.join(os.sep.join(test.split('.')), '.py')): +for testpath in sys.path: +directory = os.path.join(testpath, os.sep.join(test.split('.'))) +if os.path.isdir(directory): +del tc.testslist[index] +for files in os.listdir(directory): +if (files.endswith(".py")) and not files.startswith("_"): +tc.testslist.insert(index, test+'.'+files.split('.')[0]) target.exportStart() runTests(tc) -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 07/13] oeqa/runexported: Added support for folder names in TEST_SUITES.
From: Lucian Musat It can accept parameters like oeqa.runtime. and it will run all test files from that folder. Signed-off-by: Lucian Musat --- meta/lib/oeqa/runexported.py | 6 ++ 1 file changed, 6 insertions(+) diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py index f147089..c3ce79a 100755 --- a/meta/lib/oeqa/runexported.py +++ b/meta/lib/oeqa/runexported.py @@ -138,6 +138,12 @@ def main(): for test in tc.testslist: print test else: +for index, test in enumerate(tc.testslist): +if os.path.isdir(os.sep.join(test.split('.'))): +del tc.testslist[index] +for files in os.listdir(os.sep.join(test.split('.'))): +if (files.endswith(".py")) and not files.startswith("_"): +tc.testslist.insert(index, test+'.'+files.split('.')[0]) target.exportStart() runTests(tc) -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 06/13] oeqa/testimage: Added support for folder names in TEST_SUITES.
From: Lucian Musat You can add oeqa.runtime. and it will run all the tests found in it. Basically extends the functionality of feature [YOCTO #7834] Signed-off-by: Lucian Musat --- meta/classes/testimage.bbclass | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index 2e963f8..400d16d 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass @@ -143,7 +143,16 @@ def get_tests_list(d, type="runtime"): for testname in testsuites: if testname != "auto": if testname.startswith("oeqa."): -testslist.append(testname) +for p in bbpath: +test_location = os.path.join(p, 'lib', os.sep.join(testname.split('.'))) +if os.path.isfile(test_location+".py") or \ +(os.path.isfile(test_location.rsplit(os.sep, 1)[0]+".py")) or \ +(os.path.isfile(test_location.rsplit(os.sep, 2)[0]+".py")): +testslist.append(testname) +elif os.path.isdir(test_location): +for files in os.listdir(test_location): +if (files.endswith(".py")) and not files.startswith("_"): + testslist.append(testname+'.'+files.split('.')[0]) continue found = False for p in bbpath: -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 05/13] oeqa/runexported: Fix a problem with ssh_target_log symlink.
From: Lucian Musat Signed-off-by: Lucian Musat --- meta/lib/oeqa/runexported.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py index d273d2f..f147089 100755 --- a/meta/lib/oeqa/runexported.py +++ b/meta/lib/oeqa/runexported.py @@ -49,7 +49,7 @@ class FakeTarget(object): def exportStart(self): self.sshlog = os.path.join(self.testdir, "ssh_target_log.%s" % self.datetime) sshloglink = os.path.join(self.testdir, "ssh_target_log") -if os.path.exists(sshloglink): +if os.path.lexists(sshloglink): os.remove(sshloglink) os.symlink(self.sshlog, sshloglink) print("SSH log file: %s" % self.sshlog) -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 04/13] oeqa/runexported: Add option to run arbitrary tests.
From: Lucian Musat You can now overwrite the default TEST_SUITES from the json file and can choose the tests you want to run. Also you can display the list of tests. Signed-off-by: Lucian Musat --- meta/lib/oeqa/runexported.py | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py index dba0d7a..d273d2f 100755 --- a/meta/lib/oeqa/runexported.py +++ b/meta/lib/oeqa/runexported.py @@ -86,6 +86,8 @@ def main(): specified in the json if that directory actually exists or it will error out.") parser.add_argument("-l", "--log-dir", dest="log_dir", help="This sets the path for TEST_LOG_DIR. If not specified \ the current dir is used. This is used for usually creating a ssh log file and a scp test file.") +parser.add_argument("--list-tests", dest="list_tests", help="This lists the current TEST_SUITES that will be run.", action='store_true') +parser.add_argument("-r","--run-tests", dest="run_tests", help="Overwrite TEST_SUITES from the json file with custom list of tests.", nargs = '*') parser.add_argument("json", help="The json file exported by the build system", default="testdata.json", nargs='?') args = parser.parse_args() @@ -129,8 +131,15 @@ def main(): if key != "d" and key != "target" and key != "host_dumper": setattr(tc, key, loaded[key]) -target.exportStart() -runTests(tc) +if args.run_tests: +tc.testslist = args.run_tests + +if args.list_tests: +for test in tc.testslist: +print test +else: +target.exportStart() +runTests(tc) return 0 -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 03/13] utils/decorators.py: add TestNeedsBin() decorator
TestNeedsBin() is used in all tests where binaries are required. It offers functionality to send binaries to DUTs both in unpacked (raw) and in an .rpm form. It is able to handle native binaries, intended for the machine launching tests on DUTs. It also offers functionality for removing DUTs related binaries after finishing the test. Signed-off-by: Costin Constantin --- meta/lib/oeqa/utils/decorators.py | 58 +++ 1 file changed, 58 insertions(+) diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py index 0d79223..a3878ef 100644 --- a/meta/lib/oeqa/utils/decorators.py +++ b/meta/lib/oeqa/utils/decorators.py @@ -12,7 +12,9 @@ import sys import unittest import threading import signal +import re from functools import wraps +import testexport as te #get the "result" object from one of the upper frames provided that one of these upper frames is a unittest.case frame class getResults(object): @@ -260,3 +262,59 @@ def timeout_handler(seconds): else: return fn return decorator + +class TestNeedsBin(object): +""" +This decorator provides binary support for test cases. +Binaries can be versioned. The decorator works with .rpm files and can send +both the rpm or the content of the .rpm to the DUT in the corresponding location +as indicated inside it. When the .rpm file is sent to the DUT, it will be available +in /home/root. +It supports sent files removal after testcase completion. +In case no version is specified for the needed binary, it will take as default +the latest version of the corresponding package. +Future support for .deb and .ipk will be available. +""" +def __init__(self, *args): +self.args = args +self.params_list = list() +self.clean_list = list() +if self.args:# these are tuples of values +for param_tuple in self.args: +bn,bv,t, p,rm_b = ("", "", "", "", "") +for index,value in enumerate(param_tuple): +if index == 0: +bn = value +elif index == 1 and re.match("[0-9]+\.",value): +bv = value +elif value == "rpm": +p = value +elif value == "native": +t = value +elif value == "rm": +rm_b = value +self.params_list.append((bn, bv, p, t, rm_b)) #ensure order of params is as desired + +def deploy_binary(self, params): +from oeqa.oetest import oeRuntimeTest +p = params +if p[3] == "native": +te.process_binaries(oeRuntimeTest.tc.d, params) +else: +status = te.process_binaries(oeRuntimeTest.tc.d, params) +if status: +bin_to_rm = te.send_bin_to_DUT(oeRuntimeTest.tc.d, params) +if bin_to_rm: +self.clean_list.extend(bin_to_rm) + +def __call__(self, func): +def wrapped_f(*args): +for item in set(self.params_list): +self.deploy_binary(item) +func(*args) +te.rm_bin(self.clean_list) # used to remove sent binaries +return +wrapped_f.__name__ = func.__name__ +wrapped_f.args = self.args +return wrapped_f + -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 01/13] oeqa/utils/testexport.py: add functionality for exporting binaries
This new file is encapsulating functionality for both running tests with binaries support via TestNeedsBin() decorator and exporting these binaries via testimage.bbclass file. Addresses [YOCTO #7850], [YOCTO #8478], [YOCTO #8481], [YOCTO #8536], [YOCTO #8694]. Signed-off-by: Costin Constantin --- meta/lib/oeqa/utils/testexport.py | 263 ++ 1 file changed, 263 insertions(+) create mode 100644 meta/lib/oeqa/utils/testexport.py diff --git a/meta/lib/oeqa/utils/testexport.py b/meta/lib/oeqa/utils/testexport.py new file mode 100644 index 000..243463b --- /dev/null +++ b/meta/lib/oeqa/utils/testexport.py @@ -0,0 +1,263 @@ +# Copyright (C) 2015 Intel Corporation +# +# Released under the MIT license (see COPYING.MIT) + +# Provides functions to help with exporting binaries obtained from built targets + +import os, re, glob as g, shutil as sh,sys +from time import sleep +from commands import runCmd +from difflib import SequenceMatcher as SM + +try: +import bb +except ImportError: +class my_log(): +def __init__(self): +pass +def plain(self, msg): +if msg: +print msg +def warn(self, msg): +if msg: +print "WARNING: " + msg +def fatal(self, msg): +if msg: +print "FATAL:" + msg +sys.exit(1) +bb = my_log() + + +def determine_if_poky_env(): +""" +used to determine if we are inside the poky env or not. Usefull for remote machine where poky is not present +""" +check_env = True if ("/scripts" and "/bitbake/bin") in os.getenv("PATH") else False +return check_env + + +def get_dest_folder(tune_features, folder_list): +""" +Function to determine what rpm deploy dir to choose for a given architecture based on TUNE_FEATURES +""" +features_list = tune_features.split(" ") +features_list.reverse() +features_list = "_".join(features_list) +match_rate = 0 +best_match = None +for folder in folder_list: +curr_match_rate = SM(None, folder, features_list).ratio() +if curr_match_rate > match_rate: +match_rate = curr_match_rate +best_match = folder +return best_match + + +def process_binaries(d, params): +param_list = params +export_env = d.getVar("TEST_EXPORT_ONLY") + +def extract_binary(pth_to_pkg, dest_pth=None): +cpio_command = runCmd("which cpio") +rpm2cpio_command = runCmd("ls /usr/bin/rpm2cpio") +if (cpio_command.status != 0) and (rpm2cpio_command.status != 0): +bb.fatal("Either \"rpm2cpio\" or \"cpio\" tools are not available on your system." +"All binaries extraction processes will not be available, crashing all related tests." +"Please install them according to your OS recommendations") # will exit here +if dest_pth: +os.chdir(dest_pth) +else: +os.chdir("%s" % os.sep)# this is for native package +extract_bin_command = runCmd("%s %s | %s -idm" % (rpm2cpio_command.output, pth_to_pkg, cpio_command.output)) # semi-hardcoded because of a bug on poky's rpm2cpio +return extract_bin_command + +if determine_if_poky_env(): # machine with poky environment +exportpath = d.getVar("TEST_EXPORT_DIR", True) if export_env else d.getVar("DEPLOY_DIR", True) +rpm_deploy_dir = d.getVar("DEPLOY_DIR_RPM", True) +arch = get_dest_folder(d.getVar("TUNE_FEATURES", True), os.listdir(rpm_deploy_dir)) +arch_rpm_dir = os.path.join(rpm_deploy_dir, arch) +extracted_bin_dir = os.path.join(exportpath,"binaries", arch, "extracted_binaries") +packaged_bin_dir = os.path.join(exportpath,"binaries", arch, "packaged_binaries") +# creating necessary directory structure in case testing is done in poky env. +if export_env == "0": +if not os.path.exists(extracted_bin_dir): bb.utils.mkdirhier(extracted_bin_dir) +if not os.path.exists(packaged_bin_dir): bb.utils.mkdirhier(packaged_bin_dir) + +if param_list[3] == "native": +if export_env == "1": #this is a native package and we only need to copy it. no need for extraction +native_rpm_dir = os.path.join(rpm_deploy_dir, get_dest_folder("{} nativesdk".format(d.getVar("BUILD_SYS")), os.listdir(rpm_deploy_dir))) +native_rpm_file_list = [item for item in os.listdir(native_rpm_dir) if re.search("nativesdk-" + param_list[0] + "-([0-9]+\.*)", ite
[OE-core] [PATCH 02/13] classes/testimage.bbclass: add support for binaries export
Some test cases require support for target and native binaries. This enhancement is designed to help exporting testing environment for machines where poky/bitbake environment is not available. At the same time, tarball files are created that encapsulate native, target specific and runner related files separatelly. This helps deployment of separate functionality files in their own tarballs. Partial fix for [YOCTO #7850]. Signed-off-by: Costin Constantin --- meta/classes/testimage.bbclass | 74 +- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index 37af46f..2e963f8 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass @@ -1,6 +1,9 @@ # Copyright (C) 2013 Intel Corporation # # Released under the MIT license (see COPYING.MIT) +#from inspect import isclass +#import importlib + # testimage.bbclass enables testing of qemu images using python unittests. @@ -170,7 +173,6 @@ def get_tests_list(d, type="runtime"): bb.debug(2, 'Searching for tests in %s' % testpath) if os.path.exists(testpath): add_auto_list(testpath) - return testslist @@ -263,7 +265,77 @@ def exportTests(d,tc): for f in files: shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/runtime/files")) +#integrating binaries too +# creting needed directory structure +arch = te.get_dest_folder(d.getVar("TUNE_FEATURES", True), os.listdir(d.getVar("DEPLOY_DIR_RPM", True))) +bb.utils.mkdirhier(os.path.join(exportpath,"tar_files")) +bb.utils.mkdirhier(os.path.join(exportpath,"binaries", arch, "packaged_binaries")) +bb.utils.mkdirhier(os.path.join(exportpath,"binaries", "native")) +bb.utils.mkdirhier(os.path.join(exportpath,"binaries", arch, "extracted_binaries")) +with open(os.path.join(exportpath,"binaries",arch, "mapping.cfg"), "a") as mapping_file: +#prepare the needed info for the mapping file +mapping_params = dict() +mapping_params[d.getVar("MACHINE",True)] = (d.getVar("TARGET_SYS",True), d.getVar("TUNE_FEATURES",True)) +mapping_file.write(mapping_params.__str__()) + +populate_binaries(d) + +# create the "runner" tar file, but before that erase them if created in a previous run +[runner_tar, bin_tar, native_tar] = [os.path.join(exportpath,"tar_files", item) for item in ("runner_files.tar", "{}_binaries.tar".format(arch), "native_binaries.tar")] +for item in os.listdir(exportpath): # create the runner tarball +if item not in ('binaries','tar_files'): +create_tar(runner_tar, os.path.join(exportpath,item), item.replace(exportpath, "")) +#create the binaries tar file +for item in os.listdir(os.path.join(exportpath, "binaries")): +if re.search("native", item): # creating native binaries tarfile +create_tar(os.path.join(exportpath,"tar_files", os.path.basename(native_tar)), os.path.join(exportpath,"binaries", "native"), os.path.join("binaries", item.replace(exportpath, ""))) +else: # creating target binaries tar file + create_tar(os.path.join(exportpath,"tar_files",os.path.basename(bin_tar)), os.path.join(exportpath,"binaries", arch), os.path.join("binaries", item.replace(exportpath, ""))) bb.plain("Exported tests to: %s" % exportpath) +for item in os.listdir(exportpath): +if item == "tar_files": +bb.plain("Exported tarballs to: {}".format(exportpath + "/tar_files")) + +def create_tar(tar_fl,file_to_add, a_name=None): +import tarfile as tar +with tar.open(tar_fl,"a") as tar_file: +tar_file.add(file_to_add, arcname=a_name) + +def obtain_binaries(d, param): +""" +this func. will extract binaries based on their version (if required) +""" +import oeqa.utils.testexport as te +te.process_binaries(d, param) # for native packages, this is not extracting binaries, but only copies them + # for a local machine with poky on it the user should build native binaries + +def populate_binaries(d): +from oeqa.oetest import oeRuntimeTest +import importlib, re +testlist = get_tests_list(d) +bin_list = list() +for module in testlist: +test_module = importlib.import_module(module) +for item in vars(test_module).values(): +if isinstance(item, type(oeRuntimeTest)) and issubclass(item, oeRunt
[OE-core] [PATCHv2] scripts/oe-selftest: Add support for selftest log with timestamp
Each time oe-selftest runs, the oe-selftest.log file is overwritten. This patch solves it by adding time stamp to each selftest log file and doing a symlink named as oe-selftest.log to the last one created. Signed-off-by: Costin Constantin --- scripts/oe-selftest | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index bc50b2a..ff3307b 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -31,6 +31,7 @@ import unittest import logging import argparse import subprocess +import time as t sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib') import scriptpath @@ -43,10 +44,14 @@ from oeqa.utils.commands import runCmd, get_bb_var, get_test_layer from oeqa.selftest.base import oeSelfTest def logger_create(): +log_file = "oe-selftest-" + t.strftime("%Y-%m-%d_%H:%M:%S") + ".log" +if os.path.exists("oe-selftest.log"): os.remove("oe-selftest.log") +os.symlink(log_file, "oe-selftest.log") + log = logging.getLogger("selftest") log.setLevel(logging.DEBUG) -fh = logging.FileHandler(filename='oe-selftest.log', mode='w') +fh = logging.FileHandler(filename=log_file, mode='w') fh.setLevel(logging.DEBUG) ch = logging.StreamHandler(sys.stdout) -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] scripts/oe-selftest: Add support for selftest log with timestamp
Each time oe-selftest runs, the oe-selftest.log file is overwritten. This patch solves it by adding time stamp to each selftest log file and doing a symlink named as oe-selftest.log to the last one created. Signed-off-by: Costin Constantin --- scripts/oe-selftest | 5 + 1 file changed, 5 insertions(+) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index bc50b2a..276c7d3 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -31,6 +31,7 @@ import unittest import logging import argparse import subprocess +import time as t sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib') import scriptpath @@ -43,6 +44,10 @@ from oeqa.utils.commands import runCmd, get_bb_var, get_test_layer from oeqa.selftest.base import oeSelfTest def logger_create(): +log_file = "oe-selftest-" + t.strftime("%Y-%m-%d_%H:%M:%S") + ".log" +if os.path.exists("oe-selftest.log"): os.remove("oe-selftest.log") +os.symlink(log_file, "oe-selftest.log") + log = logging.getLogger("selftest") log.setLevel(logging.DEBUG) -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 10/12] oeqa/testimage: Added export features.
From: Lucian Musat It is now possible to export tests from all the layers that are added in bblayers even when grouped in folders. They are exported in another folder called "extralayers" and nicely grouped per layer so the test files won't mingle. If a layer contains a conf/test folder then export that as well. Signed-off-by: Lucian Musat --- meta/classes/testimage.bbclass | 113 ++--- 1 file changed, 96 insertions(+), 17 deletions(-) diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index 40442b7..88aa941 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass @@ -161,6 +161,11 @@ def get_tests_list(d, type="runtime"): testslist.append("oeqa." + type + "." + testname) found = True break +elif os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname.split(".")[0]))\ +and os.path.isdir(os.path.join(p, 'lib', 'oeqa', type, testname.split(".")[0])): +testslist.append("oeqa." + type + "." + testname) +found = True +break if not found: bb.fatal('Test %s specified in TEST_SUITES could not be found in lib/oeqa/runtime under BBPATH' % testname) @@ -182,6 +187,24 @@ def get_tests_list(d, type="runtime"): return testslist +def get_extra_layers(d): +default_layers = ['meta-yocto','meta-yocto-bsp'] +extra_layers = [] + +layer_list = [var for var in d.getVar("BBLAYERS", True).split(" ") if var] + +for layer in layer_list: +if (os.path.basename(os.path.normpath(layer)) not in default_layers)\ +and os.path.exists(os.path.join(layer,"lib","oeqa")): +extra_layers.append(layer) +return extra_layers + +def get_layer(fullpath): +try: +layer = os.path.basename(fullpath.split(os.path.join("lib","oeqa"))[0].rstrip(os.sep)) +except IndexError: +layer = None +return layer def exportTests(d,tc): import json @@ -237,6 +260,13 @@ def exportTests(d,tc): # - __init__.py files bb.utils.mkdirhier(os.path.join(exportpath, "oeqa/runtime/files")) bb.utils.mkdirhier(os.path.join(exportpath, "oeqa/utils")) +if len(get_extra_layers(d)) > 1: +bb.utils.mkdirhier(os.path.join(exportpath, "extralayers")) +for layer in get_extra_layers(d): +if os.path.basename(os.path.normpath(layer)) != "meta": +bb.utils.mkdirhier(os.path.join(exportpath, "extralayers/%s/oeqa/runtime/files" % os.path.basename(os.path.normpath(layer +bb.utils.mkdirhier(os.path.join(exportpath, "extralayers/%s/oeqa/utils" % os.path.basename(os.path.normpath(layer + # copy test modules, this should cover tests in other layers too bbpath = d.getVar("BBPATH", True).split(':') for t in tc.testslist: @@ -244,6 +274,18 @@ def exportTests(d,tc): if re.search("\w+\.\w+\.test_\S+", t): t = '.'.join(t.split('.')[:3]) mod = pkgutil.get_loader(t) +if (str(os.path.join("meta","lib","oeqa")) not in mod.filename): +if get_layer(mod.filename): +layerpath = os.path.join(exportpath, "extralayers", get_layer(mod.filename)) +else: +layerpath = exportpath +else: +layerpath = exportpath + +if os.path.isdir(mod.filename): +isfolder = True +else: +shutil.copy2(mod.filename, os.path.join(layerpath, "oeqa/runtime")) # More depth than usual? if (t.count('.') > 2): for p in bbpath: @@ -253,24 +295,61 @@ def exportTests(d,tc): target_folder = os.path.join(exportpath, "oeqa", "runtime", os.path.basename(foldername)) if not os.path.exists(target_folder): shutil.copytree(foldername, target_folder) -if not isfolder: -shutil.copy2(mod.filename, os.path.join(exportpath, "oeqa/runtime")) +if isfolder: +target_folder = os.path.join(layerpath, "oeqa", "runtime", os.path.basename(mod.filename)) +if not os.path.exists(target_folder): +shutil.copytree(mod.filename, target_folder) + + if not isfolder: +shutil.copy2(mod.filename, os.path.join(layerpath, "oeqa/runtime")) # copy __init__.py files -oeqadir = pkgutil.get_loader("oeqa").filename -shutil.copy2(os.path.join(oeqadir, "__init__.py"), os.path.join(exportpath, "oeqa")) -shutil.copy2(os.path.join(oeqadir, "runtime/__init__.py"), os.path.join(exportpath, "oeqa/runtime")) -# copy oeqa/oetest.py and oeqa/runexported.py -shutil.copy2(os.path.join(oeqadir, "oetest.py"), os.path.join(exportpath, "oeqa")) -shutil.copy2(os.path.join(oeqadir, "runexported.py"), exportpath) -# copy oeqa/utils/*.py -for root, dirs, fil
[OE-core] [PATCH 12/12] buildtools-with-tc.bb: extend buildtools-tarball to include test cases
recipes-core/meta/buildtools-with-tc.bb is a new recipe that uses all buildtools-tarball has to offer and adds test cases support. Signed-off-by: Costin Constantin --- meta/recipes-core/meta/buildtools-with-tc.bb | 37 1 file changed, 37 insertions(+) create mode 100644 meta/recipes-core/meta/buildtools-with-tc.bb diff --git a/meta/recipes-core/meta/buildtools-with-tc.bb b/meta/recipes-core/meta/buildtools-with-tc.bb new file mode 100644 index 000..84a57ee --- /dev/null +++ b/meta/recipes-core/meta/buildtools-with-tc.bb @@ -0,0 +1,37 @@ +DESCRIPTION = "This recipe is used to extend the functionality of buildtools-tarball \ + by adding the test harness plus binaries that might be required for DUTs.\ + " + +require ${COREBASE}/meta/recipes-core/meta/buildtools-tarball.bb +inherit testimage + +SDK_TITLE += "with test cases and binaries" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ + file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" + +TEST_EXPORT_ONLY = "1" +TEST_TARGET = "simpleremote" +IMAGE_NO_MANIFEST = "1" + +addtask testimage before do_populate_sdk + +tar_sdk_prepend () { + mkdir ${SDK_OUTPUT}${SDKPATH}/exported_tests 2>/dev/null + for i in $(ls ${TEST_EXPORT_DIR}) + do +if [ ${i} != "tar_files" ] +then + cp -r ${TEST_EXPORT_DIR}/${i} ${SDK_OUTPUT}${SDKPATH}/exported_tests +fi + done + sed -i 's/\"pkgmanifest\": \"\"/\"pkgmanifest\": \"\\ndropbear\\n\"/' ${SDK_OUTPUT}${SDKPATH}/exported_tests/testdata.json + cp ${SDK_OUTPUT}${SDKPATH}/exported_tests/testdata.json ${TEST_EXPORT_DIR} +} + +create_shar_append () { + message='echo "To run exported tests, go into exported_tests directory and run ./runexported.py"' + sed -i "/exit\ 0/i \ +${message}" ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh +} + -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 02/12] classes/testimage.bbclass: add support for binaries export
Some test cases require support for target and native binaries. This enhancement is designed to help exporting testing environment for machines where poky/bitbake environment is not available. At the same time, tarball files are created that encapsulate native, target specific and runner related files separatelly. This helps deployment of separate functionality files in their own tarballs. Partial fix for [YOCTO #7850]. Signed-off-by: Costin Constantin --- meta/classes/testimage.bbclass | 126 + 1 file changed, 126 insertions(+) diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index e833db4..bcf113f 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass @@ -263,7 +263,133 @@ def exportTests(d,tc): for f in files: shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/runtime/files")) +#integrating binaries too +# creting needed directory structure +arch = te.get_dest_folder(d.getVar("TUNE_FEATURES", True), os.listdir(d.getVar("DEPLOY_DIR_RPM", True))) +bb.utils.mkdirhier(os.path.join(exportpath,"tar_files")) +bb.utils.mkdirhier(os.path.join(exportpath,"binaries", arch, "packaged_binaries")) +bb.utils.mkdirhier(os.path.join(exportpath,"binaries", "native")) +bb.utils.mkdirhier(os.path.join(exportpath,"binaries", arch, "extracted_binaries")) +with open(os.path.join(exportpath,"binaries",arch, "mapping.cfg"), "a") as mapping_file: +#prepare the needed info for the mapping file +mapping_params = dict() +mapping_params[d.getVar("MACHINE",True)] = (d.getVar("TARGET_SYS",True), d.getVar("TUNE_FEATURES",True)) +mapping_file.write(mapping_params.__str__()) + +populate_binaries(d) + +# create the "runner" tar file, but before that erase them if created in a previous run +[runner_tar, bin_tar, native_tar] = [os.path.join(exportpath,"tar_files", item) for item in ("runner_files.tar", "{}_binaries.tar".format(arch), "native_binaries.tar")] +for item in os.listdir(exportpath): # create the runner tarball +if item not in ('binaries','tar_files'): +create_tar(runner_tar, os.path.join(exportpath,item), item.replace(exportpath, "")) +#create the binaries tar file +for item in os.listdir(os.path.join(exportpath, "binaries")): +if re.search("native", item): # creating native binaries tarfile +create_tar(os.path.join(exportpath,"tar_files", os.path.basename(native_tar)), os.path.join(exportpath,"binaries", "native"), os.path.join("binaries", item.replace(exportpath, ""))) +else: # creating target binaries tar file + create_tar(os.path.join(exportpath,"tar_files",os.path.basename(bin_tar)), os.path.join(exportpath,"binaries", arch), os.path.join("binaries", item.replace(exportpath, ""))) bb.plain("Exported tests to: %s" % exportpath) +for item in os.listdir(exportpath): +if item == "tar_files": +bb.plain("Exported tarballs to: {}".format(exportpath + "/tar_files")) + +def create_tar(tar_fl,file_to_add, a_name=None): +import tarfile as tar +with tar.open(tar_fl,"a") as tar_file: +tar_file.add(file_to_add, arcname=a_name) + +def obtain_binaries(d, param): +""" +this func. will extract binaries based on their version (if required) +""" +import oeqa.utils.testexport as te +te.process_binaries(d, param) # for native packages, this is not extracting binaries, but only copies them + # for a local machine with poky on it the user should build native binaries + +def read_test_files(file_pth): +""" +The only way to read what binaries are to be included in the tarball file(s) is to search for each +test file (.py) and see if the decorator TestNeedsBin is present. If yes, just extract the information +from there. The lib/oeqa/runtime dir is taken as default to read files from. The result is a list +containing needed information like binary name, binary, version etc. in a string of values separated +by "_". This aproach was taken because it helps when TestNeedsBin contains multiple binaries and some +are with identical name and different version or when same binary is needed both in extracted and +packaged mode. A dictionary would have eliminated the duplicate same key (in our case binary name) +fields. +""" +import
[OE-core] [PATCH 09/12] oeqa/runexported: Add parameter support for machine arch.
From: Lucian Musat Added support to change machine architecture on the fly and support for future TestNeedsBin decorator for tests that need binaries. Signed-off-by: Lucian Musat Signed-off-by: Costin Constantin --- meta/lib/oeqa/runexported.py | 22 ++ 1 file changed, 22 insertions(+) diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py index b8d621c..3a6bad7 100755 --- a/meta/lib/oeqa/runexported.py +++ b/meta/lib/oeqa/runexported.py @@ -22,6 +22,9 @@ import sys import os import time import argparse +import re + +from oeqa.utils.testsexport import get_dest_folder try: import simplejson as json @@ -88,10 +91,13 @@ def main(): the current dir is used. This is used for usually creating a ssh log file and a scp test file.") parser.add_argument("--list-tests", dest="list_tests", help="This lists the current TEST_SUITES that will be run.", action='store_true') parser.add_argument("-r","--run-tests", dest="run_tests", help="Overwrite TEST_SUITES from the json file with custom list of tests.", nargs = '*') +parser.add_argument("-m","--machine", dest="machine", help="Overwrite MACHINE from the json file ") parser.add_argument("json", help="The json file exported by the build system", default="testdata.json", nargs='?') args = parser.parse_args() +os.environ["bin_dir"] = os.path.join(os.getcwd(), "binaries") # exporting bin_dir path + if os.path.isdir("extralayers"): extrapaths = [x[0] for x in os.walk('extralayers')] for path in extrapaths: @@ -137,6 +143,22 @@ def main(): if key != "d" and key != "target" and key != "host_dumper": setattr(tc, key, loaded[key]) +if args.machine: +d['MACHINE'] = args.machine +bin_dir = os.getenv("bin_dir") +found = False +if os.path.exists(bin_dir): +for item in os.listdir(bin_dir): +if not re.search("native", item) and os.path.exists(os.path.join(bin_dir, item, "mapping.cfg")): +with open(os.path.join(bin_dir, item, "mapping.cfg"), "r") as mapping_file: +mapping = eval(mapping_file.read()) +if args.machine in mapping.keys(): +d['TARGET_SYS'] = mapping[args.machine][0] +d['TUNE_FEATURES'] = mapping[args.machine][1] +found = True +if not found: +print("WARNING: Cannot find binaries for provided machine %s." % args.machine) + if args.run_tests: tc.testslist = args.run_tests -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 04/12] oeqa/runexported: Add option to run arbitrary tests.
From: Lucian Musat You can now overwrite the default TEST_SUITES from the json file and can choose the tests you want to run. Also you can display the list of tests. Signed-off-by: Lucian Musat --- meta/lib/oeqa/runexported.py | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py index dba0d7a..d273d2f 100755 --- a/meta/lib/oeqa/runexported.py +++ b/meta/lib/oeqa/runexported.py @@ -86,6 +86,8 @@ def main(): specified in the json if that directory actually exists or it will error out.") parser.add_argument("-l", "--log-dir", dest="log_dir", help="This sets the path for TEST_LOG_DIR. If not specified \ the current dir is used. This is used for usually creating a ssh log file and a scp test file.") +parser.add_argument("--list-tests", dest="list_tests", help="This lists the current TEST_SUITES that will be run.", action='store_true') +parser.add_argument("-r","--run-tests", dest="run_tests", help="Overwrite TEST_SUITES from the json file with custom list of tests.", nargs = '*') parser.add_argument("json", help="The json file exported by the build system", default="testdata.json", nargs='?') args = parser.parse_args() @@ -129,8 +131,15 @@ def main(): if key != "d" and key != "target" and key != "host_dumper": setattr(tc, key, loaded[key]) -target.exportStart() -runTests(tc) +if args.run_tests: +tc.testslist = args.run_tests + +if args.list_tests: +for test in tc.testslist: +print test +else: +target.exportStart() +runTests(tc) return 0 -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 11/12] oeqa/runtime: Copy all __init__.py files from all layers.
From: Lucian Musat Copy all the __init__.py files from all the extra layers also, specified in bblayers.conf, in accordance to TEST_SUITES variable. Signed-off-by: Lucian Musat --- meta/classes/testimage.bbclass | 67 +++--- meta/lib/oeqa/runexported.py | 2 +- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index 88aa941..83a11ee 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass @@ -211,6 +211,7 @@ def exportTests(d,tc): import shutil import pkgutil import re +import oeqa.utils.testexport as te exportpath = d.getVar("TEST_EXPORT_DIR", True) @@ -300,37 +301,37 @@ def exportTests(d,tc): if not os.path.exists(target_folder): shutil.copytree(mod.filename, target_folder) - if not isfolder: +if not isfolder: shutil.copy2(mod.filename, os.path.join(layerpath, "oeqa/runtime")) -# copy __init__.py files -for _oeqadir in get_extra_layers(d): -oeqadir = os.path.join(_oeqadir,"lib","oeqa") -# copy oeqa/oetest.py and oeqa/runexported.py -if os.path.basename(_oeqadir) == "meta": -layerpath = exportpath -# Make sure we always copy the minimum required files from meta -shutil.copy2(os.path.join(oeqadir, "oetest.py"), os.path.join(layerpath, "oeqa")) -shutil.copy2(os.path.join(oeqadir, "__init__.py"), os.path.join(layerpath, "oeqa")) -shutil.copy2(os.path.join(oeqadir, "runtime", "__init__.py"), os.path.join(layerpath, "oeqa", "runtime")) -shutil.copy2(os.path.join(oeqadir, "runexported.py"), layerpath) -for root, dirs, files in os.walk(os.path.join(oeqadir, "utils")): -for f in files: -if f.endswith(".py"): -shutil.copy2(os.path.join(root, f), os.path.join(layerpath, "oeqa/utils")) -else: -if oeqadir in mod.filename: -layerpath = os.path.join(exportpath, "extralayers", get_layer(mod.filename)) - -try: -if oeqadir in mod.filename: +# copy __init__.py files +for _oeqadir in get_extra_layers(d): +oeqadir = os.path.join(_oeqadir,"lib","oeqa") +# copy oeqa/oetest.py and oeqa/runexported.py +if os.path.basename(_oeqadir) == "meta": +layerpath = exportpath +# Make sure we always copy the minimum required files from meta +shutil.copy2(os.path.join(oeqadir, "oetest.py"), os.path.join(layerpath, "oeqa")) shutil.copy2(os.path.join(oeqadir, "__init__.py"), os.path.join(layerpath, "oeqa")) -except IOError: -pass -try: -if oeqadir in mod.filename: -shutil.copy2(os.path.join(oeqadir, "runtime/__init__.py"), os.path.join(layerpath, "oeqa/runtime")) -except IOError: -pass +shutil.copy2(os.path.join(oeqadir, "runtime", "__init__.py"), os.path.join(layerpath, "oeqa", "runtime")) +shutil.copy2(os.path.join(oeqadir, "runexported.py"), layerpath) +for root, dirs, files in os.walk(os.path.join(oeqadir, "utils")): +for f in files: +if f.endswith(".py"): +shutil.copy2(os.path.join(root, f), os.path.join(layerpath, "oeqa/utils")) +else: +if oeqadir in mod.filename: +layerpath = os.path.join(exportpath, "extralayers", get_layer(mod.filename)) + +try: +if oeqadir in mod.filename: +shutil.copy2(os.path.join(oeqadir, "__init__.py"), os.path.join(layerpath, "oeqa")) +except IOError: +pass +try: +if oeqadir in mod.filename: +shutil.copy2(os.path.join(oeqadir, "runtime/__init__.py"), os.path.join(layerpath, "oeqa/runtime")) +except IOError: +pass # copy oeqa/utils/*.py for root, dirs, files in os.walk(os.path.join(oeqadir, "utils")): for f in files: @@ -347,13 +348,19 @@ def exportTests(d,tc): bb.utils.mkdirhier(os.path.join(exportpath, "conf/test")) else: bb.utils.mkdirhier(os.path.join(exportpath, "extralayers/%s/conf/test" % os.path.basename(os.path.normpath(layer +layerpath = os.path.join(exportpath, "extralayers", os.path.basename(os.path.normpath(layer))) for root, dirs, files in os.walk(os.path.join(_oeqadir, "conf", "test")): for f in files: shutil.copy2(os.path.join(root, f), os.path.join(layerpath, "conf/test")) #integrating binaries too # creting needed directory structure -arch = te.get_des
[OE-core] [PATCH 01/12] oeqa/utils/testexport.py: add functionality for exporting binaries
This new file is encapsulating functionality for both running tests with binaries support via TestNeedsBin() decorator and exporting these binaries via testimage.bbclass file. Addresses [YOCTO #7850], [YOCTO #8478], [YOCTO #8481], [YOCTO #8536], [YOCTO #8694]. Signed-off-by: Costin Constantin --- meta/lib/oeqa/utils/testexport.py | 263 ++ 1 file changed, 263 insertions(+) create mode 100644 meta/lib/oeqa/utils/testexport.py diff --git a/meta/lib/oeqa/utils/testexport.py b/meta/lib/oeqa/utils/testexport.py new file mode 100644 index 000..92b460d --- /dev/null +++ b/meta/lib/oeqa/utils/testexport.py @@ -0,0 +1,263 @@ +# Copyright (C) 2015 Intel Corporation +# +# Released under the MIT license (see COPYING.MIT) + +# Provides functions to help with exporting binaries obtained from built targets + +import os, re, glob as g, shutil as sh,sys +from time import sleep +from commands import runCmd +from difflib import SequenceMatcher as SM + +try: +import bb +except ImportError: +class my_log(): +def __init__(self): +pass +def plain(self, msg): +if msg: +print msg +def warn(self, msg): +if msg: +print "WARNING: " + msg +def fatal(self, msg): +if msg: +print "FATAL:" + msg +sys.exit(1) +bb = my_log() + + +def determine_if_poky_env(): +""" +used to determine if we are inside the poky env or not. Usefull for remote machine where poky is not present +""" +check_env = True if ("/scripts" and "/bitbake/bin") in os.getenv("PATH") else False +return check_env + + +def get_dest_folder(tune_features, folder_list): +""" +Function to determine what rpm deploy dir to choose for a given architecture based on TUNE_FEATURES +""" +features_list = tune_features.split(" ") +features_list.reverse() +features_list = "_".join(features_list) +match_rate = 0 +best_match = None +for folder in folder_list: +curr_match_rate = SM(None, folder, features_list).ratio() +if curr_match_rate > match_rate: +match_rate = curr_match_rate +best_match = folder +return best_match + + +def process_binaries(d, params): +param_list = params.split("_") +export_env = d.getVar("TEST_EXPORT_ONLY") + +def extract_binary(pth_to_pkg, dest_pth=None): +cpio_command = runCmd("which cpio") +rpm2cpio_command = runCmd("ls /usr/bin/rpm2cpio") +if (cpio_command.status != 0) and (rpm2cpio_command.status != 0): +bb.fatal("Either \"rpm2cpio\" or \"cpio\" tools are not available on your system." +"All binaries extraction processes will not be available, crashing all related tests." +"Please install them according to your OS recommendations") # will exit here +if dest_pth: +os.chdir(dest_pth) +else: +os.chdir("%s" % os.sep)# this is for native package +extract_bin_command = runCmd("%s %s | %s -idm" % (rpm2cpio_command.output, pth_to_pkg, cpio_command.output)) # semi-hardcoded because of a bug on poky's rpm2cpio +return extract_bin_command + +if determine_if_poky_env(): # machine with poky environment +exportpath = d.getVar("TEST_EXPORT_DIR", True) if export_env else d.getVar("DEPLOY_DIR", True) +rpm_deploy_dir = d.getVar("DEPLOY_DIR_RPM", True) +arch = get_dest_folder(d.getVar("TUNE_FEATURES", True), os.listdir(rpm_deploy_dir)) +arch_rpm_dir = os.path.join(rpm_deploy_dir, arch) +extracted_bin_dir = os.path.join(exportpath,"binaries", arch, "extracted_binaries") +packaged_bin_dir = os.path.join(exportpath,"binaries", arch, "packaged_binaries") +# creating necessary directory structure in case testing is done in poky env. +if export_env == "0": +if not os.path.exists(extracted_bin_dir): bb.utils.mkdirhier(extracted_bin_dir) +if not os.path.exists(packaged_bin_dir): bb.utils.mkdirhier(packaged_bin_dir) + +if param_list[3] == "native": +if export_env == "1": #this is a native package and we only need to copy it. no need for extraction +native_rpm_dir = os.path.join(rpm_deploy_dir, get_dest_folder("{} nativesdk".format(d.getVar("BUILD_SYS")), os.listdir(rpm_deploy_dir))) +native_rpm_file_list = [item for item in os.listdir(native_rpm_dir) if re.search("nativesdk-" + param_
[OE-core] [PATCH 08/12] oeqa/runexported: The runner supports tests from other layers.
From: Lucian Musat It looks in "extralayers" folder if it can't find the test that needs to be run. Signed-off-by: Lucian Musat --- meta/lib/oeqa/runexported.py | 14 ++ 1 file changed, 14 insertions(+) diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py index c3ce79a..b8d621c 100755 --- a/meta/lib/oeqa/runexported.py +++ b/meta/lib/oeqa/runexported.py @@ -92,6 +92,12 @@ def main(): args = parser.parse_args() +if os.path.isdir("extralayers"): +extrapaths = [x[0] for x in os.walk('extralayers')] +for path in extrapaths: +if os.path.isdir(os.path.join(path,"oeqa")) and (os.path.join(path,"oeqa") not in sys.path): +sys.path.append(os.path.abspath(path)) + with open(args.json, "r") as f: loaded = json.load(f) @@ -144,6 +150,14 @@ def main(): for files in os.listdir(os.sep.join(test.split('.'))): if (files.endswith(".py")) and not files.startswith("_"): tc.testslist.insert(index, test+'.'+files.split('.')[0]) +elif not os.path.isfile(os.path.join(os.sep.join(test.split('.')), '.py')): +for testpath in sys.path: +directory = os.path.join(testpath, os.sep.join(test.split('.'))) +if os.path.isdir(directory): +del tc.testslist[index] +for files in os.listdir(directory): +if (files.endswith(".py")) and not files.startswith("_"): +tc.testslist.insert(index, test+'.'+files.split('.')[0]) target.exportStart() runTests(tc) -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 05/12] oeqa/runexported: Fix a problem with ssh_target_log symlink.
From: Lucian Musat Signed-off-by: Lucian Musat --- meta/lib/oeqa/runexported.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py index d273d2f..f147089 100755 --- a/meta/lib/oeqa/runexported.py +++ b/meta/lib/oeqa/runexported.py @@ -49,7 +49,7 @@ class FakeTarget(object): def exportStart(self): self.sshlog = os.path.join(self.testdir, "ssh_target_log.%s" % self.datetime) sshloglink = os.path.join(self.testdir, "ssh_target_log") -if os.path.exists(sshloglink): +if os.path.lexists(sshloglink): os.remove(sshloglink) os.symlink(self.sshlog, sshloglink) print("SSH log file: %s" % self.sshlog) -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 07/12] oeqa/runexported: Added support for folder names in TEST_SUITES.
From: Lucian Musat It can accept parameters like oeqa.runtime. and it will run all test files from that folder. Signed-off-by: Lucian Musat --- meta/lib/oeqa/runexported.py | 6 ++ 1 file changed, 6 insertions(+) diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py index f147089..c3ce79a 100755 --- a/meta/lib/oeqa/runexported.py +++ b/meta/lib/oeqa/runexported.py @@ -138,6 +138,12 @@ def main(): for test in tc.testslist: print test else: +for index, test in enumerate(tc.testslist): +if os.path.isdir(os.sep.join(test.split('.'))): +del tc.testslist[index] +for files in os.listdir(os.sep.join(test.split('.'))): +if (files.endswith(".py")) and not files.startswith("_"): +tc.testslist.insert(index, test+'.'+files.split('.')[0]) target.exportStart() runTests(tc) -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 00/12] Include binaries in test cases and update runexported.py
The set of patches addresses Yocto binararies inclusion related features and updates to the runexported.py test launcher script for machines where poky environment is not available. As a result runtime test cases can be written to include native and target specific binaries, both packed as .rpm files or pre-unpacked for the situation where the remote target has no package manager. runexported.py includes new functionality. For all the above, enhancements are described in: [YOCTO #7850], [YOCTO #8478], [YOCTO #8479], [YOCTO #8481], [YOCTO #8530] [YOCTO #8534], [YOCTO #8535], [YOCTO #8536] The following changes since commit f1f3716776078d68bd9e3734bca881a486dc2ea3: meta: more removals of redunant FILES_${PN}-dbg (2015-12-16 12:12:18 +) are available in the git repository at: git://git.yoctoproject.org/poky-contrib ciorga/CI2-YOCTO7850 http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=ciorga/CI2-YOCTO7850 Costin Constantin (4): oeqa/utils/testexport.py: add functionality for exporting binaries classes/testimage.bbclass: add support for binaries export utils/decorators.py: add TestNeedsBin() decorator buildtools-with-tc.bb: extend buildtools-tarball to include test cases Lucian Musat (8): oeqa/runexported: Add option to run arbitrary tests. oeqa/runexported: Fix a problem with ssh_target_log symlink. oeqa/testimage: Added support for folder names in TEST_SUITES. oeqa/runexported: Added support for folder names in TEST_SUITES. oeqa/runexported: The runner supports tests from other layers. oeqa/runexported: Add parameter support for machine arch. oeqa/testimage: Added export features. oeqa/runtime: Copy all __init__.py files from all layers. meta/classes/testimage.bbclass | 257 -- meta/lib/oeqa/runexported.py | 57 +- meta/lib/oeqa/utils/decorators.py| 48 + meta/lib/oeqa/utils/testexport.py| 263 +++ meta/recipes-core/meta/buildtools-with-tc.bb | 37 5 files changed, 641 insertions(+), 21 deletions(-) create mode 100644 meta/lib/oeqa/utils/testexport.py create mode 100644 meta/recipes-core/meta/buildtools-with-tc.bb -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 03/12] utils/decorators.py: add TestNeedsBin() decorator
TestNeedsBin() is used in all tests where binaries are required. It offers functionality to send binaries to DUTs both in unpacked (raw) and in an .rpm form. It is able to handle native binaries, intended for the machine launching tests on DUTs. It also offers functionality for removing DUTs related binaries after finishing the test. Signed-off-by: Costin Constantin --- meta/lib/oeqa/utils/decorators.py | 48 +++ 1 file changed, 48 insertions(+) diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py index 0d79223..93a728e 100644 --- a/meta/lib/oeqa/utils/decorators.py +++ b/meta/lib/oeqa/utils/decorators.py @@ -12,7 +12,9 @@ import sys import unittest import threading import signal +import re from functools import wraps +import testexport as te #get the "result" object from one of the upper frames provided that one of these upper frames is a unittest.case frame class getResults(object): @@ -260,3 +262,49 @@ def timeout_handler(seconds): else: return fn return decorator + +class TestNeedsBin(object): +""" +This decorator provides binary support for test cases +""" +def __init__(self, *args): +self.params_list = list() +self. clean_list = list() +if args:# these are tuples of values +for param_tuple in args: +bn,bv,t, p,rm_b = ("", "", "", "", "") +for index,value in enumerate(param_tuple): +if index == 0: +bn = value +elif index == 1 and re.match("[0-9]+\.",value): +bv = value +elif value == "rpm": +p = value +elif value == "native": +t = value +elif value == "rm": +rm_b = value +self.params_list.append("%s_%s_%s_%s_%s" % (bn, bv, p, t, rm_b)) + +def deploy_binary(self, params): +from oeqa.oetest import oeRuntimeTest +p = params.split("_") +if p[3] == "native": +te.process_binaries(oeRuntimeTest.tc.d, params) +else: +status = te.process_binaries(oeRuntimeTest.tc.d, params) +if status: +bin_to_rm = te.send_bin_to_DUT(oeRuntimeTest.tc.d, params) +if bin_to_rm: +self.clean_list.extend(bin_to_rm) + +def __call__(self, func): +def wrapped_f(*args): +for item in set(self.params_list): +self.deploy_binary(item) +func(*args) +te.rm_bin(self.clean_list) # used to remove sent binaries +return +wrapped_f.__name__ = func.__name__ +return wrapped_f + -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 06/12] oeqa/testimage: Added support for folder names in TEST_SUITES.
From: Lucian Musat You can add oeqa.runtime. and it will run all the tests found in it. Basically extends the functionality of feature [YOCTO #7834] Signed-off-by: Lucian Musat --- meta/classes/testimage.bbclass | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index bcf113f..40442b7 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass @@ -140,7 +140,16 @@ def get_tests_list(d, type="runtime"): for testname in testsuites: if testname != "auto": if testname.startswith("oeqa."): -testslist.append(testname) +for p in bbpath: +test_location = os.path.join(p, 'lib', os.sep.join(testname.split('.'))) +if os.path.isfile(test_location+".py") or \ +(os.path.isfile(test_location.rsplit(os.sep, 1)[0]+".py")) or \ +(os.path.isfile(test_location.rsplit(os.sep, 2)[0]+".py")): +testslist.append(testname) +elif os.path.isdir(test_location): +for files in os.listdir(test_location): +if (files.endswith(".py")) and not files.startswith("_"): + testslist.append(testname+'.'+files.split('.')[0]) continue found = False for p in bbpath: -- 2.5.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] scripts/oe-publish-sdk: YP#6659
This patch fixes a small bug that prevents seting a git repo in exported SDK layers dir. Before setting a git repo, that directory needs to be created. Signed-off-by: Costin Constantin --- scripts/oe-publish-sdk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/oe-publish-sdk b/scripts/oe-publish-sdk index 1737c9f..c4c35bd 100755 --- a/scripts/oe-publish-sdk +++ b/scripts/oe-publish-sdk @@ -101,9 +101,9 @@ def publish(args): # Setting up the git repo if not is_remote: -cmd = 'set -e; cd %s/layers; if [ ! -e .git ]; then git init .; mv .git/hooks/post-update.sample .git/hooks/post-update; fi; git add -A .; git commit -q -m "init repo" || true;' % destination +cmd = 'set -e; mkdir -p %s/layers; cd %s/layers; if [ ! -e .git ]; then git init .; mv .git/hooks/post-update.sample .git/hooks/post-update; fi; git add -A .; git commit -q -m "init repo" || true;' % (destination, destination) else: -cmd = "ssh %s 'set -e; cd %s/layers; if [ ! -e .git ]; then git init .; mv .git/hooks/post-update.sample .git/hooks/post-update; fi; git add -A .; git commit -q -m \"init repo\" || true;'" % (host, destdir) +cmd = "ssh %s 'set -e; mkdir-p %s/layers; cd %s/layers; if [ ! -e .git ]; then git init .; mv .git/hooks/post-update.sample .git/hooks/post-update; fi; git add -A .; git commit -q -m \"init repo\" || true;'" % (host, destdir, destdir) ret = subprocess.call(cmd, shell=True) if ret == 0: logger.info('SDK published successfully') -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] utils/decorators.py: TestNeedsBin, decorator for sending binaries to images
TestNeedsBin is a decorator to help deploy binaries to the running image. It uses no package management system. It gets it's source binaries from the rpm built packages found under DEPLOY_DIR_RPM. As mandatory arguments, it requires only the binary name. The binary is sent by default to the DUT's "/usr/bin" dir, making it available in system PATH. Like this, a test should only call the desired binary name without any path. Left to do: - implement support for binaries versioning - accept any source path to a given binaries directory - add a tag - add support for exported tests that will run on remote testing env. without presence of poky related to [Yocto #7850] Signed-off-by: Costin Constantin --- meta/lib/oeqa/utils/decorators.py | 73 +-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py index b9fc76c..a999018 100644 --- a/meta/lib/oeqa/utils/decorators.py +++ b/meta/lib/oeqa/utils/decorators.py @@ -6,13 +6,15 @@ # Most useful is skipUnlessPassed which can be used for # creating dependecies between two test methods. -import os +import os,re import logging import sys import unittest import threading import signal from functools import wraps +import subprocess as s + #get the "result" object from one of the upper frames provided that one of these upper frames is a unittest.case frame class getResults(object): @@ -185,4 +187,71 @@ def timeout(seconds): return wrapped_f else: return fn -return decorator \ No newline at end of file +return decorator + +# this part for the bin <---> test binding +from difflib import SequenceMatcher as SM +def get_dest_folder(tune_features, folder_list): +features_list = tune_features.split(" ") +features_list.reverse() +features_list = "_".join(features_list) +match_rate = 0 +best_match = None +for folder in folder_list: +if SM(None, folder, features_list).ratio() > match_rate: +match_rate = SM(None, folder, features_list).ratio() +best_match = folder +return best_match + + + +class TestNeedsBin(object): + +def __init__(self, bin_name, bin_ver=None, source_dir=None, dest_dir="/usr/bin", TAG=None): +try: +import bb +self.under_bitbake_env = True +except: +self.under_bitbake_env = False +self.bin_name = bin_name +self.bin_ver = bin_ver +self.source_dir = source_dir +self.dest_dir = dest_dir +self.TAG = TAG + +def transfer_bin(self): +from oeqa.oetest import oeRuntimeTest +if self.under_bitbake_env: +if not self.source_dir: +arch_dir = get_dest_folder(oeRuntimeTest.tc.d.getVar("TUNE_FEATURES", True), os.listdir(oeRuntimeTest.tc.d.getVar("DEPLOY_DIR_RPM", True))) +self.source_dir = os.path.join(oeRuntimeTest.tc.d.getVar("DEPLOY_DIR_RPM", True), arch_dir) +if not arch_dir: +bb.warn("cannot find source dir") +for file in os.listdir(self.source_dir): +if re.match("%s-[0-9].*rpm" % self.bin_name, file): +rpm_name = file +local_binary = s.check_output("rpm -qlp %s" % os.path.join(self.source_dir, rpm_name), shell=True).split("\n")[-2] +if local_binary[0] == r'/': +local_binary = local_binary[1:] +if os.path.isfile(os.path.join(self.source_dir, rpm_name)): +command = "/usr/bin/rpm2cpio %s | cpio -idm" % os.path.join(self.source_dir, rpm_name) +s.check_output(command, shell=True) +else: +bb.warn("Cannot find package file to extract!") +if os.path.isfile(local_binary): +(status, output) = oeRuntimeTest.tc.target.copy_to(local_binary, self.dest_dir) +else: +bb.warn("Cannot find binary file!") +if status != 0: +bb.warn("Error at copying binary!") + +else: #when decorator is on the remote machine +#this part will serve when tests are present on remote machine +pass + +def __call__(self, func): +def wrapped_f(*args): +self.transfer_bin() +return func(*args) +wrapped_f.__name__ = func.__name__ +return wrapped_f -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] runtime/syslog.py: fix syslog test crash
This patch fixes the ability to correctly identify syslog's package name for the built image. It is derived from modifying oeqa/oetest.py for [YOCTO #8170] Signed-off-by: Costin Constantin --- meta/lib/oeqa/runtime/syslog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/lib/oeqa/runtime/syslog.py b/meta/lib/oeqa/runtime/syslog.py index dbaf8c6..2601dd9 100644 --- a/meta/lib/oeqa/runtime/syslog.py +++ b/meta/lib/oeqa/runtime/syslog.py @@ -3,7 +3,7 @@ from oeqa.oetest import oeRuntimeTest, skipModule from oeqa.utils.decorators import * def setUpModule(): -if not oeRuntimeTest.hasPackage("syslog"): +if not (oeRuntimeTest.hasPackage("busybox-syslog") or oeRuntimeTest.hasPackage("sysklogd")): skipModule("No syslog package in image") class SyslogTest(oeRuntimeTest): -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/oetest.py: add better pkg. search for hasPackage()
Modified hasPackage() to split the content of pkg. manifest file in containing lines and search at the begining of each line the existance of the needed pkg. [YOCTO #8170] Signed-off-by: Costin Constantin --- meta/lib/oeqa/oetest.py | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py index dfed3de..9bfc76d 100644 --- a/meta/lib/oeqa/oetest.py +++ b/meta/lib/oeqa/oetest.py @@ -99,10 +99,12 @@ class oeTest(unittest.TestCase): @classmethod def hasPackage(self, pkg): - -if re.search(pkg, oeTest.tc.pkgmanifest): -return True -return False +for item in oeTest.tc.pkgmanifest.split('\n'): +if re.match(pkg, item): +return True +break +else: +return False @classmethod def hasFeature(self,feature): -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] selftest/buildoptions.py: correct small mistake cleanupworkdir ---> cleanup-workdir
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index 483803b..655b5da 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -128,7 +128,7 @@ class BuildImagesTest(oeSelfTest): This method is used to test the build of directfb image for arm arch. In essence we build a coreimagedirectfb and test the exitcode of bitbake that in case of success is 0. """ -self.add_command_to_tearDown('cleanupworkdir') +self.add_command_to_tearDown('cleanup-workdir') self.write_config("DISTRO_FEATURES_remove = \"x11\"\nDISTRO_FEATURES_append = \" directfb\"\nMACHINE ??= \"qemuarm\"") res = bitbake("core-image-directfb", ignore_status=True) self.assertEqual(res.status, 0, "\ncoreimagedirectfb failed to build. Please check logs for further details.\nbitbake output %s" % res.output) @@ -139,7 +139,7 @@ class ArchiverTest(oeSelfTest): """ Test for archiving the work directory and exporting the source files. """ -self.add_command_to_tearDown('cleanupworkdir') +self.add_command_to_tearDown('cleanup-workdir') self.write_config("INHERIT = \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"") res = bitbake("xcursor-transparent-theme", ignore_status=True) self.assertEqual(res.status, 0, "\nCouldn't build xcursortransparenttheme.\nbitbake output %s" % res.output) -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/sstatetests.py: add decorator to test_sstate_nativelsbstring_same_hash
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/sstatetests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/meta/lib/oeqa/selftest/sstatetests.py b/meta/lib/oeqa/selftest/sstatetests.py index 2599e0b..6eacb57 100644 --- a/meta/lib/oeqa/selftest/sstatetests.py +++ b/meta/lib/oeqa/selftest/sstatetests.py @@ -240,6 +240,7 @@ BUILD_OS = \"linux\" self.assertItemsEqual(files1, files2) +@testcase(1271) def test_sstate_nativelsbstring_same_hash(self): """ The sstate checksums should be independent of whichever NATIVELSBSTRING is -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/sstatetests.py: add annotator to test_sstate_32_64_same_hash [YOCTO #6006]
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/sstatetests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/meta/lib/oeqa/selftest/sstatetests.py b/meta/lib/oeqa/selftest/sstatetests.py index 9258b53..2599e0b 100644 --- a/meta/lib/oeqa/selftest/sstatetests.py +++ b/meta/lib/oeqa/selftest/sstatetests.py @@ -203,6 +203,7 @@ class SStateTests(SStateBase): target_config.append('') self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic']) +@testcase(1270) def test_sstate_32_64_same_hash(self): """ The sstate checksums for both native and target should not vary whether -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH v3] oeqa/buildoptions.py: automate test case 929: check for correct GPL licenses
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 29 + 1 file changed, 29 insertions(+) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index e79be9e..9ef7776 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -132,6 +132,35 @@ class BuildImagesTest(oeSelfTest): res = bitbake("core-image-directfb", ignore_status=True) self.assertEqual(res.status, 0, "\ncoreimagedirectfb failed to build. Please check logs for further details.\nbitbake output %s" % res.output) +@testcase(929) +def test_gpl_licenses(self): +""" +Test for checking that correct GPL licenses are used when explicitly required. +""" +self.write_config("MACHINE = \"qemux86\"\nINHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nCOPYLEFT_LICENSE_INCLUDE = \"GPLv2* GPLv3*\"") +res = bitbake("core-image-minimal", ignore_status=True) +self.remove_config("MACHINE = \"qemux86\"\nINHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nCOPYLEFT_LICENSE_INCLUDE = \"GPLv2* GPLv3*\"") +self.assertEqual(res.status, 0, "core-image-minimal didn't build. Please check logs for further details %s" % res.output) +built_pkgs_list = os.listdir(self.builddir + "/tmp/deploy/sources/i586-poky-linux/")# the list containing built pkgs with ver. +pkg_name_split = [i.split("-") for i in built_pkgs_list] +pkgs = [] # this will contain the pkgs name as found in tmp/deploy/licenses +for i in pkg_name_split: + name = "" + for j in i: +if i.index(j) == 0: + name = j +elif j.isalpha() and i.index(j) != 0: + name = name + "-" + j +else: + pkgs.append(name) + break +license_dir = self.builddir + "/tmp/deploy/licenses/" +for i in pkgs: + if os.path.isdir(license_dir + i): +self.assertTrue(g.glob(license_dir + i + "/*GPL*"), "couldn't find GPL license in " + license_dir + "for package " + i) + else: +self.log.info("\nNo license dir for %s" % i) + class ArchiverTest(oeSelfTest): @testcase(926) def test_arch_work_dir_and_export_source(self): -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH v2] oeqa/buildoptions.py: automate test case 929: check for correct GPL licenses
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 30 ++ 1 file changed, 30 insertions(+) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index e79be9e..ab009f2 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -132,6 +132,36 @@ class BuildImagesTest(oeSelfTest): res = bitbake("core-image-directfb", ignore_status=True) self.assertEqual(res.status, 0, "\ncoreimagedirectfb failed to build. Please check logs for further details.\nbitbake output %s" % res.output) +@testcase(929) +def test_gpl_licenses(self): +""" +Test for checking that correct GPL licenses are used when explicitly required. +""" +self.add_command_to_tearDown('cleanup-workdir') +self.write_config("MACHINE = \"qemux86\"\nINHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nCOPYLEFT_LICENSE_INCLUDE = \"GPLv2* GPLv3*\"") +res = bitbake("core-image-minimal", ignore_status=True) +self.remove_config("MACHINE = \"qemux86\"\nINHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nCOPYLEFT_LICENSE_INCLUDE = \"GPLv2* GPLv3*\"") +self.assertEqual(res.status, 0, "core-image-minimal didn't build. Please check logs for further details %s" % res.output) +built_pkgs_list = os.listdir(self.builddir + "/tmp/deploy/sources/i586-poky-linux/")# the list containing built pkgs with ver. +pkg_name_split = [i.split("-") for i in built_pkgs_list] +pkgs = [] # this will contain the pkgs name as found in tmp/deploy/licenses +for i in pkg_name_split: + name = "" + for j in i: +if i.index(j) == 0: + name = j +elif j.isalpha() and i.index(j) != 0: + name = name + "-" + j +else: + pkgs.append(name) + break +license_dir = self.builddir + "/tmp/deploy/licenses/" +for i in pkgs: + if os.path.isdir(license_dir + i): +self.assertTrue(g.glob(license_dir + i + "/*GPL*"), "couldn't find GPL license in " + license_dir + "for package " + i) + else: +self.log.info("\nNo license dir for %s" % i) + class ArchiverTest(oeSelfTest): @testcase(926) def test_arch_work_dir_and_export_source(self): -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH v2] oeqa/buildoptions.py: automate test case 926, archive work dir and export source
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 15 +++ 1 file changed, 15 insertions(+) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index 10e4fc5..e79be9e 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -131,3 +131,18 @@ class BuildImagesTest(oeSelfTest): self.write_config("DISTRO_FEATURES_remove = \"x11\"\nDISTRO_FEATURES_append = \" directfb\"\nMACHINE ??= \"qemuarm\"") res = bitbake("core-image-directfb", ignore_status=True) self.assertEqual(res.status, 0, "\ncoreimagedirectfb failed to build. Please check logs for further details.\nbitbake output %s" % res.output) + +class ArchiverTest(oeSelfTest): +@testcase(926) +def test_arch_work_dir_and_export_source(self): +""" +Test for archiving the work directory and exporting the source files. +""" +self.add_command_to_tearDown('cleanupworkdir') +self.write_config("INHERIT = \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"") +res = bitbake("xcursor-transparent-theme", ignore_status=True) +self.assertEqual(res.status, 0, "\nCouldn't build xcursortransparenttheme.\nbitbake output %s" % res.output) +pkgs_path = g.glob(str(self.builddir) + "/tmp/deploy/sources/allarch*/xcurs*") +src_file_glob = str(pkgs_path[0]) + "/xcursor*.src.rpm" +tar_file_glob = str(pkgs_path[0]) + "/xcursor*.tar.gz" +self.assertTrue((g.glob(src_file_glob) and g.glob(tar_file_glob)), "Couldn't find .src.rpm and .tar.gz files under tmp/deploy/sources/allarch*/xcursor*") -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH v2] oeqa/buildoptions.py: automate test case 563; build directfb image
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index 13ec276..10e4fc5 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -2,7 +2,8 @@ import unittest import os import logging import re - +import glob as g +import pexpect as p from oeqa.selftest.base import oeSelfTest from oeqa.selftest.buildhistory import BuildhistoryBase from oeqa.utils.commands import runCmd, bitbake, get_bb_var @@ -119,8 +120,14 @@ class BuildhistoryTests(BuildhistoryBase): self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True) self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error) - - - - - +class BuildImagesTest(oeSelfTest): +@testcase(563) +def test_directfb(self): +""" +This method is used to test the build of directfb image for arm arch. +In essence we build a coreimagedirectfb and test the exitcode of bitbake that in case of success is 0. +""" +self.add_command_to_tearDown('cleanupworkdir') +self.write_config("DISTRO_FEATURES_remove = \"x11\"\nDISTRO_FEATURES_append = \" directfb\"\nMACHINE ??= \"qemuarm\"") +res = bitbake("core-image-directfb", ignore_status=True) +self.assertEqual(res.status, 0, "\ncoreimagedirectfb failed to build. Please check logs for further details.\nbitbake output %s" % res.output) -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/prservice: add useful failure messages to test cases
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/prservice.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/meta/lib/oeqa/selftest/prservice.py b/meta/lib/oeqa/selftest/prservice.py index fb6d68d..4187fbf 100644 --- a/meta/lib/oeqa/selftest/prservice.py +++ b/meta/lib/oeqa/selftest/prservice.py @@ -17,7 +17,7 @@ class BitbakePrTests(oeSelfTest): package_data_file = os.path.join(pkgdata_dir, 'runtime', package_name) package_data = ftools.read_file(package_data_file) find_pr = re.search("PKGR: r[0-9]+\.([0-9]+)", package_data) -self.assertTrue(find_pr) +self.assertTrue(find_pr, "No PKG revision found in %s" % package_data_file) return int(find_pr.group(1)) def get_task_stamp(self, package_name, recipe_task): @@ -60,8 +60,8 @@ class BitbakePrTests(oeSelfTest): stamp_2 = self.get_task_stamp(package_name, track_task) bitbake("-ccleansstate %s" % package_name) -self.assertTrue(pr_2 - pr_1 == 1) -self.assertTrue(stamp_1 != stamp_2) +self.assertTrue(pr_2 - pr_1 == 1, "Step between same pkg. revision is greater than 1") +self.assertTrue(stamp_1 != stamp_2, "Different pkg rev. but same stamp: %s" % stamp_1) def run_test_pr_export_import(self, package_name, replace_current_db=True): self.config_pr_tests(package_name) @@ -86,7 +86,7 @@ class BitbakePrTests(oeSelfTest): pr_2 = self.get_pr_version(package_name) bitbake("-ccleansstate %s" % package_name) -self.assertTrue(pr_2 - pr_1 == 1) +self.assertTrue(pr_2 - pr_1 == 1, "Step between same pkg. revision is greater than 1") @testcase(930) def test_import_export_replace_db(self): -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/recipetool: add useful failure messages to test cases
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/recipetool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meta/lib/oeqa/selftest/recipetool.py b/meta/lib/oeqa/selftest/recipetool.py index 08ff4f1..12c6b25 100644 --- a/meta/lib/oeqa/selftest/recipetool.py +++ b/meta/lib/oeqa/selftest/recipetool.py @@ -50,7 +50,7 @@ class RecipetoolTests(DevtoolBase): bbappendfile = self._check_bbappend(testrecipe, recipefile, templayerdir) # Check the bbappend contents with open(bbappendfile, 'r') as f: -self.assertEqual(expectedlines, f.readlines()) +self.assertEqual(expectedlines, f.readlines(), "Expected lines are not present in %s" % bbappendfile) # Check file was copied filesdir = os.path.join(os.path.dirname(bbappendfile), testrecipe) for expectedfile in expectedfiles: @@ -109,7 +109,7 @@ class RecipetoolTests(DevtoolBase): # But file should have copiedfile = os.path.join(os.path.dirname(bbappendfile), 'coreutils', testfile2name) result = runCmd('diff -q %s %s' % (testfile2, copiedfile), ignore_status=True) -self.assertNotEqual(result.status, 0, 'New file should have been copied but was not') +self.assertNotEqual(result.status, 0, 'New file should have been copied but was not %s' % result.output) @testcase(1178) def test_recipetool_appendfile_binary(self): -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/pkgdata: add useful failure messages to test cases
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/pkgdata.py | 86 +++ 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/meta/lib/oeqa/selftest/pkgdata.py b/meta/lib/oeqa/selftest/pkgdata.py index c4d34bd..138b03a 100644 --- a/meta/lib/oeqa/selftest/pkgdata.py +++ b/meta/lib/oeqa/selftest/pkgdata.py @@ -26,7 +26,7 @@ class OePkgdataUtilTests(oeSelfTest): result = runCmd('oe-pkgdata-util lookup-pkg zlib-dev') self.assertEqual(result.output, 'libz-dev') result = runCmd('oe-pkgdata-util lookup-pkg nonexistentpkg', ignore_status=True) -self.assertEqual(result.status, 1) +self.assertEqual(result.status, 1, "Status different than 1. output: %s" % result.output) self.assertEqual(result.output, 'ERROR: The following packages could not be found: nonexistentpkg') # Reverse tests result = runCmd('oe-pkgdata-util lookup-pkg -r "libc6 busybox"') @@ -34,7 +34,7 @@ class OePkgdataUtilTests(oeSelfTest): result = runCmd('oe-pkgdata-util lookup-pkg -r libz-dev') self.assertEqual(result.output, 'zlib-dev') result = runCmd('oe-pkgdata-util lookup-pkg -r nonexistentpkg', ignore_status=True) -self.assertEqual(result.status, 1) +self.assertEqual(result.status, 1, "Status different than 1. output: %s" % result.output) self.assertEqual(result.output, 'ERROR: The following packages could not be found: nonexistentpkg') @testcase(1205) @@ -43,7 +43,7 @@ class OePkgdataUtilTests(oeSelfTest): self.assertEqual(result.output, 'zlib') result = runCmd('oe-pkgdata-util read-value PKGSIZE bash') pkgsize = int(result.output.strip()) -self.assertGreater(pkgsize, 1) +self.assertGreater(pkgsize, 1, "Size should be greater than 1. %s" % result.output) @testcase(1198) def test_find_path(self): @@ -52,7 +52,7 @@ class OePkgdataUtilTests(oeSelfTest): result = runCmd('oe-pkgdata-util find-path /bin/bash') self.assertEqual(result.output, 'bash: /bin/bash') result = runCmd('oe-pkgdata-util find-path /not/exist', ignore_status=True) -self.assertEqual(result.status, 1) +self.assertEqual(result.status, 1, "Status different than 1. output: %s" % result.output) self.assertEqual(result.output, 'ERROR: Unable to find any package producing path /not/exist') @testcase(1204) @@ -62,7 +62,7 @@ class OePkgdataUtilTests(oeSelfTest): result = runCmd('oe-pkgdata-util lookup-recipe libz-dbg') self.assertEqual(result.output, 'zlib') result = runCmd('oe-pkgdata-util lookup-recipe nonexistentpkg', ignore_status=True) -self.assertEqual(result.status, 1) +self.assertEqual(result.status, 1, "Status different than 1. output: %s" % result.output) self.assertEqual(result.output, 'ERROR: The following packages could not be found: nonexistentpkg') @testcase(1202) @@ -70,13 +70,13 @@ class OePkgdataUtilTests(oeSelfTest): # No arguments result = runCmd('oe-pkgdata-util list-pkgs') pkglist = result.output.split() -self.assertIn('glibc-utils', pkglist) -self.assertIn('zlib-dev', pkglist) +self.assertIn('glibc-utils', pkglist, "Listed packages: %s" % result.output) +self.assertIn('zlib-dev', pkglist, "Listed packages: %s" % result.output) # No pkgspec, runtime result = runCmd('oe-pkgdata-util list-pkgs -r') pkglist = result.output.split() -self.assertIn('libc6-utils', pkglist) -self.assertIn('libz-dev', pkglist) +self.assertIn('libc6-utils', pkglist, "Listed packages: %s" % result.output) +self.assertIn('libz-dev', pkglist, "Listed packages: %s" % result.output) # With recipe specified result = runCmd('oe-pkgdata-util list-pkgs -p zlib') pkglist = sorted(result.output.split()) @@ -84,7 +84,7 @@ class OePkgdataUtilTests(oeSelfTest): pkglist.remove('zlib-ptest') # in case ptest is disabled except ValueError: pass -self.assertEqual(pkglist, ['zlib', 'zlib-dbg', 'zlib-dev', 'zlib-doc', 'zlib-staticdev']) +self.assertEqual(pkglist, ['zlib', 'zlib-dbg', 'zlib-dev', 'zlib-doc', 'zlib-staticdev'], "Packages listed after remove: %s" % result.output) # With recipe specified, runtime result = ru
[OE-core] [PATCH] oeqa/devtool: add useful failure messages for some test cases
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/devtool.py | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index ab412b6..21cd7f5 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -95,14 +95,14 @@ class DevtoolTests(DevtoolBase): tempdir = tempfile.mkdtemp(prefix='devtoolqa') self.track_for_cleanup(tempdir) result = runCmd('devtool create-workspace %s' % tempdir) -self.assertTrue(os.path.isfile(os.path.join(tempdir, 'conf', 'layer.conf'))) +self.assertTrue(os.path.isfile(os.path.join(tempdir, 'conf', 'layer.conf')), msg = "No workspace created. devtool output: %s " % result.output) result = runCmd('bitbake-layers show-layers') self.assertIn(tempdir, result.output) # Try creating a workspace layer with the default path self.track_for_cleanup(workspacedir) self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') result = runCmd('devtool create-workspace') -self.assertTrue(os.path.isfile(os.path.join(workspacedir, 'conf', 'layer.conf'))) +self.assertTrue(os.path.isfile(os.path.join(workspacedir, 'conf', 'layer.conf')), msg = "No workspace created. devtool output: %s " % result.output) result = runCmd('bitbake-layers show-layers') self.assertNotIn(tempdir, result.output) self.assertIn(workspacedir, result.output) @@ -170,9 +170,10 @@ class DevtoolTests(DevtoolBase): bitbake('libftdi -c cleansstate') # Test devtool build result = runCmd('devtool build libftdi') +self.add_command_to_tearDown('bitbake -c cleansstate libftdi') staging_libdir = get_bb_var('STAGING_LIBDIR', 'libftdi') self.assertTrue(staging_libdir, 'Could not query STAGING_LIBDIR variable') -self.assertTrue(os.path.isfile(os.path.join(staging_libdir, 'libftdi1.so.2.1.0')), 'libftdi binary not found in STAGING_LIBDIR') +self.assertTrue(os.path.isfile(os.path.join(staging_libdir, 'libftdi1.so.2.1.0')), "libftdi binary not found in STAGING_LIBDIR. Output of devtool build libftdi %s" % result.output) # Test devtool reset stampprefix = get_bb_var('STAMP', 'libftdi') result = runCmd('devtool reset libftdi') @@ -200,7 +201,7 @@ class DevtoolTests(DevtoolBase): self.add_command_to_tearDown('bitbake -c cleansstate %s' % testrecipe) self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') result = runCmd('devtool add %s %s -f %s' % (testrecipe, srcdir, url)) -self.assertTrue(os.path.exists(os.path.join(workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created') +self.assertTrue(os.path.exists(os.path.join(workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created. %s' % result.output) self.assertTrue(os.path.isfile(os.path.join(srcdir, 'setup.py')), 'Unable to find setup.py in source directory') # Test devtool status result = runCmd('devtool status') @@ -247,7 +248,7 @@ class DevtoolTests(DevtoolBase): self.add_command_to_tearDown('bitbake -c cleansstate %s' % testrecipe) self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') result = runCmd('devtool add %s %s -f %s' % (testrecipe, srcdir, url)) -self.assertTrue(os.path.exists(os.path.join(workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created') +self.assertTrue(os.path.exists(os.path.join(workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created: %s' % result.output) self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure.ac')), 'Unable to find configure.ac in source directory') # Test devtool status result = runCmd('devtool status') @@ -300,7 +301,7 @@ class DevtoolTests(DevtoolBase): self.assertTrue(os.path.isdir(os.path.join(tempdir, '.git')), 'git repository for external source tree not found') self.assertTrue(os.path.exists(os.path.join(workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created') matches = glob.glob(os.path.join(workspacedir, 'appends', 'mdadm_*.bbappend')) -self.assertTrue(matches,
[OE-core] [PATCH 1/3] oeqa/bbtests: add useful failure messages for all test cases
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/bbtests.py | 58 --- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/meta/lib/oeqa/selftest/bbtests.py b/meta/lib/oeqa/selftest/bbtests.py index 7df6b2f..3d6860f 100644 --- a/meta/lib/oeqa/selftest/bbtests.py +++ b/meta/lib/oeqa/selftest/bbtests.py @@ -14,14 +14,14 @@ class BitbakeTests(oeSelfTest): @testcase(789) def test_run_bitbake_from_dir_1(self): os.chdir(os.path.join(self.builddir, 'conf')) -bitbake('-e') +self.assertEqual(bitbake('-e').status, 0, msg = "bitbake couldn't run from \"conf\" dir") @testcase(790) def test_run_bitbake_from_dir_2(self): my_env = os.environ.copy() my_env['BBPATH'] = my_env['BUILDDIR'] os.chdir(os.path.dirname(os.environ['BUILDDIR'])) -bitbake('-e', env=my_env) +self.assertEqual(bitbake('-e', env=my_env).status, 0, msg = "bitbake couldn't run from builddir") @testcase(806) def test_event_handler(self): @@ -31,7 +31,7 @@ class BitbakeTests(oeSelfTest): find_build_completed = re.search("Tasks Summary:.*(\n.*)*NOTE: Test for bb\.event\.BuildCompleted", result.output) self.assertTrue(find_build_started, msg = "Match failed in:\n%s" % result.output) self.assertTrue(find_build_completed, msg = "Match failed in:\n%s" % result.output) -self.assertFalse('Test for bb.event.InvalidEvent' in result.output) +self.assertFalse('Test for bb.event.InvalidEvent' in result.output, msg = "\"Test for bb.event.InvalidEvent\" message found during bitbake process. bitbake output: %s" % result.output) @testcase(103) def test_local_sstate(self): @@ -40,17 +40,17 @@ class BitbakeTests(oeSelfTest): bitbake('m4-native -cclean') result = bitbake('m4-native') find_setscene = re.search("m4-native.*do_.*_setscene", result.output) -self.assertTrue(find_setscene) +self.assertTrue(find_setscene, msg = "No \"m4-native.*do_.*_setscene\" message found during bitbake m4-native. bitbake output: %s" % result.output ) @testcase(105) def test_bitbake_invalid_recipe(self): result = bitbake('-b asdf', ignore_status=True) -self.assertTrue("ERROR: Unable to find any recipe file matching 'asdf'" in result.output) +self.assertTrue("ERROR: Unable to find any recipe file matching 'asdf'" in result.output, msg = "Though asdf recipe doesn't exist, bitbake didn't output any err. message. bitbake output: %s" % result.output) @testcase(107) def test_bitbake_invalid_target(self): result = bitbake('asdf', ignore_status=True) -self.assertTrue("ERROR: Nothing PROVIDES 'asdf'" in result.output) +self.assertTrue("ERROR: Nothing PROVIDES 'asdf'" in result.output, msg = "Though no 'asdf' target exists, bitbake didn't output any err. message. bitbake output: %s" % result.output) @testcase(106) def test_warnings_errors(self): @@ -66,7 +66,7 @@ class BitbakeTests(oeSelfTest): result = bitbake('man -c patch', ignore_status=True) self.delete_recipeinc('man') bitbake('-cclean man') -self.assertTrue("ERROR: Function failed: patch_do_patch" in result.output) +self.assertTrue("ERROR: Function failed: patch_do_patch" in result.output, msg = "Though no man-1.5h1-make.patch file exists, bitbake didn't output any err. message. bitbake output: %s" % result.output) @testcase(163) def test_force_task(self): @@ -76,15 +76,15 @@ class BitbakeTests(oeSelfTest): look_for_tasks = ['do_compile', 'do_install', 'do_populate_sysroot'] for task in look_for_tasks: find_task = re.search("m4-native.*%s" % task, result.output) -self.assertTrue(find_task) +self.assertTrue(find_task, msg = "Couldn't find %s task. bitbake output %s" % (task, result.output)) @testcase(167) def test_bitbake_g(self): result = bitbake('-g core-image-full-cmdline') -self.assertTrue('NOTE: PN build list saved to \'pn-buildlist\'' in result.output) -self.assertTrue('openssh' in ftools.read_file(os.path.join(self.builddir, 'pn-buildlist'))) for f in ['pn-buildlist', 'pn-depends.dot', 'package-depends.dot', 'task-depends.dot']: -
[OE-core] [PATCH 3/3] oeqa/buildoptions: add useful failure messages for all test cases
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index 926ffe9..13ec276 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -44,18 +44,18 @@ class ImageOptionsTests(oeSelfTest): bitbake("-C rootfs core-image-minimal") deploydir_files = os.listdir(deploydir) remaining_not_expected = [path for path in track_original_files if os.path.basename(path) in deploydir_files] -self.assertFalse(remaining_not_expected, msg="\nThe following image files ware not removed: %s" % ', '.join(map(str, remaining_not_expected))) +self.assertFalse(remaining_not_expected, msg="\nThe following image files were not removed: %s" % ', '.join(map(str, remaining_not_expected))) @testcase(286) def test_ccache_tool(self): bitbake("ccache-native") - self.assertTrue(os.path.isfile(os.path.join(get_bb_var('STAGING_BINDIR_NATIVE', 'ccache-native'), "ccache"))) + self.assertTrue(os.path.isfile(os.path.join(get_bb_var('STAGING_BINDIR_NATIVE', 'ccache-native'), "ccache")), msg = "No ccache found under %s" % str(get_bb_var('STAGING_BINDIR_NATIVE', 'ccache-native'))) self.write_config('INHERIT += "ccache"') bitbake("m4 -c cleansstate") bitbake("m4 -c compile") +self.addCleanup(bitbake, 'ccache-native -ccleansstate') res = runCmd("grep ccache %s" % (os.path.join(get_bb_var("WORKDIR","m4"),"temp/log.do_compile")), ignore_status=True) -self.assertEqual(0, res.status, msg="No match for ccache in m4 log.do_compile") -bitbake("ccache-native -ccleansstate") +self.assertEqual(0, res.status, msg="No match for ccache in m4 log.do_compile. For further details: %s" % os.path.join(get_bb_var("WORKDIR","m4"),"temp/log.do_compile")) class DiskMonTest(oeSelfTest): @@ -64,15 +64,15 @@ class DiskMonTest(oeSelfTest): def test_stoptask_behavior(self): self.write_config('BB_DISKMON_DIRS = "STOPTASKS,${TMPDIR},10G,100K"') res = bitbake("m4", ignore_status = True) -self.assertTrue('ERROR: No new tasks can be executed since the disk space monitor action is "STOPTASKS"!' in res.output) -self.assertEqual(res.status, 1) +self.assertTrue('ERROR: No new tasks can be executed since the disk space monitor action is "STOPTASKS"!' in res.output, msg = "Tasks should have stopped. Disk monitor is set to STOPTASK: %s" % res.output) +self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output)) self.write_config('BB_DISKMON_DIRS = "ABORT,${TMPDIR},10G,100K"') res = bitbake("m4", ignore_status = True) -self.assertTrue('ERROR: Immediately abort since the disk space monitor action is "ABORT"!' in res.output) -self.assertEqual(res.status, 1) +self.assertTrue('ERROR: Immediately abort since the disk space monitor action is "ABORT"!' in res.output, "Tasks should have been aborted immediatelly. Disk monitor is set to ABORT: %s" % res.output) +self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output)) self.write_config('BB_DISKMON_DIRS = "WARN,${TMPDIR},10G,100K"') res = bitbake("m4") -self.assertTrue('WARNING: The free space' in res.output) +self.assertTrue('WARNING: The free space' in res.output, msg = "A warning should have been displayed for disk monitor is set to WARN: %s" %res.output) class SanityOptionsTest(oeSelfTest): @@ -87,7 +87,7 @@ class SanityOptionsTest(oeSelfTest): res = bitbake("xcursor-transparent-theme", ignore_status=True) self.delete_recipeinc('xcursor-transparent-theme') self.assertTrue("ERROR: QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors." in res.output, msg=res.output) -self.assertEqual(res.status, 1) +self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
[OE-core] [PATCH 2/3] oeqa/bblayers.py: add useful failure messages to all test cases
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/bblayers.py | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/meta/lib/oeqa/selftest/bblayers.py b/meta/lib/oeqa/selftest/bblayers.py index bf3dd1b..20c17e4 100644 --- a/meta/lib/oeqa/selftest/bblayers.py +++ b/meta/lib/oeqa/selftest/bblayers.py @@ -14,49 +14,49 @@ class BitbakeLayers(oeSelfTest): @testcase(756) def test_bitbakelayers_showcrossdepends(self): result = runCmd('bitbake-layers show-cross-depends') -self.assertTrue('aspell' in result.output) +self.assertTrue('aspell' in result.output, msg = "No dependencies were shown. bitbake-layers show-cross-depends output: %s" % result.output) @testcase(83) def test_bitbakelayers_showlayers(self): result = runCmd('bitbake-layers show-layers') -self.assertTrue('meta-selftest' in result.output) +self.assertTrue('meta-selftest' in result.output, msg = "No layers were shown. bitbake-layers show-layers output: %s" % result.output) @testcase(93) def test_bitbakelayers_showappends(self): result = runCmd('bitbake-layers show-appends') -self.assertTrue('xcursor-transparent-theme_0.1.1.bbappend' in result.output, msg='xcursor-transparent-theme_0.1.1.bbappend file was not recognised') +self.assertTrue('xcursor-transparent-theme_0.1.1.bbappend' in result.output, msg="xcursor-transparent-theme_0.1.1.bbappend file was not recognised. bitbake-layers show-appends output: %s" % result.output) @testcase(90) def test_bitbakelayers_showoverlayed(self): result = runCmd('bitbake-layers show-overlayed') -self.assertTrue('aspell' in result.output, msg='aspell overlayed recipe was not recognised') +self.assertTrue('aspell' in result.output, msg="aspell overlayed recipe was not recognised bitbake-layers show-overlayed %s" % result.output) @testcase(95) def test_bitbakelayers_flatten(self): testoutdir = os.path.join(self.builddir, 'test_bitbakelayers_flatten') -self.assertFalse(os.path.isdir(testoutdir)) +self.assertFalse(os.path.isdir(testoutdir), msg = "test_bitbakelayers_flatten should not exist at this point in time") self.track_for_cleanup(testoutdir) result = runCmd('bitbake-layers flatten %s' % testoutdir) bb_file = os.path.join(testoutdir, 'recipes-graphics/xcursor-transparent-theme/xcursor-transparent-theme_0.1.1.bb') -self.assertTrue(os.path.isfile(bb_file)) +self.assertTrue(os.path.isfile(bb_file), msg = "Cannot find xcursor-transparent-theme_0.1.1.bb in the test_bitbakelayers_flatten local dir.") contents = ftools.read_file(bb_file) find_in_contents = re.search("# bbappended from meta-selftest #\n(.*\n)*include test_recipe.inc", contents) -self.assertTrue(find_in_contents) +self.assertTrue(find_in_contents, msg = "Flattening layers did not work. bitbake-layers flatten output: %s" % result.output) @testcase(1195) def test_bitbakelayers_add_remove(self): test_layer = os.path.join(get_bb_var('COREBASE'), 'meta-skeleton') result = runCmd('bitbake-layers show-layers') -self.assertNotIn('meta-skeleton', result.output, 'This test cannot run with meta-skeleton in bblayers.conf') +self.assertNotIn('meta-skeleton', result.output, "This test cannot run with meta-skeleton in bblayers.conf. bitbake-layers show-layers output: %s" % result.output) result = runCmd('bitbake-layers add-layer %s' % test_layer) result = runCmd('bitbake-layers show-layers') -self.assertIn('meta-skeleton', result.output) +self.assertIn('meta-skeleton', result.output, msg = "Something wrong happened. meta-skeleton layer was not added to conf/bblayers.conf. bitbake-layers show-layers output: %s" % result.output) result = runCmd('bitbake-layers remove-layer %s' % test_layer) result = runCmd('bitbake-layers show-layers') -self.assertNotIn('meta-skeleton', result.output) +self.assertNotIn('meta-skeleton', result.output, msg = "meta-skeleton should have been removed at this step. bitbake-layers show-layers output: %s" % result.output) result = runCmd('bitbake-layers add-layer %s' % test_layer) result = runCmd('bitbake-layers show-layers') -self.assertIn('meta-skeleton', result.output) +self.assertIn('meta-skeleton', result
[OE-core] [PATCH] oeqa/bblayers.py: Show useful failure msg. for all test cases
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/bblayers.py | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/meta/lib/oeqa/selftest/bblayers.py b/meta/lib/oeqa/selftest/bblayers.py index bf3dd1b..6a9c097 100644 --- a/meta/lib/oeqa/selftest/bblayers.py +++ b/meta/lib/oeqa/selftest/bblayers.py @@ -14,12 +14,12 @@ class BitbakeLayers(oeSelfTest): @testcase(756) def test_bitbakelayers_showcrossdepends(self): result = runCmd('bitbake-layers show-cross-depends') -self.assertTrue('aspell' in result.output) +self.assertTrue('aspell' in result.output, msg = "No dependencies were shown. To debug, please manually run \"bitbake-layers show-cross-depends\"") @testcase(83) def test_bitbakelayers_showlayers(self): result = runCmd('bitbake-layers show-layers') -self.assertTrue('meta-selftest' in result.output) +self.assertTrue('meta-selftest' in result.output, msg = "No layers were shown. Please check your conf/bblayers.conf and run \"bitbake-layers show-layers\"") @testcase(93) def test_bitbakelayers_showappends(self): @@ -34,14 +34,14 @@ class BitbakeLayers(oeSelfTest): @testcase(95) def test_bitbakelayers_flatten(self): testoutdir = os.path.join(self.builddir, 'test_bitbakelayers_flatten') -self.assertFalse(os.path.isdir(testoutdir)) +self.assertFalse(os.path.isdir(testoutdir), msg = "test_bitbakelayers_flatten should not exist at this point in time") self.track_for_cleanup(testoutdir) result = runCmd('bitbake-layers flatten %s' % testoutdir) bb_file = os.path.join(testoutdir, 'recipes-graphics/xcursor-transparent-theme/xcursor-transparent-theme_0.1.1.bb') -self.assertTrue(os.path.isfile(bb_file)) +self.assertTrue(os.path.isfile(bb_file), msg = "Cannot find xcursor-transparent-theme_0.1.1.bb in the test_bitbakelayers_flatten local dir.") contents = ftools.read_file(bb_file) find_in_contents = re.search("# bbappended from meta-selftest #\n(.*\n)*include test_recipe.inc", contents) -self.assertTrue(find_in_contents) +self.assertTrue(find_in_contents, msg = "Flattening layers did not work.") @testcase(1195) def test_bitbakelayers_add_remove(self): @@ -50,13 +50,13 @@ class BitbakeLayers(oeSelfTest): self.assertNotIn('meta-skeleton', result.output, 'This test cannot run with meta-skeleton in bblayers.conf') result = runCmd('bitbake-layers add-layer %s' % test_layer) result = runCmd('bitbake-layers show-layers') -self.assertIn('meta-skeleton', result.output) +self.assertIn('meta-skeleton', result.output, msg = "Something wrong happened. meta-skeleton layer was not added to conf/bblayers.conf") result = runCmd('bitbake-layers remove-layer %s' % test_layer) result = runCmd('bitbake-layers show-layers') -self.assertNotIn('meta-skeleton', result.output) +self.assertNotIn('meta-skeleton', result.output, msg = "meta-skeleton should have been removed at this step.") result = runCmd('bitbake-layers add-layer %s' % test_layer) result = runCmd('bitbake-layers show-layers') -self.assertIn('meta-skeleton', result.output) +self.assertIn('meta-skeleton', result.output, msg = "Something wrong happened. meta-skeleton layer was not added to conf/bblayers.conf") result = runCmd('bitbake-layers remove-layer */meta-skeleton') result = runCmd('bitbake-layers show-layers') -self.assertNotIn('meta-skeleton', result.output) +self.assertNotIn('meta-skeleton', result.output, msg = "meta-skeleton should have been removed at this step.") -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/bbtests: Show useful failure message for all auto-tests
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/bbtests.py | 54 --- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/meta/lib/oeqa/selftest/bbtests.py b/meta/lib/oeqa/selftest/bbtests.py index 7df6b2f..8301790 100644 --- a/meta/lib/oeqa/selftest/bbtests.py +++ b/meta/lib/oeqa/selftest/bbtests.py @@ -14,14 +14,14 @@ class BitbakeTests(oeSelfTest): @testcase(789) def test_run_bitbake_from_dir_1(self): os.chdir(os.path.join(self.builddir, 'conf')) -bitbake('-e') +self.assertEqual(bitbake('-e').status, 0, msg = "bitbake couldn't run from \"conf\" dir") @testcase(790) def test_run_bitbake_from_dir_2(self): my_env = os.environ.copy() my_env['BBPATH'] = my_env['BUILDDIR'] os.chdir(os.path.dirname(os.environ['BUILDDIR'])) -bitbake('-e', env=my_env) +self.assertEqual(bitbake('-e', env=my_env).status, 0, msg = "bitbake couldn't run from builddir") @testcase(806) def test_event_handler(self): @@ -31,7 +31,7 @@ class BitbakeTests(oeSelfTest): find_build_completed = re.search("Tasks Summary:.*(\n.*)*NOTE: Test for bb\.event\.BuildCompleted", result.output) self.assertTrue(find_build_started, msg = "Match failed in:\n%s" % result.output) self.assertTrue(find_build_completed, msg = "Match failed in:\n%s" % result.output) -self.assertFalse('Test for bb.event.InvalidEvent' in result.output) +self.assertFalse('Test for bb.event.InvalidEvent' in result.output, msg = "\"Test for bb.event.InvalidEvent\" message found during bitbake process") @testcase(103) def test_local_sstate(self): @@ -40,17 +40,17 @@ class BitbakeTests(oeSelfTest): bitbake('m4-native -cclean') result = bitbake('m4-native') find_setscene = re.search("m4-native.*do_.*_setscene", result.output) -self.assertTrue(find_setscene) +self.assertTrue(find_setscene, msg = "No \"m4-native.*do_.*_setscene\" message found during bitbake m4-native") @testcase(105) def test_bitbake_invalid_recipe(self): result = bitbake('-b asdf', ignore_status=True) -self.assertTrue("ERROR: Unable to find any recipe file matching 'asdf'" in result.output) +self.assertTrue("ERROR: Unable to find any recipe file matching 'asdf'" in result.output, msg = "Though asdf recipe doesn't exist, bitbake didn't output any err. message.") @testcase(107) def test_bitbake_invalid_target(self): result = bitbake('asdf', ignore_status=True) -self.assertTrue("ERROR: Nothing PROVIDES 'asdf'" in result.output) +self.assertTrue("ERROR: Nothing PROVIDES 'asdf'" in result.output, msg = "Though no 'asdf' target exists, bitbake didn't output any err. message.") @testcase(106) def test_warnings_errors(self): @@ -66,7 +66,7 @@ class BitbakeTests(oeSelfTest): result = bitbake('man -c patch', ignore_status=True) self.delete_recipeinc('man') bitbake('-cclean man') -self.assertTrue("ERROR: Function failed: patch_do_patch" in result.output) +self.assertTrue("ERROR: Function failed: patch_do_patch" in result.output, msg = "Though no man-1.5h1-make.patch file exists, bitbake didn't output any err. message.") @testcase(163) def test_force_task(self): @@ -76,15 +76,15 @@ class BitbakeTests(oeSelfTest): look_for_tasks = ['do_compile', 'do_install', 'do_populate_sysroot'] for task in look_for_tasks: find_task = re.search("m4-native.*%s" % task, result.output) -self.assertTrue(find_task) +self.assertTrue(find_task, msg = "Couldn't find %s task" % task) @testcase(167) def test_bitbake_g(self): result = bitbake('-g core-image-full-cmdline') -self.assertTrue('NOTE: PN build list saved to \'pn-buildlist\'' in result.output) -self.assertTrue('openssh' in ftools.read_file(os.path.join(self.builddir, 'pn-buildlist'))) for f in ['pn-buildlist', 'pn-depends.dot', 'package-depends.dot', 'task-depends.dot']: -os.remove(f) +self.addCleanup(os.remove, f) +self.assertTrue('NOTE: PN build list saved to \'pn-buildlist\'' in result.output, msg = "No dependency \"pn-buildlist\&q
[OE-core] [PATCH] meta/lib/oeqa/selftest/wic.py: dynamic BSP name loading + small typo
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/wic.py | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py index 358f09e..45abd3b 100644 --- a/meta/lib/oeqa/selftest/wic.py +++ b/meta/lib/oeqa/selftest/wic.py @@ -52,7 +52,7 @@ class Wic(oeSelfTest): def test02_createhelp(self): """Test wic create --help""" -self.assertEqual(0, runCmd('wic creat --help').status) +self.assertEqual(0, runCmd('wic create --help').status) def test03_listhelp(self): """Test wic list --help""" @@ -66,12 +66,18 @@ class Wic(oeSelfTest): def test05_build_artifacts(self): """Test wic create directdisk providing all artifacts.""" -self.assertEqual(0, runCmd("wic create directdisk " - "-b tmp/sysroots/qemux86/usr/share " - "-k tmp/deploy/images/qemux86 " - "-n tmp/sysroots/x86_64-linux " - "-r tmp/work/qemux86-poky-linux/" - "core-image-minimal/1.0-r0/rootfs").status) +self.append_config("wic_test_var = \"${MACHINE}\"") +self.machine_name = runCmd("bitbake -e | egrep '^wic_test_var='").output +self.machine_name = self.machine_name.replace("-","_") +self.machine_name = self.machine_name.split('"')[1] +self.wic_command = "wic create directdisk \ +-b tmp/sysroots/qemux86/usr/share \ +-k tmp/deploy/images/qemux86 \ +-n tmp/sysroots/x86_64-linux \ +-r tmp/work/" + self.machine_name + \ +"-poky-linux/core-image-minimal/1.0-r0/rootfs" +self.wic_command = " ".join(self.wic_command.split()) +self.assertEqual(0, runCmd(self.wic_command).status) self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) def test06_gpt_image(self): -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] scripts/oe-selftest: enhancement 7865
Signed-off-by: Costin Constantin --- scripts/oe-selftest | 36 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index a04e9fc..1a89c31 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -16,7 +16,10 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # DESCRIPTION -# This script runs tests defined in meta/lib/selftest/ +# This script runs tests defined in meta/lib/selftest/ for all $BUILDDIR/../meta* layers +# In order to work, each meta* layer needs to have a relative lib/oeqa/selftest path to it. +# Subdirectories to this relative path are accepted. +# Test module names need to be unique between all layers. # It's purpose is to automate the testing of different bitbake tools. # To use it you just need to source your build environment setup script and # add the meta-selftest layer to your BBLAYERS. @@ -24,15 +27,26 @@ # Call the script as: "oe-selftest .." to run just a single test # E.g: "oe-selftest bboutput.BitbakeLayers" will run just the BitbakeLayers class from meta/lib/selftest/bboutput.py - import os import sys import unittest import logging import argparse +import glob as g sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'meta/lib'))) +tests_path = g.glob(os.path.abspath(os.path.join(os.getenv("BUILDDIR"), "..", "meta*/lib/oeqa/selftest"))) +# adding tests paths to the sys.path enabling dynamic import further on +# support for subdirectories is also added +test_subdirs = [] +for pth in tests_path: +sys.path.insert(0, pth) +for sbd in g.glob(pth + "/*"): +if os.path.isdir(sbd): +sys.path.append(sbd) +test_subdirs.append(sbd) + import oeqa.selftest import oeqa.utils.ftools as ftools from oeqa.utils.commands import runCmd, get_bb_var, get_test_layer @@ -125,14 +139,13 @@ def remove_inc_files(): def get_tests(exclusive_modules=[], include_hidden=False): testslist = [] for x in exclusive_modules: -testslist.append('oeqa.selftest.' + x) +testslist.append(x) if not testslist: -testpath = os.path.abspath(os.path.dirname(oeqa.selftest.__file__)) -files = sorted([f for f in os.listdir(testpath) if f.endswith('.py') and not (f.startswith('_') and not include_hidden) and not f.startswith('__') and f != 'base.py']) -for f in files: -module = 'oeqa.selftest.' + f[:-3] -testslist.append(module) - +for pth in (tests_path + test_subdirs) : +files = sorted([f for f in os.listdir(pth) if f.endswith('.py') and not (f.startswith('_') and not include_hidden) and not f.startswith('__') and f != 'base.py']) +for f in files: +module = f[:-3] +testslist.append(module) return testslist def main(): @@ -145,8 +158,7 @@ def main(): if args.list_modules: log.info('Listing all available test modules:') testslist = get_tests(include_hidden=True) -for test in testslist: -module = test.split('.')[-1] +for module in testslist: info = '' if module.startswith('_'): info = ' (hidden)' @@ -154,7 +166,7 @@ def main(): if args.list_allclasses: try: import importlib -modlib = importlib.import_module(test) +modlib = importlib.import_module(module) for v in vars(modlib): t = vars(modlib)[v] if isinstance(t, type(oeSelfTest)) and issubclass(t, oeSelfTest) and t!=oeSelfTest: -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] lib/oeqa/selftest/buildoptions.py: added auto test for archiving the work directory and exporting the source files
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index cddfa48..be75311 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -2,6 +2,8 @@ import unittest import os import logging import re +import glob as g +import pexpect as p from oeqa.selftest.base import oeSelfTest from oeqa.selftest.buildhistory import BuildhistoryBase @@ -9,6 +11,7 @@ from oeqa.utils.commands import runCmd, bitbake, get_bb_var import oeqa.utils.ftools as ftools from oeqa.utils.decorators import testcase + class ImageOptionsTests(oeSelfTest): @testcase(761) @@ -133,7 +136,7 @@ class BuildImagesTest(oeSelfTest): self.remove_config("DISTRO_FEATURES_remove = \"x11\"\nDISTRO_FEATURES_append = \" directfb\"\nMACHINE ??= \"qemuarm\"") self.assertEqual(self.res, 0, "\ncore-image-directfb failed to build. Please check logs for further details.\n") - @testcase(283) +@testcase(283) def test_btrfs(self): """ This method is used to test the build of an image with btrfs file system. After building it, qemu is launched @@ -184,4 +187,19 @@ class ArchiverTest(oeSelfTest): self.license_dir = self.builddir + "/tmp/deploy/licenses/" for i in self.pkgs: if os.path.isdir(self.license_dir + i): -self.assertTrue(g.glob(self.license_dir + i + "/*GPL*"), "couldn't find GPL license in " + self.license_dir + i) \ No newline at end of file +self.assertTrue(g.glob(self.license_dir + i + "/*GPL*"), "couldn't find GPL license in " + self.license_dir + i) + +@testcase(926) +def test_arch_work_dir_and_export_source(self): +""" +Test for archiving the work directory and exporting the source files. +""" +self.add_command_to_tearDown('cleanup-workdir') +self.write_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"") +self.res = bitbake("xcursor-transparent-theme").status +self.remove_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"") +self.assertEqual(self.res, 0, "\nCouldn't build xcursor-transparent-theme.\n") +self.pkgs_path = g.glob(str(self.builddir) + "/tmp/deploy/sources/allarch*/xcurs*") +self.src_file_glob = str(self.pkgs_path[0]) + "/xcursor*.src.rpm" +self.tar_file_glob = str(self.pkgs_path[0]) + "/xcursor*.tar.gz" +self.assertTrue((g.glob(self.src_file_glob) and g.glob(self.tar_file_glob)), "Couldn't find .src.rpm and .tar.gz files under tmp/deploy/sources/allarch*/xcursor*") \ No newline at end of file -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] lib/oeqa/selftest/buildoptions.py: added auto test for image build with GPL licenses for containing packages
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 29 + 1 file changed, 29 insertions(+) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index a3297fd..cddfa48 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -156,3 +156,32 @@ class BuildImagesTest(oeSelfTest): self.prc.kill(9) self.log.error("It is possible that runquemu didn't start correctly. Add this line your_username ALL=NOPASSWD: ALL\nto your visudo") self.assertTrue(False, "Couldn't start qemu") + +class ArchiverTest(oeSelfTest): +@testcase(929) +def test_gpl_licenses(self): +""" +Test for checking that correct GPL licenses are used when explicitly required. +""" +self.add_command_to_tearDown('cleanup-workdir') +self.write_config("MACHINE = \"qemux86\"\nINHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nCOPYLEFT_LICENSE_INCLUDE = \"GPLv2* GPLv3*\"") +self.res = bitbake("core-image-minimal").status +self.remove_config("MACHINE = \"qemux86\"\nINHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nCOPYLEFT_LICENSE_INCLUDE = \"GPLv2* GPLv3*\"") +self.assertEqual(self.res, 0, "core-image-minimal didn't build. Please check logs for further details") +self.built_pkgs_list = os.listdir(self.builddir + "/tmp/deploy/sources/i586-poky-linux/")# the list containing built pkgs with ver. +self.pkg_name_split = [i.split("-") for i in self.built_pkgs_list] +self.pkgs = [] # this will contain the pkgs name as found in tmp/deploy/licenses +for i in self.pkg_name_split: + self.name = "" + for j in i: +if i.index(j) == 0: + self.name = j +elif j.isalpha() and i.index(j) != 0: + self.name = self.name + "-" + j +else: + self.pkgs.append(self.name) + break +self.license_dir = self.builddir + "/tmp/deploy/licenses/" +for i in self.pkgs: + if os.path.isdir(self.license_dir + i): +self.assertTrue(g.glob(self.license_dir + i + "/*GPL*"), "couldn't find GPL license in " + self.license_dir + i) \ No newline at end of file -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] lib/oeqa/selftest/buildoptions.py: added auto test for btrfs based images
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 27 +-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index c69da68..a3297fd 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -131,5 +131,28 @@ class BuildImagesTest(oeSelfTest): self.write_config("DISTRO_FEATURES_remove = \"x11\"\nDISTRO_FEATURES_append = \" directfb\"\nMACHINE ??= \"qemuarm\"") self.res = bitbake("core-image-directfb").status self.remove_config("DISTRO_FEATURES_remove = \"x11\"\nDISTRO_FEATURES_append = \" directfb\"\nMACHINE ??= \"qemuarm\"") -self.assertEqual(self.res, 0, "\ndirectfb image couldn't be built\n") -self.assertEqual(self.res, 0, "\ncore-image-directfb failed to build. Please check logs for further details.\n") \ No newline at end of file +self.assertEqual(self.res, 0, "\ncore-image-directfb failed to build. Please check logs for further details.\n") + + @testcase(283) +def test_btrfs(self): +""" +This method is used to test the build of an image with btrfs file system. After building it, qemu is launched +and the test searches for the "login" keyword that it expects in order to consider an image as functional. +Please note that "runquemu" requires sudo access. In order to solve this please add to visudo (sudo visudo) +the following line: your_username ALL=NOPASSWD: ALL +The above setting was tested in Ubuntu +""" +self.add_command_to_tearDown('cleanup-workdir') +self.write_config("MACHINE = \"qemux86\"\nIMAGE_FSTYPES = \"btrfs\"\nKERNEL_FEATURES_append = \" cfg/fs/btrfs \"") +self.res = bitbake("core-image-sato").status +self.remove_config("MACHINE = \"qemux86\"\nIMAGE_FSTYPES = \"btrfs\"\nKERNEL_FEATURES_append = \" cfg/fs/btrfs \"") +self.assertEqual(self.res, 0, "\nbtrfs core-image-sato failed to build. Please check logs for further details.\n") +self.prc = p.spawn("runqemu qemux86 core-image-sato nographic") +try: + self.prc.expect("login", timeout=150) + self.prc.kill(9) + self.assertTrue(True, "couldn't start qemu") +except: + self.prc.kill(9) + self.log.error("It is possible that runquemu didn't start correctly. Add this line your_username ALL=NOPASSWD: ALL\nto your visudo") + self.assertTrue(False, "Couldn't start qemu") -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest/buildoptions.py: added auto test for directfb image generation
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index 926ffe9..c69da68 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -120,7 +120,16 @@ class BuildhistoryTests(BuildhistoryBase): self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error) - - - - +class BuildImagesTest(oeSelfTest): +@testcase(563) +def test_directfb(self): +""" +This method is used to test the build of directfb image for arm arch. +In essence we build a core-image-directfb and test the exitcode of bitbake that in case of success is 0. +""" +self.add_command_to_tearDown('cleanup-workdir') +self.write_config("DISTRO_FEATURES_remove = \"x11\"\nDISTRO_FEATURES_append = \" directfb\"\nMACHINE ??= \"qemuarm\"") +self.res = bitbake("core-image-directfb").status +self.remove_config("DISTRO_FEATURES_remove = \"x11\"\nDISTRO_FEATURES_append = \" directfb\"\nMACHINE ??= \"qemuarm\"") +self.assertEqual(self.res, 0, "\ndirectfb image couldn't be built\n") +self.assertEqual(self.res, 0, "\ncore-image-directfb failed to build. Please check logs for further details.\n") \ No newline at end of file -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] meta/testimage.bbclass: corrected the bug that prevented test cases to be loaded from layers other than meta when using TEST_SUITES = "auto"
Signed-off-by: Costin Constantin --- meta/classes/testimage.bbclass | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index 4074ff7..aadee45 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass @@ -88,19 +88,20 @@ def get_tests_list(d, type="runtime"): if "auto" in testsuites: def add_auto_list(path): -if not os.path.exists(os.path.join(path, '__init__.py')): -bb.fatal('Tests directory %s exists but is missing __init__.py' % path) files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_')]) for f in files: module = 'oeqa.' + type + '.' + f[:-3] if module not in testslist: testslist.append(module) - +tests_found = False for p in bbpath: testpath = os.path.join(p, 'lib', 'oeqa', type) bb.debug(2, 'Searching for tests in %s' % testpath) -if os.path.exists(testpath): +if os.path.exists(os.path.join(testpath, '__init__.py')): add_auto_list(testpath) +tests_found = True +if not tests_found: +bb.fatal('Couldn\'t find any test files inside meta*/lib/oeqa/runtime or meta*/lib/oeqa/sdk directories.') return testslist -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest: added an auto-test to filter packages by license
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 36 ++ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index 8cacd1e..257122a 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -124,18 +124,30 @@ class BuildhistoryTests(BuildhistoryBase): self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error) class ArchiverTest(oeSelfTest): -@testcase(926) -def test_arch_work_dir_and_export_source(self): +@testcase(929) +def test_gpl_licenses(self): """ -Test for archiving the work directory and exporting the source files. +Test for checking that correct GPL licenses are used when explicitly required. """ self.add_command_to_tearDown('cleanup-workdir') -self.write_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"") -self.res = bitbake("xcursor-transparent-theme").status -self.remove_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"") -self.assertEqual(self.res, 0, "\nCouldn't build xcursor-transparent-theme.\n") -self.pkgs_path = g.glob(str(self.builddir) + "/tmp/deploy/sources/allarch*/xcurs*") -self.src_file_glob = str(self.pkgs_path[0]) + "/xcursor*.src.rpm" -self.tar_file_glob = str(self.pkgs_path[0]) + "/xcursor*.tar.gz" -if (g.glob(self.src_file_glob) and g.glob(self.tar_file_glob)): -self.assertTrue(True, "Couldn't find .src.rpm and .tar.gz files under tmp/deploy/sources/allarch*/xcursor*") \ No newline at end of file +self.write_config("MACHINE = \"qemux86\"\nINHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nCOPYLEFT_LICENSE_INCLUDE = \"GPLv2* GPLv3*\"") +self.res = bitbake("core-image-minimal").status +self.remove_config("MACHINE = \"qemux86\"\nINHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nCOPYLEFT_LICENSE_INCLUDE = \"GPLv2* GPLv3*\"") +self.assertEqual(self.res, 0, "core-image-minimal didn't build. Please check logs for further details") +self.built_pkgs_list = os.listdir(self.builddir + "/tmp/deploy/sources/i586-poky-linux/")# the list containing built pkgs with ver. +self.pkg_name_split = [i.split("-") for i in self.built_pkgs_list] +self.pkgs = [] # this will contain the pkgs name as found in tmp/deploy/licenses +for i in self.pkg_name_split: + self.name = "" + for j in i: +if i.index(j) == 0: + self.name = j +elif j.isalpha() and i.index(j) != 0: + self.name = self.name + "-" + j +else: + self.pkgs.append(self.name) + break +self.license_dir = self.builddir + "/tmp/deploy/licenses/" +for i in self.pkgs: + if os.path.isdir(self.license_dir + i): +self.assertTrue(g.glob(self.license_dir + i + "/*GPL*"), "couldn't find GPL license in " + self.license_dir + i) \ No newline at end of file -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest: added auto-test for archiving working dir and expeort source package
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index 620fd77..8cacd1e 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -123,16 +123,19 @@ class BuildhistoryTests(BuildhistoryBase): self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True) self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error) -class BuildImagesTest(oeSelfTest): -@testcase(563) -def test_directfb(self): +class ArchiverTest(oeSelfTest): +@testcase(926) +def test_arch_work_dir_and_export_source(self): """ -This method is used to test the build of directfb image for arm arch. -In essence we build a core-image-directfb and test the exitcode of bitbake that in case of success is 0. +Test for archiving the work directory and exporting the source files. """ self.add_command_to_tearDown('cleanup-workdir') -self.write_config("DISTRO_FEATURES_remove = \"x11\"\nDISTRO_FEATURES_append = \" directfb\"\nMACHINE ??= \"qemuarm\"") -self.res = bitbake("core-image-directfb").status -self.remove_config("DISTRO_FEATURES_remove = \"x11\"\nDISTRO_FEATURES_append = \" directfb\"\nMACHINE ??= \"qemuarm\"") -self.assertEqual(self.res, 0, "\ndirectfb image couldn't be built\n") -self.assertEqual(self.res, 0, "\ncore-image-directfb failed to build. Please check logs for further details.\n") \ No newline at end of file +self.write_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"") +self.res = bitbake("xcursor-transparent-theme").status +self.remove_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"") +self.assertEqual(self.res, 0, "\nCouldn't build xcursor-transparent-theme.\n") +self.pkgs_path = g.glob(str(self.builddir) + "/tmp/deploy/sources/allarch*/xcurs*") +self.src_file_glob = str(self.pkgs_path[0]) + "/xcursor*.src.rpm" +self.tar_file_glob = str(self.pkgs_path[0]) + "/xcursor*.tar.gz" +if (g.glob(self.src_file_glob) and g.glob(self.tar_file_glob)): +self.assertTrue(True, "Couldn't find .src.rpm and .tar.gz files under tmp/deploy/sources/allarch*/xcursor*") \ No newline at end of file -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest: added auto-test for directfb image on arm architecture
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 29 + 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index e48bd04..620fd77 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -124,26 +124,15 @@ class BuildhistoryTests(BuildhistoryBase): self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error) class BuildImagesTest(oeSelfTest): -@testcase(283) -def test_btrfs(self): +@testcase(563) +def test_directfb(self): """ -This method is used to test the build of an image with btrfs file system. After building it, qemu is launched -and the test searches for the "login" keyword that it expects in order to consider an image as functional. -Please note that "runquemu" requires sudo access. In order to solve this please add to visudo (sudo visudo) -the following line: your_username ALL=NOPASSWD: ALL -The above setting was tested in Ubuntu +This method is used to test the build of directfb image for arm arch. +In essence we build a core-image-directfb and test the exitcode of bitbake that in case of success is 0. """ self.add_command_to_tearDown('cleanup-workdir') -self.write_config("MACHINE = \"qemux86\"\nIMAGE_FSTYPES = \"btrfs\"\nKERNEL_FEATURES_append = \" cfg/fs/btrfs \"") -self.res = bitbake("core-image-sato").status -self.remove_config("MACHINE = \"qemux86\"\nIMAGE_FSTYPES = \"btrfs\"\nKERNEL_FEATURES_append = \" cfg/fs/btrfs \"") -self.assertEqual(self.res, 0, "\nbtrfs core-image-sato failed to build. Please check logs for further details.\n") -self.prc = p.spawn("runqemu qemux86 core-image-sato nographic") -try: - self.prc.expect("login", timeout=150) - self.prc.kill(9) - self.assertTrue(True, "couldn't start qemu") -except: - self.prc.kill(9) - self.log.error("It is possible that runquemu didn't start correctly. Add this line your_username ALL=NOPASSWD: ALL\nto your visudo") - self.assertTrue(False, "Couldn't start qemu") \ No newline at end of file +self.write_config("DISTRO_FEATURES_remove = \"x11\"\nDISTRO_FEATURES_append = \" directfb\"\nMACHINE ??= \"qemuarm\"") +self.res = bitbake("core-image-directfb").status +self.remove_config("DISTRO_FEATURES_remove = \"x11\"\nDISTRO_FEATURES_append = \" directfb\"\nMACHINE ??= \"qemuarm\"") +self.assertEqual(self.res, 0, "\ndirectfb image couldn't be built\n") +self.assertEqual(self.res, 0, "\ncore-image-directfb failed to build. Please check logs for further details.\n") \ No newline at end of file -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest: added auto-test for btrfs image type
Signed-off-by: Costin Constantin --- meta/lib/oeqa/selftest/buildoptions.py | 33 - 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index 926ffe9..e48bd04 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -2,6 +2,10 @@ import unittest import os import logging import re +from time import sleep +import pexpect as p +import glob as g + from oeqa.selftest.base import oeSelfTest from oeqa.selftest.buildhistory import BuildhistoryBase @@ -119,8 +123,27 @@ class BuildhistoryTests(BuildhistoryBase): self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True) self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error) - - - - - +class BuildImagesTest(oeSelfTest): +@testcase(283) +def test_btrfs(self): +""" +This method is used to test the build of an image with btrfs file system. After building it, qemu is launched +and the test searches for the "login" keyword that it expects in order to consider an image as functional. +Please note that "runquemu" requires sudo access. In order to solve this please add to visudo (sudo visudo) +the following line: your_username ALL=NOPASSWD: ALL +The above setting was tested in Ubuntu +""" +self.add_command_to_tearDown('cleanup-workdir') +self.write_config("MACHINE = \"qemux86\"\nIMAGE_FSTYPES = \"btrfs\"\nKERNEL_FEATURES_append = \" cfg/fs/btrfs \"") +self.res = bitbake("core-image-sato").status +self.remove_config("MACHINE = \"qemux86\"\nIMAGE_FSTYPES = \"btrfs\"\nKERNEL_FEATURES_append = \" cfg/fs/btrfs \"") +self.assertEqual(self.res, 0, "\nbtrfs core-image-sato failed to build. Please check logs for further details.\n") +self.prc = p.spawn("runqemu qemux86 core-image-sato nographic") +try: + self.prc.expect("login", timeout=150) + self.prc.kill(9) + self.assertTrue(True, "couldn't start qemu") +except: + self.prc.kill(9) + self.log.error("It is possible that runquemu didn't start correctly. Add this line your_username ALL=NOPASSWD: ALL\nto your visudo") + self.assertTrue(False, "Couldn't start qemu") \ No newline at end of file -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core