diff options
author | Aníbal Limón <anibal.limon@linux.intel.com> | 2016-11-30 10:56:09 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-23 12:03:54 +0000 |
commit | 7a1ae3149965b162fb2c71fc7067e07a7a189249 (patch) | |
tree | 0b2788c576bdefb0947b8fd6ffad86fa25bae334 | |
parent | 19e875dd81c42841666e6db5f6b665b4e1cddfe6 (diff) | |
download | openembedded-core-7a1ae3149965b162fb2c71fc7067e07a7a189249.tar.gz openembedded-core-7a1ae3149965b162fb2c71fc7067e07a7a189249.tar.bz2 openembedded-core-7a1ae3149965b162fb2c71fc7067e07a7a189249.zip |
classes/testsdk: Migrates testsdk.bbclass to use new OESDKTestContext
The functionality provided is the same with imporvements on code
reuse and better interfaces.
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
-rw-r--r-- | meta/classes/testsdk.bbclass | 75 |
1 files changed, 60 insertions, 15 deletions
diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass index 063b9080a5..7304129b49 100644 --- a/meta/classes/testsdk.bbclass +++ b/meta/classes/testsdk.bbclass @@ -50,30 +50,75 @@ def run_test_context(CTestContext, d, testdir, tcname, pn, *args): def testsdk_main(d): import os - import oeqa.sdk import subprocess - from oeqa.oetest import SDKTestContext + import json + import logging - pn = d.getVar("PN") - bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR")) + from bb.utils import export_proxies + from oeqa.core.runner import OEStreamLogger + from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor + from oeqa.utils import make_logger_bitbake_compatible + + pn = d.getVar("PN", True) + logger = make_logger_bitbake_compatible(logging.getLogger("BitBake")) + + # sdk use network for download projects for build + export_proxies(d) + + test_log_dir = d.getVar("TEST_LOG_DIR", True) + + bb.utils.mkdirhier(test_log_dir) 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) - sdktestdir = d.expand("${WORKDIR}/testimage-sdk/") - bb.utils.remove(sdktestdir, True) - bb.utils.mkdirhier(sdktestdir) + tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json") + test_data = json.load(open(tdname, "r")) + test_data['TEST_LOG_DIR'] = test_log_dir + + 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")) + + 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./tc\nY\nEOF" % (sdktestdir, tcname), shell=True) + 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")) - try: - run_test_context(SDKTestContext, d, sdktestdir, tcname, pn) - finally: - bb.utils.remove(sdktestdir, True) + 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()) + + result = tc.runTests() + + component = "%s %s" % (pn, OESDKTestContextExecutor.name) + context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) + + tc.logSummary(result, component, context_msg) + tc.logDetails() + + 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() { @@ -88,13 +133,13 @@ TESTSDKEXTLOCK = "${TMPDIR}/testsdkext.lock" def testsdkext_main(d): import os - import oeqa.sdkext + import json import subprocess + import logging + from bb.utils import export_proxies - from oeqa.oetest import SDKTestContext, SDKExtTestContext from oeqa.utils import avoid_paths_in_environ - # extensible sdk use network export_proxies(d) |