* [PATCH] classes/testsdk: Split implementation into classes
@ 2018-11-15 19:14 Joshua Watt
2018-11-15 19:40 ` Richard Purdie
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Joshua Watt @ 2018-11-15 19:14 UTC (permalink / raw)
To: openembedded-core
Splits the SDK test implementation into separate class files. The
classes that are included are controlled by the variable
${TESTSDK_CLASSES}. This allows a SDK machine to change which classes
are used to implement the test cases.
[YOCTO #13020]
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
meta/classes/testsdk-oecore.bbclass | 88 +++++++++++
meta/classes/testsdk.bbclass | 202 ++-----------------------
meta/classes/testsdkext-oecore.bbclass | 107 +++++++++++++
3 files changed, 205 insertions(+), 192 deletions(-)
create mode 100644 meta/classes/testsdk-oecore.bbclass
create mode 100644 meta/classes/testsdkext-oecore.bbclass
diff --git a/meta/classes/testsdk-oecore.bbclass b/meta/classes/testsdk-oecore.bbclass
new file mode 100644
index 00000000000..9a85ac59397
--- /dev/null
+++ b/meta/classes/testsdk-oecore.bbclass
@@ -0,0 +1,88 @@
+# Copyright (C) 2013 - 2016 Intel Corporation
+#
+# Released under the MIT license (see COPYING.MIT)
+
+def testsdk_oecore_main(d):
+ import os
+ import subprocess
+ import json
+ import logging
+
+ from bb.utils import export_proxies
+ from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor
+ from oeqa.utils import make_logger_bitbake_compatible
+
+ pn = d.getVar("PN")
+ logger = make_logger_bitbake_compatible(logging.getLogger("BitBake"))
+
+ # sdk use network for download projects for build
+ export_proxies(d)
+
+ tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh")
+ if not os.path.exists(tcname):
+ bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' ." % tcname)
+
+ tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json")
+ test_data = json.load(open(tdname, "r"))
+
+ target_pkg_manifest = OESDKTestContextExecutor._load_manifest(
+ d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest"))
+ host_pkg_manifest = OESDKTestContextExecutor._load_manifest(
+ d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest"))
+
+ processes = d.getVar("TESTIMAGE_NUMBER_THREADS") or d.getVar("BB_NUMBER_THREADS")
+ if processes:
+ try:
+ import testtools, subunit
+ except ImportError:
+ bb.warn("Failed to import testtools or subunit, the testcases will run serially")
+ processes = None
+
+ sdk_dir = d.expand("${WORKDIR}/testimage-sdk/")
+ bb.utils.remove(sdk_dir, True)
+ bb.utils.mkdirhier(sdk_dir)
+ try:
+ subprocess.check_output("cd %s; %s <<EOF\n./\nY\nEOF" % (sdk_dir, tcname), shell=True)
+ except subprocess.CalledProcessError as e:
+ bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8"))
+
+ fail = False
+ sdk_envs = OESDKTestContextExecutor._get_sdk_environs(sdk_dir)
+ for s in sdk_envs:
+ sdk_env = sdk_envs[s]
+ bb.plain("SDK testing environment: %s" % s)
+ tc = OESDKTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir,
+ sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest,
+ host_pkg_manifest=host_pkg_manifest)
+
+ try:
+ tc.loadTests(OESDKTestContextExecutor.default_cases)
+ except Exception as e:
+ import traceback
+ bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
+
+ if processes:
+ result = tc.runTests(processes=int(processes))
+ else:
+ result = tc.runTests()
+
+ component = "%s %s" % (pn, OESDKTestContextExecutor.name)
+ context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env))
+ configuration = get_sdk_configuration(d, 'sdk')
+ result.logDetails(get_sdk_json_result_dir(d),
+ configuration,
+ get_sdk_result_id(configuration))
+ result.logSummary(component, context_msg)
+
+ if not result.wasSuccessful():
+ fail = True
+
+ if fail:
+ bb.fatal("%s - FAILED - check the task log and the commands log" % pn)
+
+testsdk_oecore_main[vardepsexclude] =+ "BB_ORIGENV"
+
+python do_testsdk() {
+ testsdk_oecore_main(d)
+}
+
diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass
index 5b9bf7b2624..5be946fca47 100644
--- a/meta/classes/testsdk.bbclass
+++ b/meta/classes/testsdk.bbclass
@@ -38,200 +38,18 @@ def get_sdk_json_result_dir(d):
def get_sdk_result_id(configuration):
return '%s_%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['SDKMACHINE'], configuration['MACHINE'], configuration['STARTTIME'])
-def testsdk_main(d):
- import os
- import subprocess
- import json
- import logging
+TESTSDK_CLASSES ?= "testsdk-oecore testsdkext-oecore"
- from bb.utils import export_proxies
- from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor
- from oeqa.utils import make_logger_bitbake_compatible
+inherit ${TESTSDK_CLASSES}
- pn = d.getVar("PN")
- logger = make_logger_bitbake_compatible(logging.getLogger("BitBake"))
-
- # sdk use network for download projects for build
- export_proxies(d)
-
- tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh")
- if not os.path.exists(tcname):
- bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' ." % tcname)
-
- tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json")
- test_data = json.load(open(tdname, "r"))
-
- target_pkg_manifest = OESDKTestContextExecutor._load_manifest(
- d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest"))
- host_pkg_manifest = OESDKTestContextExecutor._load_manifest(
- d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest"))
-
- processes = d.getVar("TESTIMAGE_NUMBER_THREADS") or d.getVar("BB_NUMBER_THREADS")
- if processes:
- try:
- import testtools, subunit
- except ImportError:
- bb.warn("Failed to import testtools or subunit, the testcases will run serially")
- processes = None
-
- sdk_dir = d.expand("${WORKDIR}/testimage-sdk/")
- bb.utils.remove(sdk_dir, True)
- bb.utils.mkdirhier(sdk_dir)
- try:
- subprocess.check_output("cd %s; %s <<EOF\n./\nY\nEOF" % (sdk_dir, tcname), shell=True)
- except subprocess.CalledProcessError as e:
- bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8"))
-
- fail = False
- sdk_envs = OESDKTestContextExecutor._get_sdk_environs(sdk_dir)
- for s in sdk_envs:
- sdk_env = sdk_envs[s]
- bb.plain("SDK testing environment: %s" % s)
- tc = OESDKTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir,
- sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest,
- host_pkg_manifest=host_pkg_manifest)
-
- try:
- tc.loadTests(OESDKTestContextExecutor.default_cases)
- except Exception as e:
- import traceback
- bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
-
- if processes:
- result = tc.runTests(processes=int(processes))
- else:
- result = tc.runTests()
-
- component = "%s %s" % (pn, OESDKTestContextExecutor.name)
- context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env))
- configuration = get_sdk_configuration(d, 'sdk')
- result.logDetails(get_sdk_json_result_dir(d),
- configuration,
- get_sdk_result_id(configuration))
- result.logSummary(component, context_msg)
-
- if not result.wasSuccessful():
- fail = True
-
- if fail:
- bb.fatal("%s - FAILED - check the task log and the commands log" % pn)
-
-testsdk_main[vardepsexclude] =+ "BB_ORIGENV"
-
-python do_testsdk() {
- testsdk_main(d)
-}
-addtask testsdk
-do_testsdk[nostamp] = "1"
-
-def testsdkext_main(d):
- import os
- import json
- import subprocess
- import logging
-
- from bb.utils import export_proxies
- from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible, subprocesstweak
- from oeqa.sdkext.context import OESDKExtTestContext, OESDKExtTestContextExecutor
-
- pn = d.getVar("PN")
- logger = make_logger_bitbake_compatible(logging.getLogger("BitBake"))
-
- # extensible sdk use network
- export_proxies(d)
-
- subprocesstweak.errors_have_output()
-
- # extensible sdk can be contaminated if native programs are
- # in PATH, i.e. use perl-native instead of eSDK one.
- paths_to_avoid = [d.getVar('STAGING_DIR'),
- d.getVar('BASE_WORKDIR')]
- os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid)
-
- tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh")
- if not os.path.exists(tcname):
- bb.fatal("The toolchain ext %s is not built. Build it before running the" \
- " tests: 'bitbake <image> -c populate_sdk_ext' ." % tcname)
-
- tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.testdata.json")
- test_data = json.load(open(tdname, "r"))
-
- target_pkg_manifest = OESDKExtTestContextExecutor._load_manifest(
- d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest"))
- host_pkg_manifest = OESDKExtTestContextExecutor._load_manifest(
- d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest"))
-
- sdk_dir = d.expand("${WORKDIR}/testsdkext/")
- bb.utils.remove(sdk_dir, True)
- bb.utils.mkdirhier(sdk_dir)
- try:
- subprocess.check_output("%s -y -d %s" % (tcname, sdk_dir), shell=True)
- except subprocess.CalledProcessError as e:
- msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8")
- logfn = os.path.join(sdk_dir, 'preparing_build_system.log')
- if os.path.exists(logfn):
- msg += '\n\nContents of preparing_build_system.log:\n'
- with open(logfn, 'r') as f:
- for line in f:
- msg += line
- bb.fatal(msg)
-
- fail = False
- sdk_envs = OESDKExtTestContextExecutor._get_sdk_environs(sdk_dir)
- for s in sdk_envs:
- bb.plain("Extensible SDK testing environment: %s" % s)
-
- sdk_env = sdk_envs[s]
-
- # Use our own SSTATE_DIR and DL_DIR so that updates to the eSDK come from our sstate cache
- # and we don't spend hours downloading kernels for the kernel module test
- # Abuse auto.conf since local.conf would be overwritten by the SDK
- with open(os.path.join(sdk_dir, 'conf', 'auto.conf'), 'a+') as f:
- f.write('SSTATE_MIRRORS += " \\n file://.* file://%s/PATH"\n' % test_data.get('SSTATE_DIR'))
- f.write('SOURCE_MIRROR_URL = "file://%s"\n' % test_data.get('DL_DIR'))
- f.write('INHERIT += "own-mirrors"\n')
- f.write('PREMIRRORS_prepend = " git://git.yoctoproject.org/.* git://%s/git2/git.yoctoproject.org.BASENAME \\n "\n' % test_data.get('DL_DIR'))
-
- # We need to do this in case we have a minimal SDK
- subprocess.check_output(". %s > /dev/null; devtool sdk-install meta-extsdk-toolchain" % \
- sdk_env, cwd=sdk_dir, shell=True, stderr=subprocess.STDOUT)
-
- tc = OESDKExtTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir,
- sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest,
- host_pkg_manifest=host_pkg_manifest)
-
- try:
- tc.loadTests(OESDKExtTestContextExecutor.default_cases)
- except Exception as e:
- import traceback
- bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
-
- result = tc.runTests()
-
- component = "%s %s" % (pn, OESDKExtTestContextExecutor.name)
- context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env))
- configuration = get_sdk_configuration(d, 'sdkext')
- result.logDetails(get_sdk_json_result_dir(d),
- configuration,
- get_sdk_result_id(configuration))
- result.logSummary(component, context_msg)
-
- if not result.wasSuccessful():
- fail = True
-
- if fail:
- bb.fatal("%s - FAILED - check the task log and the commands log" % pn)
-
-testsdkext_main[vardepsexclude] =+ "BB_ORIGENV"
+python () {
+ auto = oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False")
-python do_testsdkext() {
- testsdkext_main(d)
-}
-addtask testsdkext
-do_testsdkext[nostamp] = "1"
+ if d.getVar('do_testsdk'):
+ d.setVarFlag('do_testsdk', 'nostamp', '1')
+ bb.build.addtask("testsdk", None, ("", "do_populate_sdk")[auto], d)
-python () {
- if oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False"):
- bb.build.addtask("testsdk", None, "do_populate_sdk", d)
- bb.build.addtask("testsdkext", None, "do_populate_sdk_ext", d)
+ if d.getVar('TESTSDKEXT_CLASSES'):
+ d.setVarFlag('do_testsdkext', 'nostamp', '1')
+ bb.build.addtask("testsdkext", None, ("", "do_populate_sdk_ext")[auto], d)
}
diff --git a/meta/classes/testsdkext-oecore.bbclass b/meta/classes/testsdkext-oecore.bbclass
new file mode 100644
index 00000000000..e8c02013ac9
--- /dev/null
+++ b/meta/classes/testsdkext-oecore.bbclass
@@ -0,0 +1,107 @@
+# Copyright (C) 2013 - 2016 Intel Corporation
+#
+# Released under the MIT license (see COPYING.MIT)
+
+def testsdkext_oecore_main(d):
+ import os
+ import json
+ import subprocess
+ import logging
+
+ from bb.utils import export_proxies
+ from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible, subprocesstweak
+ from oeqa.sdkext.context import OESDKExtTestContext, OESDKExtTestContextExecutor
+
+ pn = d.getVar("PN")
+ logger = make_logger_bitbake_compatible(logging.getLogger("BitBake"))
+
+ # extensible sdk use network
+ export_proxies(d)
+
+ subprocesstweak.errors_have_output()
+
+ # extensible sdk can be contaminated if native programs are
+ # in PATH, i.e. use perl-native instead of eSDK one.
+ paths_to_avoid = [d.getVar('STAGING_DIR'),
+ d.getVar('BASE_WORKDIR')]
+ os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid)
+
+ tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh")
+ if not os.path.exists(tcname):
+ bb.fatal("The toolchain ext %s is not built. Build it before running the" \
+ " tests: 'bitbake <image> -c populate_sdk_ext' ." % tcname)
+
+ tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.testdata.json")
+ test_data = json.load(open(tdname, "r"))
+
+ target_pkg_manifest = OESDKExtTestContextExecutor._load_manifest(
+ d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest"))
+ host_pkg_manifest = OESDKExtTestContextExecutor._load_manifest(
+ d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest"))
+
+ sdk_dir = d.expand("${WORKDIR}/testsdkext/")
+ bb.utils.remove(sdk_dir, True)
+ bb.utils.mkdirhier(sdk_dir)
+ try:
+ subprocess.check_output("%s -y -d %s" % (tcname, sdk_dir), shell=True)
+ except subprocess.CalledProcessError as e:
+ msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8")
+ logfn = os.path.join(sdk_dir, 'preparing_build_system.log')
+ if os.path.exists(logfn):
+ msg += '\n\nContents of preparing_build_system.log:\n'
+ with open(logfn, 'r') as f:
+ for line in f:
+ msg += line
+ bb.fatal(msg)
+
+ fail = False
+ sdk_envs = OESDKExtTestContextExecutor._get_sdk_environs(sdk_dir)
+ for s in sdk_envs:
+ bb.plain("Extensible SDK testing environment: %s" % s)
+
+ sdk_env = sdk_envs[s]
+
+ # Use our own SSTATE_DIR and DL_DIR so that updates to the eSDK come from our sstate cache
+ # and we don't spend hours downloading kernels for the kernel module test
+ # Abuse auto.conf since local.conf would be overwritten by the SDK
+ with open(os.path.join(sdk_dir, 'conf', 'auto.conf'), 'a+') as f:
+ f.write('SSTATE_MIRRORS += " \\n file://.* file://%s/PATH"\n' % test_data.get('SSTATE_DIR'))
+ f.write('SOURCE_MIRROR_URL = "file://%s"\n' % test_data.get('DL_DIR'))
+ f.write('INHERIT += "own-mirrors"\n')
+ f.write('PREMIRRORS_prepend = " git://git.yoctoproject.org/.* git://%s/git2/git.yoctoproject.org.BASENAME \\n "\n' % test_data.get('DL_DIR'))
+
+ # We need to do this in case we have a minimal SDK
+ subprocess.check_output(". %s > /dev/null; devtool sdk-install meta-extsdk-toolchain" % \
+ sdk_env, cwd=sdk_dir, shell=True, stderr=subprocess.STDOUT)
+
+ tc = OESDKExtTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir,
+ sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest,
+ host_pkg_manifest=host_pkg_manifest)
+
+ try:
+ tc.loadTests(OESDKExtTestContextExecutor.default_cases)
+ except Exception as e:
+ import traceback
+ bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
+
+ result = tc.runTests()
+
+ component = "%s %s" % (pn, OESDKExtTestContextExecutor.name)
+ context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env))
+ configuration = get_sdk_configuration(d, 'sdkext')
+ result.logDetails(get_sdk_json_result_dir(d),
+ configuration,
+ get_sdk_result_id(configuration))
+ result.logSummary(component, context_msg)
+
+ if not result.wasSuccessful():
+ fail = True
+
+ if fail:
+ bb.fatal("%s - FAILED - check the task log and the commands log" % pn)
+
+testsdkext_oecore_main[vardepsexclude] =+ "BB_ORIGENV"
+
+python do_testsdkext() {
+ testsdkext_oecore_main(d)
+}
--
2.19.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH] classes/testsdk: Split implementation into classes 2018-11-15 19:14 [PATCH] classes/testsdk: Split implementation into classes Joshua Watt @ 2018-11-15 19:40 ` Richard Purdie 2018-11-15 22:28 ` Joshua Watt 2018-11-18 19:19 ` [PATCH v2] " Joshua Watt 2018-11-18 19:33 ` ✗ patchtest: failure for classes/testsdk: Split implementation into classes (rev2) Patchwork 2 siblings, 1 reply; 9+ messages in thread From: Richard Purdie @ 2018-11-15 19:40 UTC (permalink / raw) To: Joshua Watt, openembedded-core On Thu, 2018-11-15 at 13:14 -0600, Joshua Watt wrote: > Splits the SDK test implementation into separate class files. The > classes that are included are controlled by the variable > ${TESTSDK_CLASSES}. This allows a SDK machine to change which classes > are used to implement the test cases. > > [YOCTO #13020] > > Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> > --- > meta/classes/testsdk-oecore.bbclass | 88 +++++++++++ > meta/classes/testsdk.bbclass | 202 ++--------------------- > -- > meta/classes/testsdkext-oecore.bbclass | 107 +++++++++++++ > 3 files changed, 205 insertions(+), 192 deletions(-) > create mode 100644 meta/classes/testsdk-oecore.bbclass > create mode 100644 meta/classes/testsdkext-oecore.bbclass Would it make more sense to move some of this code to 'proper' python library/classes under meta/lib/oe ? We did this with package_managers and I'd say it probably did improve things... We probably don't want/need more bbclass files, particularly when they just include each other. Cheers, Richard ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] classes/testsdk: Split implementation into classes 2018-11-15 19:40 ` Richard Purdie @ 2018-11-15 22:28 ` Joshua Watt 2018-11-15 22:48 ` richard.purdie 0 siblings, 1 reply; 9+ messages in thread From: Joshua Watt @ 2018-11-15 22:28 UTC (permalink / raw) To: Richard Purdie, openembedded-core On Thu, 2018-11-15 at 19:40 +0000, Richard Purdie wrote: > On Thu, 2018-11-15 at 13:14 -0600, Joshua Watt wrote: > > Splits the SDK test implementation into separate class files. The > > classes that are included are controlled by the variable > > ${TESTSDK_CLASSES}. This allows a SDK machine to change which > > classes > > are used to implement the test cases. > > > > [YOCTO #13020] > > > > Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> > > --- > > meta/classes/testsdk-oecore.bbclass | 88 +++++++++++ > > meta/classes/testsdk.bbclass | 202 ++------------------- > > -- > > -- > > meta/classes/testsdkext-oecore.bbclass | 107 +++++++++++++ > > 3 files changed, 205 insertions(+), 192 deletions(-) > > create mode 100644 meta/classes/testsdk-oecore.bbclass > > create mode 100644 meta/classes/testsdkext-oecore.bbclass > > Would it make more sense to move some of this code to 'proper' python > library/classes under meta/lib/oe ? > > We did this with package_managers and I'd say it probably did improve > things... > > We probably don't want/need more bbclass files, particularly when > they > just include each other. Organizationally, using Python classes for the main code makes a lot of sense, but I believe you would still need the 3 (or 2 if you combine testsdk-oecore and testsdkext-oecore) classes, since you want the single entry point of testsdk.bbclass, but need to be able to override how it gets implemented (unless I'm missing something)... The files would basically boil down to: ---- classes/testsdk.bbclass ---- TESTSDK_CLASSES ?= "testsdk-oecore testsdkext-oecore" inherit ${TESTSDK_CLASSES} ---- classes/testsdk(ext)?-oecore.bbclass ---- python do_testsdk() { from oeqa.sdk.testsdk import TestSDK t = TestSDK(d) t.run() } ---- It might make things a little more clear if I describe the end game; I would like to provide a different class to implement the MinGW SDK tests. This would be done by adding the following to the MinGW SDK machine.conf file (mingw32-common.inc): TESTSDK_CLASSES = "testsdk-mingw" Then, adding a new class in meta-mingw ---- classes/testsdk-mingw.bbclass ---- python do_testsdk() { from oeqa.sdk.testsdkmingw import TestSDKMinGW t = TestSDKMinGW(d) t.run() } ---- AFAICT, this is pretty similar to how the package managers are working. Did you had something else in mind? > > Cheers, > > Richard > -- Joshua Watt <JPEWhacker@gmail.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] classes/testsdk: Split implementation into classes 2018-11-15 22:28 ` Joshua Watt @ 2018-11-15 22:48 ` richard.purdie 0 siblings, 0 replies; 9+ messages in thread From: richard.purdie @ 2018-11-15 22:48 UTC (permalink / raw) To: Joshua Watt, openembedded-core On Thu, 2018-11-15 at 16:28 -0600, Joshua Watt wrote: > > ---- classes/testsdk(ext)?-oecore.bbclass ---- > > python do_testsdk() { > from oeqa.sdk.testsdk import TestSDK > t = TestSDK(d) > t.run() > } > > ---- > > It might make things a little more clear if I describe the end game; > I > would like to provide a different class to implement the MinGW SDK > tests. This would be done by adding the following to the MinGW SDK > machine.conf file (mingw32-common.inc): > > TESTSDK_CLASSES = "testsdk-mingw" > > Then, adding a new class in meta-mingw > > ---- classes/testsdk-mingw.bbclass ---- > > python do_testsdk() { > from oeqa.sdk.testsdkmingw import TestSDKMinGW > t = TestSDKMinGW(d) > t.run() > } > > ---- > > AFAICT, this is pretty similar to how the package managers are > working. > > Did you had something else in mind? We're thinking along similar lines but in pseudo-code I was thinking something more like: SDKCLASSNAME ??= "default" python do_testsdk() { sdkclass = d.getVar("SDKCLASSNAME") from oeqa.sdk.testsdkmingw import sdkclass t = sdkclass(d) t.run() } as there should be some way to structure this so we don't need so many bbclass files... Cheers, Richard ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] classes/testsdk: Split implementation into classes 2018-11-15 19:14 [PATCH] classes/testsdk: Split implementation into classes Joshua Watt 2018-11-15 19:40 ` Richard Purdie @ 2018-11-18 19:19 ` Joshua Watt 2018-11-19 14:25 ` Richard Purdie 2018-11-19 18:11 ` [PATCH v3] " Joshua Watt 2018-11-18 19:33 ` ✗ patchtest: failure for classes/testsdk: Split implementation into classes (rev2) Patchwork 2 siblings, 2 replies; 9+ messages in thread From: Joshua Watt @ 2018-11-18 19:19 UTC (permalink / raw) To: openembedded-core Splits the SDK test implementation into configurable Python classes. The classes used for the normal and extensible SDKs are ${TESTSDK_CLASS_NAME} and ${TESTSDKEXT_CLASS_NAME} respectively. This allows SDK machines to override the classes used to implement the tests. For the traditional SDK, a common "run()" function is provided by the class (oeqa.sdk.testsdk.TestSDK), with several hook member functions that can be overridden in child classes, making it easier to have consistent behavior. The extensible SDK class (oeqa.sdkext.testsdk.TestSDKEXT) also has a common "run()" function, but no hooks have yet been added as there is not currently a known use case for create derived classes. [YOCTO #13020] Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> --- meta/classes/testsdk.bbclass | 227 +++----------------------------- meta/lib/oeqa/sdk/testsdk.py | 141 ++++++++++++++++++++ meta/lib/oeqa/sdkext/testsdk.py | 104 +++++++++++++++ 3 files changed, 264 insertions(+), 208 deletions(-) create mode 100644 meta/lib/oeqa/sdk/testsdk.py create mode 100644 meta/lib/oeqa/sdkext/testsdk.py diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass index 5b9bf7b2624..f4392337236 100644 --- a/meta/classes/testsdk.bbclass +++ b/meta/classes/testsdk.bbclass @@ -14,224 +14,35 @@ # # where "<image-name>" is an image like core-image-sato. -def get_sdk_configuration(d, test_type): - import platform - from oeqa.utils.metadata import get_layers - configuration = {'TEST_TYPE': test_type, - 'MACHINE': d.getVar("MACHINE"), - 'SDKMACHINE': d.getVar("SDKMACHINE"), - 'IMAGE_BASENAME': d.getVar("IMAGE_BASENAME"), - 'IMAGE_PKGTYPE': d.getVar("IMAGE_PKGTYPE"), - 'STARTTIME': d.getVar("DATETIME"), - 'HOST_DISTRO': ('-'.join(platform.linux_distribution())).replace(' ', '-'), - 'LAYERS': get_layers(d.getVar("BBLAYERS"))} - return configuration -get_sdk_configuration[vardepsexclude] = "DATETIME" +TESTSDK_CLASS_NAME ?= "oeqa.sdk.testsdk.TestSDK" +TESTSDKEXT_CLASS_NAME ?= "oeqa.sdkext.testsdk.TestSDKExt" -def get_sdk_json_result_dir(d): - json_result_dir = os.path.join(d.getVar("LOG_DIR"), 'oeqa') - custom_json_result_dir = d.getVar("OEQA_JSON_RESULT_DIR") - if custom_json_result_dir: - json_result_dir = custom_json_result_dir - return json_result_dir +def import_and_run(name, d): + import importlib -def get_sdk_result_id(configuration): - return '%s_%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['SDKMACHINE'], configuration['MACHINE'], configuration['STARTTIME']) + class_name = d.getVar(name) + if class_name: + module, cls = class_name.rsplit('.', 1) + m = importlib.import_module(module) + c = getattr(m, cls)() + c.run(d) + else: + bb.warn('No tests were run because %s did not define a class' % name) -def testsdk_main(d): - import os - import subprocess - import json - import logging - - from bb.utils import export_proxies - from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor - from oeqa.utils import make_logger_bitbake_compatible - - pn = d.getVar("PN") - logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) - - # sdk use network for download projects for build - export_proxies(d) - - tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh") - if not os.path.exists(tcname): - bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' ." % tcname) - - tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json") - test_data = json.load(open(tdname, "r")) - - target_pkg_manifest = OESDKTestContextExecutor._load_manifest( - d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest")) - host_pkg_manifest = OESDKTestContextExecutor._load_manifest( - d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest")) - - processes = d.getVar("TESTIMAGE_NUMBER_THREADS") or d.getVar("BB_NUMBER_THREADS") - if processes: - try: - import testtools, subunit - except ImportError: - bb.warn("Failed to import testtools or subunit, the testcases will run serially") - processes = None - - sdk_dir = d.expand("${WORKDIR}/testimage-sdk/") - bb.utils.remove(sdk_dir, True) - bb.utils.mkdirhier(sdk_dir) - try: - subprocess.check_output("cd %s; %s <<EOF\n./\nY\nEOF" % (sdk_dir, tcname), shell=True) - except subprocess.CalledProcessError as e: - bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8")) - - fail = False - sdk_envs = OESDKTestContextExecutor._get_sdk_environs(sdk_dir) - for s in sdk_envs: - sdk_env = sdk_envs[s] - bb.plain("SDK testing environment: %s" % s) - tc = OESDKTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir, - sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest, - host_pkg_manifest=host_pkg_manifest) - - try: - tc.loadTests(OESDKTestContextExecutor.default_cases) - except Exception as e: - import traceback - bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) - - if processes: - result = tc.runTests(processes=int(processes)) - else: - result = tc.runTests() - - component = "%s %s" % (pn, OESDKTestContextExecutor.name) - context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) - configuration = get_sdk_configuration(d, 'sdk') - result.logDetails(get_sdk_json_result_dir(d), - configuration, - get_sdk_result_id(configuration)) - result.logSummary(component, context_msg) - - if not result.wasSuccessful(): - fail = True - - if fail: - bb.fatal("%s - FAILED - check the task log and the commands log" % pn) - -testsdk_main[vardepsexclude] =+ "BB_ORIGENV" +import_and_run[vardepsexclude] = "DATETIME BB_ORIGENV" python do_testsdk() { - testsdk_main(d) + import_and_run('TESTSDK_CLASS_NAME', d) } -addtask testsdk do_testsdk[nostamp] = "1" -def testsdkext_main(d): - import os - import json - import subprocess - import logging - - from bb.utils import export_proxies - from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible, subprocesstweak - from oeqa.sdkext.context import OESDKExtTestContext, OESDKExtTestContextExecutor - - pn = d.getVar("PN") - logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) - - # extensible sdk use network - export_proxies(d) - - subprocesstweak.errors_have_output() - - # extensible sdk can be contaminated if native programs are - # in PATH, i.e. use perl-native instead of eSDK one. - paths_to_avoid = [d.getVar('STAGING_DIR'), - d.getVar('BASE_WORKDIR')] - os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid) - - tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh") - if not os.path.exists(tcname): - bb.fatal("The toolchain ext %s is not built. Build it before running the" \ - " tests: 'bitbake <image> -c populate_sdk_ext' ." % tcname) - - tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.testdata.json") - test_data = json.load(open(tdname, "r")) - - target_pkg_manifest = OESDKExtTestContextExecutor._load_manifest( - d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest")) - host_pkg_manifest = OESDKExtTestContextExecutor._load_manifest( - d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest")) - - sdk_dir = d.expand("${WORKDIR}/testsdkext/") - bb.utils.remove(sdk_dir, True) - bb.utils.mkdirhier(sdk_dir) - try: - subprocess.check_output("%s -y -d %s" % (tcname, sdk_dir), shell=True) - except subprocess.CalledProcessError as e: - msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8") - logfn = os.path.join(sdk_dir, 'preparing_build_system.log') - if os.path.exists(logfn): - msg += '\n\nContents of preparing_build_system.log:\n' - with open(logfn, 'r') as f: - for line in f: - msg += line - bb.fatal(msg) - - fail = False - sdk_envs = OESDKExtTestContextExecutor._get_sdk_environs(sdk_dir) - for s in sdk_envs: - bb.plain("Extensible SDK testing environment: %s" % s) - - sdk_env = sdk_envs[s] - - # Use our own SSTATE_DIR and DL_DIR so that updates to the eSDK come from our sstate cache - # and we don't spend hours downloading kernels for the kernel module test - # Abuse auto.conf since local.conf would be overwritten by the SDK - with open(os.path.join(sdk_dir, 'conf', 'auto.conf'), 'a+') as f: - f.write('SSTATE_MIRRORS += " \\n file://.* file://%s/PATH"\n' % test_data.get('SSTATE_DIR')) - f.write('SOURCE_MIRROR_URL = "file://%s"\n' % test_data.get('DL_DIR')) - f.write('INHERIT += "own-mirrors"\n') - f.write('PREMIRRORS_prepend = " git://git.yoctoproject.org/.* git://%s/git2/git.yoctoproject.org.BASENAME \\n "\n' % test_data.get('DL_DIR')) - - # We need to do this in case we have a minimal SDK - subprocess.check_output(". %s > /dev/null; devtool sdk-install meta-extsdk-toolchain" % \ - sdk_env, cwd=sdk_dir, shell=True, stderr=subprocess.STDOUT) - - tc = OESDKExtTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir, - sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest, - host_pkg_manifest=host_pkg_manifest) - - try: - tc.loadTests(OESDKExtTestContextExecutor.default_cases) - except Exception as e: - import traceback - bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) - - result = tc.runTests() - - component = "%s %s" % (pn, OESDKExtTestContextExecutor.name) - context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) - configuration = get_sdk_configuration(d, 'sdkext') - result.logDetails(get_sdk_json_result_dir(d), - configuration, - get_sdk_result_id(configuration)) - result.logSummary(component, context_msg) - - if not result.wasSuccessful(): - fail = True - - if fail: - bb.fatal("%s - FAILED - check the task log and the commands log" % pn) - -testsdkext_main[vardepsexclude] =+ "BB_ORIGENV" - python do_testsdkext() { - testsdkext_main(d) + import_and_run('TESTSDKEXT_CLASS_NAME', d) } -addtask testsdkext -do_testsdkext[nostamp] = "1" +do_testsdk[nostamp] = "1" python () { - if oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False"): - bb.build.addtask("testsdk", None, "do_populate_sdk", d) - bb.build.addtask("testsdkext", None, "do_populate_sdk_ext", d) + auto = oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False") + bb.build.addtask("testsdk", None, ("", "do_populate_sdk")[auto], d) + bb.build.addtask("testsdkext", None, ("", "do_populate_sdk_ext")[auto], d) } diff --git a/meta/lib/oeqa/sdk/testsdk.py b/meta/lib/oeqa/sdk/testsdk.py new file mode 100644 index 00000000000..6ff44f83f66 --- /dev/null +++ b/meta/lib/oeqa/sdk/testsdk.py @@ -0,0 +1,141 @@ +# Copyright 2018 by Garmin Ltd. or its subsidiaries +# Released under the MIT license (see COPYING.MIT) + +from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor + +class TestSDKBase(object): + @staticmethod + def get_sdk_configuration(d, test_type): + import platform + from oeqa.utils.metadata import get_layers + configuration = {'TEST_TYPE': test_type, + 'MACHINE': d.getVar("MACHINE"), + 'SDKMACHINE': d.getVar("SDKMACHINE"), + 'IMAGE_BASENAME': d.getVar("IMAGE_BASENAME"), + 'IMAGE_PKGTYPE': d.getVar("IMAGE_PKGTYPE"), + 'STARTTIME': d.getVar("DATETIME"), + 'HOST_DISTRO': ('-'.join(platform.linux_distribution())).replace(' ', '-'), + 'LAYERS': get_layers(d.getVar("BBLAYERS"))} + return configuration + + @staticmethod + def get_sdk_json_result_dir(d): + json_result_dir = os.path.join(d.getVar("LOG_DIR"), 'oeqa') + custom_json_result_dir = d.getVar("OEQA_JSON_RESULT_DIR") + if custom_json_result_dir: + json_result_dir = custom_json_result_dir + return json_result_dir + + @staticmethod + def get_sdk_result_id(configuration): + return '%s_%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['SDKMACHINE'], configuration['MACHINE'], configuration['STARTTIME']) + +class TestSDK(TestSDKBase): + context_executor_class = OESDKTestContextExecutor + context_class = OESDKTestContext + test_type = 'sdk' + + def get_tcname(self, d): + """ + Get the name of the SDK file + """ + return d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh") + + def extract_sdk(self, tcname, sdk_dir, d): + """ + Extract the SDK to the specified location + """ + import subprocess + + try: + subprocess.check_output("cd %s; %s <<EOF\n./\nY\nEOF" % (sdk_dir, tcname), shell=True) + except subprocess.CalledProcessError as e: + bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8")) + + def setup_context(self, d): + """ + Return a dictionary of additional arguments that should be passed to + the context_class on construction + """ + return dict() + + def run(self, d): + + import os + import subprocess + import json + import logging + + from bb.utils import export_proxies + from oeqa.utils import make_logger_bitbake_compatible + + pn = d.getVar("PN") + logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) + + # sdk use network for download projects for build + export_proxies(d) + + tcname = self.get_tcname(d) + + if not os.path.exists(tcname): + bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' ." % tcname) + + tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json") + test_data = json.load(open(tdname, "r")) + + target_pkg_manifest = self.context_executor_class._load_manifest( + d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest")) + host_pkg_manifest = self.context_executor_class._load_manifest( + d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest")) + + processes = d.getVar("TESTIMAGE_NUMBER_THREADS") or d.getVar("BB_NUMBER_THREADS") + if processes: + try: + import testtools, subunit + except ImportError: + bb.warn("Failed to import testtools or subunit, the testcases will run serially") + processes = None + + sdk_dir = d.expand("${WORKDIR}/testimage-sdk/") + bb.utils.remove(sdk_dir, True) + bb.utils.mkdirhier(sdk_dir) + + context_args = self.setup_context(d) + + self.extract_sdk(tcname, sdk_dir, d) + + fail = False + sdk_envs = self.context_executor_class._get_sdk_environs(sdk_dir) + for s in sdk_envs: + sdk_env = sdk_envs[s] + bb.plain("SDK testing environment: %s" % s) + tc = self.context_class(td=test_data, logger=logger, sdk_dir=sdk_dir, + sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest, + host_pkg_manifest=host_pkg_manifest, **context_args) + + try: + tc.loadTests(self.context_executor_class.default_cases) + except Exception as e: + import traceback + bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) + + if processes: + result = tc.runTests(processes=int(processes)) + else: + result = tc.runTests() + + component = "%s %s" % (pn, self.context_executor_class.name) + context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) + configuration = self.get_sdk_configuration(d, self.test_type) + result.logDetails(self.get_sdk_json_result_dir(d), + configuration, + self.get_sdk_result_id(configuration)) + result.logSummary(component, context_msg) + + if not result.wasSuccessful(): + fail = True + + if fail: + bb.fatal("%s - FAILED - check the task log and the commands log" % pn) + + diff --git a/meta/lib/oeqa/sdkext/testsdk.py b/meta/lib/oeqa/sdkext/testsdk.py new file mode 100644 index 00000000000..57b2e0e03f2 --- /dev/null +++ b/meta/lib/oeqa/sdkext/testsdk.py @@ -0,0 +1,104 @@ +# Copyright 2018 by Garmin Ltd. or its subsidiaries +# Released under the MIT license (see COPYING.MIT) + +from oeqa.sdk.testsdk import TestSDKBase + +class TestSDKExt(TestSDKBase): + def run(self, d): + import os + import json + import subprocess + import logging + + from bb.utils import export_proxies + from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible, subprocesstweak + from oeqa.sdkext.context import OESDKExtTestContext, OESDKExtTestContextExecutor + + pn = d.getVar("PN") + logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) + + # extensible sdk use network + export_proxies(d) + + subprocesstweak.errors_have_output() + + # extensible sdk can be contaminated if native programs are + # in PATH, i.e. use perl-native instead of eSDK one. + paths_to_avoid = [d.getVar('STAGING_DIR'), + d.getVar('BASE_WORKDIR')] + os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid) + + tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh") + if not os.path.exists(tcname): + bb.fatal("The toolchain ext %s is not built. Build it before running the" \ + " tests: 'bitbake <image> -c populate_sdk_ext' ." % tcname) + + tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.testdata.json") + test_data = json.load(open(tdname, "r")) + + target_pkg_manifest = OESDKExtTestContextExecutor._load_manifest( + d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest")) + host_pkg_manifest = OESDKExtTestContextExecutor._load_manifest( + d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest")) + + sdk_dir = d.expand("${WORKDIR}/testsdkext/") + bb.utils.remove(sdk_dir, True) + bb.utils.mkdirhier(sdk_dir) + try: + subprocess.check_output("%s -y -d %s" % (tcname, sdk_dir), shell=True) + except subprocess.CalledProcessError as e: + msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8") + logfn = os.path.join(sdk_dir, 'preparing_build_system.log') + if os.path.exists(logfn): + msg += '\n\nContents of preparing_build_system.log:\n' + with open(logfn, 'r') as f: + for line in f: + msg += line + bb.fatal(msg) + + fail = False + sdk_envs = OESDKExtTestContextExecutor._get_sdk_environs(sdk_dir) + for s in sdk_envs: + bb.plain("Extensible SDK testing environment: %s" % s) + + sdk_env = sdk_envs[s] + + # Use our own SSTATE_DIR and DL_DIR so that updates to the eSDK come from our sstate cache + # and we don't spend hours downloading kernels for the kernel module test + # Abuse auto.conf since local.conf would be overwritten by the SDK + with open(os.path.join(sdk_dir, 'conf', 'auto.conf'), 'a+') as f: + f.write('SSTATE_MIRRORS += " \\n file://.* file://%s/PATH"\n' % test_data.get('SSTATE_DIR')) + f.write('SOURCE_MIRROR_URL = "file://%s"\n' % test_data.get('DL_DIR')) + f.write('INHERIT += "own-mirrors"\n') + f.write('PREMIRRORS_prepend = " git://git.yoctoproject.org/.* git://%s/git2/git.yoctoproject.org.BASENAME \\n "\n' % test_data.get('DL_DIR')) + + # We need to do this in case we have a minimal SDK + subprocess.check_output(". %s > /dev/null; devtool sdk-install meta-extsdk-toolchain" % \ + sdk_env, cwd=sdk_dir, shell=True, stderr=subprocess.STDOUT) + + tc = OESDKExtTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir, + sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest, + host_pkg_manifest=host_pkg_manifest) + + try: + tc.loadTests(OESDKExtTestContextExecutor.default_cases) + except Exception as e: + import traceback + bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) + + result = tc.runTests() + + component = "%s %s" % (pn, OESDKExtTestContextExecutor.name) + context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) + configuration = self.get_sdk_configuration(d, 'sdkext') + result.logDetails(self.get_sdk_json_result_dir(d), + configuration, + self.get_sdk_result_id(configuration)) + result.logSummary(component, context_msg) + + if not result.wasSuccessful(): + fail = True + + if fail: + bb.fatal("%s - FAILED - check the task log and the commands log" % pn) + -- 2.19.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2] classes/testsdk: Split implementation into classes 2018-11-18 19:19 ` [PATCH v2] " Joshua Watt @ 2018-11-19 14:25 ` Richard Purdie 2018-11-19 16:33 ` Joshua Watt 2018-11-19 18:11 ` [PATCH v3] " Joshua Watt 1 sibling, 1 reply; 9+ messages in thread From: Richard Purdie @ 2018-11-19 14:25 UTC (permalink / raw) To: Joshua Watt, openembedded-core Thanks for reworking this, it does look a lot better and should stop some of the bbclass proliferation we're seeing. I assume all the code was functionally unchanged in the move? On Sun, 2018-11-18 at 13:19 -0600, Joshua Watt wrote: > python () { > - if oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False"): > - bb.build.addtask("testsdk", None, "do_populate_sdk", d) > - bb.build.addtask("testsdkext", None, "do_populate_sdk_ext", d) > + auto = oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False") > + bb.build.addtask("testsdk", None, ("", "do_populate_sdk")[auto], d) > + bb.build.addtask("testsdkext", None, ("", "do_populate_sdk_ext")[auto], d) > } This doesn't look like an improvement to code readability? :) Cheers, Richard ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] classes/testsdk: Split implementation into classes 2018-11-19 14:25 ` Richard Purdie @ 2018-11-19 16:33 ` Joshua Watt 0 siblings, 0 replies; 9+ messages in thread From: Joshua Watt @ 2018-11-19 16:33 UTC (permalink / raw) To: Richard Purdie, openembedded-core On Mon, 2018-11-19 at 14:25 +0000, Richard Purdie wrote: > Thanks for reworking this, it does look a lot better and should stop > some of the bbclass proliferation we're seeing. > > I assume all the code was functionally unchanged in the move? Correct. > > On Sun, 2018-11-18 at 13:19 -0600, Joshua Watt wrote: > > python () { > > - if oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False"): > > - bb.build.addtask("testsdk", None, "do_populate_sdk", d) > > - bb.build.addtask("testsdkext", None, > > "do_populate_sdk_ext", d) > > + auto = oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False") > > + bb.build.addtask("testsdk", None, ("", > > "do_populate_sdk")[auto], d) > > + bb.build.addtask("testsdkext", None, ("", > > "do_populate_sdk_ext")[auto], d) > > } > > This doesn't look like an improvement to code readability? :) It isn't. I will fix it with v3. > > Cheers, > > Richard > > > -- Joshua Watt <JPEWhacker@gmail.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3] classes/testsdk: Split implementation into classes 2018-11-18 19:19 ` [PATCH v2] " Joshua Watt 2018-11-19 14:25 ` Richard Purdie @ 2018-11-19 18:11 ` Joshua Watt 1 sibling, 0 replies; 9+ messages in thread From: Joshua Watt @ 2018-11-19 18:11 UTC (permalink / raw) To: openembedded-core Splits the SDK test implementation into configurable Python classes. The classes used for the normal and extensible SDKs are ${TESTSDK_CLASS_NAME} and ${TESTSDKEXT_CLASS_NAME} respectively. This allows SDK machines to override the classes used to implement the tests. For the traditional SDK, a common "run()" function is provided by the class (oeqa.sdk.testsdk.TestSDK), with several hook member functions that can be overridden in child classes, making it easier to have consistent behavior. The extensible SDK class (oeqa.sdkext.testsdk.TestSDKEXT) also has a common "run()" function, but no hooks have yet been added as there is not currently a known use case for create derived classes. These changes should be purely organizational; no functional changes have been made to either the standard SDK or extensible SDK tests. [YOCTO #13020] Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> --- meta/classes/testsdk.bbclass | 217 +++----------------------------- meta/lib/oeqa/sdk/testsdk.py | 142 +++++++++++++++++++++ meta/lib/oeqa/sdkext/testsdk.py | 104 +++++++++++++++ 3 files changed, 261 insertions(+), 202 deletions(-) create mode 100644 meta/lib/oeqa/sdk/testsdk.py create mode 100644 meta/lib/oeqa/sdkext/testsdk.py diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass index 458c3f40b04..758a23ac553 100644 --- a/meta/classes/testsdk.bbclass +++ b/meta/classes/testsdk.bbclass @@ -14,218 +14,31 @@ # # where "<image-name>" is an image like core-image-sato. -def get_sdk_configuration(d, test_type): - import platform - from oeqa.utils.metadata import get_layers - configuration = {'TEST_TYPE': test_type, - 'MACHINE': d.getVar("MACHINE"), - 'SDKMACHINE': d.getVar("SDKMACHINE"), - 'IMAGE_BASENAME': d.getVar("IMAGE_BASENAME"), - 'IMAGE_PKGTYPE': d.getVar("IMAGE_PKGTYPE"), - 'STARTTIME': d.getVar("DATETIME"), - 'HOST_DISTRO': oe.lsb.distro_identifier().replace(' ', '-'), - 'LAYERS': get_layers(d.getVar("BBLAYERS"))} - return configuration -get_sdk_configuration[vardepsexclude] = "DATETIME" +TESTSDK_CLASS_NAME ?= "oeqa.sdk.testsdk.TestSDK" +TESTSDKEXT_CLASS_NAME ?= "oeqa.sdkext.testsdk.TestSDKExt" -def get_sdk_json_result_dir(d): - json_result_dir = os.path.join(d.getVar("LOG_DIR"), 'oeqa') - custom_json_result_dir = d.getVar("OEQA_JSON_RESULT_DIR") - if custom_json_result_dir: - json_result_dir = custom_json_result_dir - return json_result_dir +def import_and_run(name, d): + import importlib -def get_sdk_result_id(configuration): - return '%s_%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['SDKMACHINE'], configuration['MACHINE'], configuration['STARTTIME']) + class_name = d.getVar(name) + if class_name: + module, cls = class_name.rsplit('.', 1) + m = importlib.import_module(module) + c = getattr(m, cls)() + c.run(d) + else: + bb.warn('No tests were run because %s did not define a class' % name) -def testsdk_main(d): - import os - import subprocess - import json - import logging - - from bb.utils import export_proxies - from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor - from oeqa.utils import make_logger_bitbake_compatible - - pn = d.getVar("PN") - logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) - - # sdk use network for download projects for build - export_proxies(d) - - tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh") - if not os.path.exists(tcname): - bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' ." % tcname) - - tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json") - test_data = json.load(open(tdname, "r")) - - target_pkg_manifest = OESDKTestContextExecutor._load_manifest( - d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest")) - host_pkg_manifest = OESDKTestContextExecutor._load_manifest( - d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest")) - - processes = d.getVar("TESTIMAGE_NUMBER_THREADS") or d.getVar("BB_NUMBER_THREADS") - if processes: - try: - import testtools, subunit - except ImportError: - bb.warn("Failed to import testtools or subunit, the testcases will run serially") - processes = None - - sdk_dir = d.expand("${WORKDIR}/testimage-sdk/") - bb.utils.remove(sdk_dir, True) - bb.utils.mkdirhier(sdk_dir) - try: - subprocess.check_output("cd %s; %s <<EOF\n./\nY\nEOF" % (sdk_dir, tcname), shell=True) - except subprocess.CalledProcessError as e: - bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8")) - - fail = False - sdk_envs = OESDKTestContextExecutor._get_sdk_environs(sdk_dir) - for s in sdk_envs: - sdk_env = sdk_envs[s] - bb.plain("SDK testing environment: %s" % s) - tc = OESDKTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir, - sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest, - host_pkg_manifest=host_pkg_manifest) - - try: - tc.loadTests(OESDKTestContextExecutor.default_cases) - except Exception as e: - import traceback - bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) - - if processes: - result = tc.runTests(processes=int(processes)) - else: - result = tc.runTests() - - component = "%s %s" % (pn, OESDKTestContextExecutor.name) - context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) - configuration = get_sdk_configuration(d, 'sdk') - result.logDetails(get_sdk_json_result_dir(d), - configuration, - get_sdk_result_id(configuration)) - result.logSummary(component, context_msg) - - if not result.wasSuccessful(): - fail = True - - if fail: - bb.fatal("%s - FAILED - check the task log and the commands log" % pn) - -testsdk_main[vardepsexclude] =+ "BB_ORIGENV" +import_and_run[vardepsexclude] = "DATETIME BB_ORIGENV" python do_testsdk() { - testsdk_main(d) + import_and_run('TESTSDK_CLASS_NAME', d) } addtask testsdk do_testsdk[nostamp] = "1" -def testsdkext_main(d): - import os - import json - import subprocess - import logging - - from bb.utils import export_proxies - from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible, subprocesstweak - from oeqa.sdkext.context import OESDKExtTestContext, OESDKExtTestContextExecutor - - pn = d.getVar("PN") - logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) - - # extensible sdk use network - export_proxies(d) - - subprocesstweak.errors_have_output() - - # extensible sdk can be contaminated if native programs are - # in PATH, i.e. use perl-native instead of eSDK one. - paths_to_avoid = [d.getVar('STAGING_DIR'), - d.getVar('BASE_WORKDIR')] - os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid) - - tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh") - if not os.path.exists(tcname): - bb.fatal("The toolchain ext %s is not built. Build it before running the" \ - " tests: 'bitbake <image> -c populate_sdk_ext' ." % tcname) - - tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.testdata.json") - test_data = json.load(open(tdname, "r")) - - target_pkg_manifest = OESDKExtTestContextExecutor._load_manifest( - d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest")) - host_pkg_manifest = OESDKExtTestContextExecutor._load_manifest( - d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest")) - - sdk_dir = d.expand("${WORKDIR}/testsdkext/") - bb.utils.remove(sdk_dir, True) - bb.utils.mkdirhier(sdk_dir) - try: - subprocess.check_output("%s -y -d %s" % (tcname, sdk_dir), shell=True) - except subprocess.CalledProcessError as e: - msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8") - logfn = os.path.join(sdk_dir, 'preparing_build_system.log') - if os.path.exists(logfn): - msg += '\n\nContents of preparing_build_system.log:\n' - with open(logfn, 'r') as f: - for line in f: - msg += line - bb.fatal(msg) - - fail = False - sdk_envs = OESDKExtTestContextExecutor._get_sdk_environs(sdk_dir) - for s in sdk_envs: - bb.plain("Extensible SDK testing environment: %s" % s) - - sdk_env = sdk_envs[s] - - # Use our own SSTATE_DIR and DL_DIR so that updates to the eSDK come from our sstate cache - # and we don't spend hours downloading kernels for the kernel module test - # Abuse auto.conf since local.conf would be overwritten by the SDK - with open(os.path.join(sdk_dir, 'conf', 'auto.conf'), 'a+') as f: - f.write('SSTATE_MIRRORS += " \\n file://.* file://%s/PATH"\n' % test_data.get('SSTATE_DIR')) - f.write('SOURCE_MIRROR_URL = "file://%s"\n' % test_data.get('DL_DIR')) - f.write('INHERIT += "own-mirrors"\n') - f.write('PREMIRRORS_prepend = " git://git.yoctoproject.org/.* git://%s/git2/git.yoctoproject.org.BASENAME \\n "\n' % test_data.get('DL_DIR')) - - # We need to do this in case we have a minimal SDK - subprocess.check_output(". %s > /dev/null; devtool sdk-install meta-extsdk-toolchain" % \ - sdk_env, cwd=sdk_dir, shell=True, stderr=subprocess.STDOUT) - - tc = OESDKExtTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir, - sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest, - host_pkg_manifest=host_pkg_manifest) - - try: - tc.loadTests(OESDKExtTestContextExecutor.default_cases) - except Exception as e: - import traceback - bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) - - result = tc.runTests() - - component = "%s %s" % (pn, OESDKExtTestContextExecutor.name) - context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) - configuration = get_sdk_configuration(d, 'sdkext') - result.logDetails(get_sdk_json_result_dir(d), - configuration, - get_sdk_result_id(configuration)) - result.logSummary(component, context_msg) - - if not result.wasSuccessful(): - fail = True - - if fail: - bb.fatal("%s - FAILED - check the task log and the commands log" % pn) - -testsdkext_main[vardepsexclude] =+ "BB_ORIGENV" - python do_testsdkext() { - testsdkext_main(d) + import_and_run('TESTSDKEXT_CLASS_NAME', d) } addtask testsdkext do_testsdkext[nostamp] = "1" diff --git a/meta/lib/oeqa/sdk/testsdk.py b/meta/lib/oeqa/sdk/testsdk.py new file mode 100644 index 00000000000..632ac50d0cb --- /dev/null +++ b/meta/lib/oeqa/sdk/testsdk.py @@ -0,0 +1,142 @@ +# Copyright 2018 by Garmin Ltd. or its subsidiaries +# Released under the MIT license (see COPYING.MIT) + +from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor + +class TestSDKBase(object): + @staticmethod + def get_sdk_configuration(d, test_type): + import platform + import oe.lsb + from oeqa.utils.metadata import get_layers + configuration = {'TEST_TYPE': test_type, + 'MACHINE': d.getVar("MACHINE"), + 'SDKMACHINE': d.getVar("SDKMACHINE"), + 'IMAGE_BASENAME': d.getVar("IMAGE_BASENAME"), + 'IMAGE_PKGTYPE': d.getVar("IMAGE_PKGTYPE"), + 'STARTTIME': d.getVar("DATETIME"), + 'HOST_DISTRO': oe.lsb.distro_identifier().replace(' ', '-'), + 'LAYERS': get_layers(d.getVar("BBLAYERS"))} + return configuration + + @staticmethod + def get_sdk_json_result_dir(d): + json_result_dir = os.path.join(d.getVar("LOG_DIR"), 'oeqa') + custom_json_result_dir = d.getVar("OEQA_JSON_RESULT_DIR") + if custom_json_result_dir: + json_result_dir = custom_json_result_dir + return json_result_dir + + @staticmethod + def get_sdk_result_id(configuration): + return '%s_%s_%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['SDKMACHINE'], configuration['MACHINE'], configuration['STARTTIME']) + +class TestSDK(TestSDKBase): + context_executor_class = OESDKTestContextExecutor + context_class = OESDKTestContext + test_type = 'sdk' + + def get_tcname(self, d): + """ + Get the name of the SDK file + """ + return d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh") + + def extract_sdk(self, tcname, sdk_dir, d): + """ + Extract the SDK to the specified location + """ + import subprocess + + try: + subprocess.check_output("cd %s; %s <<EOF\n./\nY\nEOF" % (sdk_dir, tcname), shell=True) + except subprocess.CalledProcessError as e: + bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8")) + + def setup_context(self, d): + """ + Return a dictionary of additional arguments that should be passed to + the context_class on construction + """ + return dict() + + def run(self, d): + + import os + import subprocess + import json + import logging + + from bb.utils import export_proxies + from oeqa.utils import make_logger_bitbake_compatible + + pn = d.getVar("PN") + logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) + + # sdk use network for download projects for build + export_proxies(d) + + tcname = self.get_tcname(d) + + if not os.path.exists(tcname): + bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' ." % tcname) + + tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json") + test_data = json.load(open(tdname, "r")) + + target_pkg_manifest = self.context_executor_class._load_manifest( + d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest")) + host_pkg_manifest = self.context_executor_class._load_manifest( + d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest")) + + processes = d.getVar("TESTIMAGE_NUMBER_THREADS") or d.getVar("BB_NUMBER_THREADS") + if processes: + try: + import testtools, subunit + except ImportError: + bb.warn("Failed to import testtools or subunit, the testcases will run serially") + processes = None + + sdk_dir = d.expand("${WORKDIR}/testimage-sdk/") + bb.utils.remove(sdk_dir, True) + bb.utils.mkdirhier(sdk_dir) + + context_args = self.setup_context(d) + + self.extract_sdk(tcname, sdk_dir, d) + + fail = False + sdk_envs = self.context_executor_class._get_sdk_environs(sdk_dir) + for s in sdk_envs: + sdk_env = sdk_envs[s] + bb.plain("SDK testing environment: %s" % s) + tc = self.context_class(td=test_data, logger=logger, sdk_dir=sdk_dir, + sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest, + host_pkg_manifest=host_pkg_manifest, **context_args) + + try: + tc.loadTests(self.context_executor_class.default_cases) + except Exception as e: + import traceback + bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) + + if processes: + result = tc.runTests(processes=int(processes)) + else: + result = tc.runTests() + + component = "%s %s" % (pn, self.context_executor_class.name) + context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) + configuration = self.get_sdk_configuration(d, self.test_type) + result.logDetails(self.get_sdk_json_result_dir(d), + configuration, + self.get_sdk_result_id(configuration)) + result.logSummary(component, context_msg) + + if not result.wasSuccessful(): + fail = True + + if fail: + bb.fatal("%s - FAILED - check the task log and the commands log" % pn) + + diff --git a/meta/lib/oeqa/sdkext/testsdk.py b/meta/lib/oeqa/sdkext/testsdk.py new file mode 100644 index 00000000000..57b2e0e03f2 --- /dev/null +++ b/meta/lib/oeqa/sdkext/testsdk.py @@ -0,0 +1,104 @@ +# Copyright 2018 by Garmin Ltd. or its subsidiaries +# Released under the MIT license (see COPYING.MIT) + +from oeqa.sdk.testsdk import TestSDKBase + +class TestSDKExt(TestSDKBase): + def run(self, d): + import os + import json + import subprocess + import logging + + from bb.utils import export_proxies + from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible, subprocesstweak + from oeqa.sdkext.context import OESDKExtTestContext, OESDKExtTestContextExecutor + + pn = d.getVar("PN") + logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) + + # extensible sdk use network + export_proxies(d) + + subprocesstweak.errors_have_output() + + # extensible sdk can be contaminated if native programs are + # in PATH, i.e. use perl-native instead of eSDK one. + paths_to_avoid = [d.getVar('STAGING_DIR'), + d.getVar('BASE_WORKDIR')] + os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid) + + tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh") + if not os.path.exists(tcname): + bb.fatal("The toolchain ext %s is not built. Build it before running the" \ + " tests: 'bitbake <image> -c populate_sdk_ext' ." % tcname) + + tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.testdata.json") + test_data = json.load(open(tdname, "r")) + + target_pkg_manifest = OESDKExtTestContextExecutor._load_manifest( + d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest")) + host_pkg_manifest = OESDKExtTestContextExecutor._load_manifest( + d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest")) + + sdk_dir = d.expand("${WORKDIR}/testsdkext/") + bb.utils.remove(sdk_dir, True) + bb.utils.mkdirhier(sdk_dir) + try: + subprocess.check_output("%s -y -d %s" % (tcname, sdk_dir), shell=True) + except subprocess.CalledProcessError as e: + msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8") + logfn = os.path.join(sdk_dir, 'preparing_build_system.log') + if os.path.exists(logfn): + msg += '\n\nContents of preparing_build_system.log:\n' + with open(logfn, 'r') as f: + for line in f: + msg += line + bb.fatal(msg) + + fail = False + sdk_envs = OESDKExtTestContextExecutor._get_sdk_environs(sdk_dir) + for s in sdk_envs: + bb.plain("Extensible SDK testing environment: %s" % s) + + sdk_env = sdk_envs[s] + + # Use our own SSTATE_DIR and DL_DIR so that updates to the eSDK come from our sstate cache + # and we don't spend hours downloading kernels for the kernel module test + # Abuse auto.conf since local.conf would be overwritten by the SDK + with open(os.path.join(sdk_dir, 'conf', 'auto.conf'), 'a+') as f: + f.write('SSTATE_MIRRORS += " \\n file://.* file://%s/PATH"\n' % test_data.get('SSTATE_DIR')) + f.write('SOURCE_MIRROR_URL = "file://%s"\n' % test_data.get('DL_DIR')) + f.write('INHERIT += "own-mirrors"\n') + f.write('PREMIRRORS_prepend = " git://git.yoctoproject.org/.* git://%s/git2/git.yoctoproject.org.BASENAME \\n "\n' % test_data.get('DL_DIR')) + + # We need to do this in case we have a minimal SDK + subprocess.check_output(". %s > /dev/null; devtool sdk-install meta-extsdk-toolchain" % \ + sdk_env, cwd=sdk_dir, shell=True, stderr=subprocess.STDOUT) + + tc = OESDKExtTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir, + sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest, + host_pkg_manifest=host_pkg_manifest) + + try: + tc.loadTests(OESDKExtTestContextExecutor.default_cases) + except Exception as e: + import traceback + bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) + + result = tc.runTests() + + component = "%s %s" % (pn, OESDKExtTestContextExecutor.name) + context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) + configuration = self.get_sdk_configuration(d, 'sdkext') + result.logDetails(self.get_sdk_json_result_dir(d), + configuration, + self.get_sdk_result_id(configuration)) + result.logSummary(component, context_msg) + + if not result.wasSuccessful(): + fail = True + + if fail: + bb.fatal("%s - FAILED - check the task log and the commands log" % pn) + -- 2.19.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* ✗ patchtest: failure for classes/testsdk: Split implementation into classes (rev2) 2018-11-15 19:14 [PATCH] classes/testsdk: Split implementation into classes Joshua Watt 2018-11-15 19:40 ` Richard Purdie 2018-11-18 19:19 ` [PATCH v2] " Joshua Watt @ 2018-11-18 19:33 ` Patchwork 2 siblings, 0 replies; 9+ messages in thread From: Patchwork @ 2018-11-18 19:33 UTC (permalink / raw) To: Joshua Watt; +Cc: openembedded-core == Series Details == Series: classes/testsdk: Split implementation into classes (rev2) Revision: 2 URL : https://patchwork.openembedded.org/series/14944/ State : failure == Summary == Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures: * Issue Series does not apply on top of target branch [test_series_merge_on_head] Suggested fix Rebase your series on top of targeted branch Targeted branch master (currently at 62fe04c245) If you believe any of these test results are incorrect, please reply to the mailing list (openembedded-core@lists.openembedded.org) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...). --- Guidelines: https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest Test suite: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-11-19 18:11 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-11-15 19:14 [PATCH] classes/testsdk: Split implementation into classes Joshua Watt 2018-11-15 19:40 ` Richard Purdie 2018-11-15 22:28 ` Joshua Watt 2018-11-15 22:48 ` richard.purdie 2018-11-18 19:19 ` [PATCH v2] " Joshua Watt 2018-11-19 14:25 ` Richard Purdie 2018-11-19 16:33 ` Joshua Watt 2018-11-19 18:11 ` [PATCH v3] " Joshua Watt 2018-11-18 19:33 ` ✗ patchtest: failure for classes/testsdk: Split implementation into classes (rev2) Patchwork
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox