1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-31 12:49:46 +00:00

classes/testsdk: Migrate to use the new OESDKExtTestContext

(From OE-Core rev: b254822dad850ce74563c83b7a9e31463501baa7)

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Aníbal Limón
2016-11-30 15:11:40 -06:00
committed by Richard Purdie
parent 14eee4fdf8
commit 03d175f1fa
+45 -53
View File
@@ -16,37 +16,6 @@
TESTSDKLOCK = "${TMPDIR}/testsdk.lock" TESTSDKLOCK = "${TMPDIR}/testsdk.lock"
def run_test_context(CTestContext, d, testdir, tcname, pn, *args):
import glob
import time
targets = glob.glob(d.expand(testdir + "/tc/environment-setup-*"))
for sdkenv in targets:
bb.plain("Testing %s" % sdkenv)
tc = CTestContext(d, testdir, sdkenv, tcname, args)
# this is a dummy load of tests
# we are doing that to find compile errors in the tests themselves
# before booting the image
try:
tc.loadTests()
except Exception as e:
import traceback
bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
starttime = time.time()
result = tc.runTests()
stoptime = time.time()
if result.wasSuccessful():
bb.plain("%s SDK(%s):%s - Ran %d test%s in %.3fs" % (pn, os.path.basename(tcname), os.path.basename(sdkenv),result.testsRun, result.testsRun != 1 and "s" or "", stoptime - starttime))
msg = "%s - OK - All required tests passed" % pn
skipped = len(result.skipped)
if skipped:
msg += " (skipped=%d)" % skipped
bb.plain(msg)
else:
bb.fatal("%s - FAILED - check the task log and the commands log" % pn)
def testsdk_main(d): def testsdk_main(d):
import os import os
import subprocess import subprocess
@@ -122,7 +91,6 @@ addtask testsdk
do_testsdk[nostamp] = "1" do_testsdk[nostamp] = "1"
do_testsdk[lockfiles] += "${TESTSDKLOCK}" do_testsdk[lockfiles] += "${TESTSDKLOCK}"
TEST_LOG_SDKEXT_DIR ?= "${WORKDIR}/testsdkext"
TESTSDKEXTLOCK = "${TMPDIR}/testsdkext.lock" TESTSDKEXTLOCK = "${TMPDIR}/testsdkext.lock"
def testsdkext_main(d): def testsdkext_main(d):
@@ -132,7 +100,11 @@ def testsdkext_main(d):
import logging import logging
from bb.utils import export_proxies from bb.utils import export_proxies
from oeqa.utils import avoid_paths_in_environ from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible
from oeqa.sdkext.context import OESDKExtTestContext, OESDKExtTestContextExecutor
pn = d.getVar("PN", True)
logger = make_logger_bitbake_compatible(logging.getLogger("BitBake"))
# extensible sdk use network # extensible sdk use network
export_proxies(d) export_proxies(d)
@@ -143,23 +115,27 @@ def testsdkext_main(d):
d.getVar('BASE_WORKDIR')] d.getVar('BASE_WORKDIR')]
os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid) os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid)
pn = d.getVar("PN")
bb.utils.mkdirhier(d.getVar("TEST_LOG_SDKEXT_DIR"))
tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh") tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh")
if not os.path.exists(tcname): if not os.path.exists(tcname):
bb.fatal("The toolchain ext %s is not built. Build it before running the" \ bb.fatal("The toolchain ext %s is not built. Build it before running the" \
" tests: 'bitbake <image> -c populate_sdk_ext' ." % tcname) " tests: 'bitbake <image> -c populate_sdk_ext' ." % tcname)
testdir = d.expand("${WORKDIR}/testsdkext/") tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.testdata.json")
bb.utils.remove(testdir, True) test_data = json.load(open(tdname, "r"))
bb.utils.mkdirhier(testdir)
sdkdir = os.path.join(testdir, 'tc') 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: try:
subprocess.check_output("%s -y -d %s" % (tcname, sdkdir), shell=True) subprocess.check_output("%s -y -d %s" % (tcname, sdk_dir), shell=True)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8") msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8")
logfn = os.path.join(sdkdir, 'preparing_build_system.log') logfn = os.path.join(sdk_dir, 'preparing_build_system.log')
if os.path.exists(logfn): if os.path.exists(logfn):
msg += '\n\nContents of preparing_build_system.log:\n' msg += '\n\nContents of preparing_build_system.log:\n'
with open(logfn, 'r') as f: with open(logfn, 'r') as f:
@@ -167,19 +143,35 @@ def testsdkext_main(d):
msg += line msg += line
bb.fatal(msg) bb.fatal(msg)
try: fail = False
bb.plain("Running SDK Compatibility tests ...") sdk_envs = OESDKExtTestContextExecutor._get_sdk_environs(sdk_dir)
run_test_context(SDKExtTestContext, d, testdir, tcname, pn, True) for s in sdk_envs:
finally: bb.plain("Extensible SDK testing environment: %s" % s)
pass
try: sdk_env = sdk_envs[s]
bb.plain("Running Extensible SDK tests ...") tc = OESDKExtTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir,
run_test_context(SDKExtTestContext, d, testdir, tcname, pn) sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest,
finally: host_pkg_manifest=host_pkg_manifest)
pass
bb.utils.remove(testdir, True) 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))
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)
testsdkext_main[vardepsexclude] =+ "BB_ORIGENV" testsdkext_main[vardepsexclude] =+ "BB_ORIGENV"