diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-07-31 11:23:22 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-01 07:34:04 +0100 |
commit | f351c031a920834c0b8ff44c6be5dfa8bebf4885 (patch) | |
tree | 14fb14e3ae2c10e57737827c922931c82bc82b56 /meta/classes/testimage.bbclass | |
parent | 93360e8a1c0657542bb0536ad0281389d89b2d5d (diff) | |
download | poky-f351c031a920834c0b8ff44c6be5dfa8bebf4885.tar.gz |
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>
Diffstat (limited to 'meta/classes/testimage.bbclass')
-rw-r--r-- | meta/classes/testimage.bbclass | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index 2b655b49fa..140babed74 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass | |||
@@ -296,19 +296,9 @@ def testsdk_main(d): | |||
296 | testslist = get_tests_list(d, "sdk") | 296 | testslist = get_tests_list(d, "sdk") |
297 | testsrequired = [t for t in (d.getVar("TEST_SUITES_SDK", True) or "auto").split() if t != "auto"] | 297 | testsrequired = [t for t in (d.getVar("TEST_SUITES_SDK", True) or "auto").split() if t != "auto"] |
298 | 298 | ||
299 | sdktestdir = d.expand("${WORKDIR}/testimage-sdk/") | ||
300 | bb.utils.remove(sdktestdir, True) | ||
301 | bb.utils.mkdirhier(sdktestdir) | ||
302 | |||
303 | tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh") | 299 | tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh") |
304 | if not os.path.exists(tcname): | 300 | if not os.path.exists(tcname): |
305 | bb.fatal("The toolchain is not built. Build it before running the tests: 'bitbake meta-toolchain' .") | 301 | bb.fatal("The toolchain is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' .") |
306 | subprocess.call("cd %s; %s <<EOF\n./tc\nY\nEOF" % (sdktestdir, tcname), shell=True) | ||
307 | |||
308 | targets = glob.glob(d.expand(sdktestdir + "/tc/sysroots/*${TARGET_VENDOR}-linux*")) | ||
309 | if len(targets) > 1: | ||
310 | bb.fatal("Error, multiple targets within the SDK found and we don't know which to test? %s" % str(targets)) | ||
311 | sdkenv = sdktestdir + "/tc/environment-setup-" + os.path.basename(targets[0]) | ||
312 | 302 | ||
313 | class TestContext(object): | 303 | class TestContext(object): |
314 | def __init__(self): | 304 | def __init__(self): |
@@ -333,33 +323,42 @@ def testsdk_main(d): | |||
333 | except IOError as e: | 323 | except IOError as e: |
334 | bb.fatal("No host package manifest file found. Did you build the sdk image?\n%s" % e) | 324 | bb.fatal("No host package manifest file found. Did you build the sdk image?\n%s" % e) |
335 | 325 | ||
336 | # test context | 326 | sdktestdir = d.expand("${WORKDIR}/testimage-sdk/") |
337 | tc = TestContext() | 327 | bb.utils.remove(sdktestdir, True) |
328 | bb.utils.mkdirhier(sdktestdir) | ||
329 | subprocess.call("cd %s; %s <<EOF\n./tc\nY\nEOF" % (sdktestdir, tcname), shell=True) | ||
338 | 330 | ||
339 | # this is a dummy load of tests | ||
340 | # we are doing that to find compile errors in the tests themselves | ||
341 | # before booting the image | ||
342 | try: | 331 | try: |
343 | loadTests(tc, "sdk") | 332 | targets = glob.glob(d.expand(sdktestdir + "/tc/environment-setup-*")) |
344 | except Exception as e: | 333 | bb.warn(str(targets)) |
345 | import traceback | 334 | for sdkenv in targets: |
346 | bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) | 335 | bb.plain("Testing %s" % sdkenv) |
336 | # test context | ||
337 | tc = TestContext() | ||
338 | |||
339 | # this is a dummy load of tests | ||
340 | # we are doing that to find compile errors in the tests themselves | ||
341 | # before booting the image | ||
342 | try: | ||
343 | loadTests(tc, "sdk") | ||
344 | except Exception as e: | ||
345 | import traceback | ||
346 | bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) | ||
347 | 347 | ||
348 | try: | 348 | |
349 | starttime = time.time() | 349 | starttime = time.time() |
350 | result = runTests(tc, "sdk") | 350 | result = runTests(tc, "sdk") |
351 | stoptime = time.time() | 351 | stoptime = time.time() |
352 | if result.wasSuccessful(): | 352 | if result.wasSuccessful(): |
353 | bb.plain("%s - Ran %d test%s in %.3fs" % (pn, result.testsRun, result.testsRun != 1 and "s" or "", stoptime - starttime)) | 353 | 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)) |
354 | msg = "%s - OK - All required tests passed" % pn | 354 | msg = "%s - OK - All required tests passed" % pn |
355 | skipped = len(result.skipped) | 355 | skipped = len(result.skipped) |
356 | if skipped: | 356 | if skipped: |
357 | msg += " (skipped=%d)" % skipped | 357 | msg += " (skipped=%d)" % skipped |
358 | bb.plain(msg) | 358 | bb.plain(msg) |
359 | else: | 359 | else: |
360 | raise bb.build.FuncFailed("%s - FAILED - check the task log and the commands log" % pn ) | 360 | raise bb.build.FuncFailed("%s - FAILED - check the task log and the commands log" % pn ) |
361 | finally: | 361 | finally: |
362 | pass | ||
363 | bb.utils.remove(sdktestdir, True) | 362 | bb.utils.remove(sdktestdir, True) |
364 | 363 | ||
365 | testsdk_main[vardepsexclude] =+ "BB_ORIGENV" | 364 | testsdk_main[vardepsexclude] =+ "BB_ORIGENV" |