classes/testsdk: Migrates testsdk.bbclass to use new OESDKTestContext
The functionality provided is the same with imporvements on code reuse and better interfaces. (From OE-Core rev: 7a1ae3149965b162fb2c71fc7067e07a7a189249) 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:
parent
8a37763ae9
commit
92c57a5db7
|
@ -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,12 +133,12 @@ TESTSDKEXTLOCK = "${TMPDIR}/testsdkext.lock"
|
|||
|
||||
def testsdkext_main(d):
|
||||
import os
|
||||
import oeqa.sdkext
|
||||
import json
|
||||
import subprocess
|
||||
from bb.utils import export_proxies
|
||||
from oeqa.oetest import SDKTestContext, SDKExtTestContext
|
||||
from oeqa.utils import avoid_paths_in_environ
|
||||
import logging
|
||||
|
||||
from bb.utils import export_proxies
|
||||
from oeqa.utils import avoid_paths_in_environ
|
||||
|
||||
# extensible sdk use network
|
||||
export_proxies(d)
|
||||
|
|
Loading…
Reference in New Issue