1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 13:29:49 +00:00

testimage: testsdk fixes/improvements

The "bitbake meta-toolchain" comment is dated and incorrect, fix to
point at -c populate_sdk.

If a toolchain contains multiple environment files, iterate them and run
the sdk test suite on each on in turn rather than giving a fatal error and
giving up.

Also improve the debug output so that rather than PN, it also show the
toolchain tarball under test, and the environment file name its using.

Also enable the accidentally disabled cleanup code.

(From OE-Core rev: 44c8b1bd58397db85e6f7bb9a57f0d57d2c69ad5)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2015-07-31 11:23:22 +01:00
parent 93360e8a1c
commit f351c031a9
+34 -35
View File
@@ -296,19 +296,9 @@ def testsdk_main(d):
testslist = get_tests_list(d, "sdk") testslist = get_tests_list(d, "sdk")
testsrequired = [t for t in (d.getVar("TEST_SUITES_SDK", True) or "auto").split() if t != "auto"] testsrequired = [t for t in (d.getVar("TEST_SUITES_SDK", True) or "auto").split() if t != "auto"]
sdktestdir = d.expand("${WORKDIR}/testimage-sdk/")
bb.utils.remove(sdktestdir, True)
bb.utils.mkdirhier(sdktestdir)
tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh") tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh")
if not os.path.exists(tcname): if not os.path.exists(tcname):
bb.fatal("The toolchain is not built. Build it before running the tests: 'bitbake meta-toolchain' .") bb.fatal("The toolchain is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' .")
subprocess.call("cd %s; %s <<EOF\n./tc\nY\nEOF" % (sdktestdir, tcname), shell=True)
targets = glob.glob(d.expand(sdktestdir + "/tc/sysroots/*${TARGET_VENDOR}-linux*"))
if len(targets) > 1:
bb.fatal("Error, multiple targets within the SDK found and we don't know which to test? %s" % str(targets))
sdkenv = sdktestdir + "/tc/environment-setup-" + os.path.basename(targets[0])
class TestContext(object): class TestContext(object):
def __init__(self): def __init__(self):
@@ -333,33 +323,42 @@ def testsdk_main(d):
except IOError as e: except IOError as e:
bb.fatal("No host package manifest file found. Did you build the sdk image?\n%s" % e) bb.fatal("No host package manifest file found. Did you build the sdk image?\n%s" % e)
# test context sdktestdir = d.expand("${WORKDIR}/testimage-sdk/")
tc = TestContext() bb.utils.remove(sdktestdir, True)
bb.utils.mkdirhier(sdktestdir)
# this is a dummy load of tests subprocess.call("cd %s; %s <<EOF\n./tc\nY\nEOF" % (sdktestdir, tcname), shell=True)
# we are doing that to find compile errors in the tests themselves
# before booting the image
try:
loadTests(tc, "sdk")
except Exception as e:
import traceback
bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
try: try:
starttime = time.time() targets = glob.glob(d.expand(sdktestdir + "/tc/environment-setup-*"))
result = runTests(tc, "sdk") bb.warn(str(targets))
stoptime = time.time() for sdkenv in targets:
if result.wasSuccessful(): bb.plain("Testing %s" % sdkenv)
bb.plain("%s - Ran %d test%s in %.3fs" % (pn, result.testsRun, result.testsRun != 1 and "s" or "", stoptime - starttime)) # test context
msg = "%s - OK - All required tests passed" % pn tc = TestContext()
skipped = len(result.skipped)
if skipped: # this is a dummy load of tests
msg += " (skipped=%d)" % skipped # we are doing that to find compile errors in the tests themselves
bb.plain(msg) # before booting the image
else: try:
raise bb.build.FuncFailed("%s - FAILED - check the task log and the commands log" % pn ) loadTests(tc, "sdk")
except Exception as e:
import traceback
bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
starttime = time.time()
result = runTests(tc, "sdk")
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:
raise bb.build.FuncFailed("%s - FAILED - check the task log and the commands log" % pn )
finally: finally:
pass
bb.utils.remove(sdktestdir, True) bb.utils.remove(sdktestdir, True)
testsdk_main[vardepsexclude] =+ "BB_ORIGENV" testsdk_main[vardepsexclude] =+ "BB_ORIGENV"