diff options
Diffstat (limited to 'poky/meta/classes/testimage.bbclass')
-rw-r--r-- | poky/meta/classes/testimage.bbclass | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/poky/meta/classes/testimage.bbclass b/poky/meta/classes/testimage.bbclass index deb81bc256..c709384b91 100644 --- a/poky/meta/classes/testimage.bbclass +++ b/poky/meta/classes/testimage.bbclass @@ -31,6 +31,7 @@ TESTIMAGE_AUTO ??= "0" # TEST_LOG_DIR contains a command ssh log and may contain infromation about what command is running, output and return codes and for qemu a boot log till login. # Booting is handled by this class, and it's not a test in itself. # TEST_QEMUBOOT_TIMEOUT can be used to set the maximum time in seconds the launch code will wait for the login prompt. +# TEST_OVERALL_TIMEOUT can be used to set the maximum time in seconds the tests will be allowed to run (defaults to no limit). # TEST_QEMUPARAMS can be used to pass extra parameters to qemu, e.g. "-m 1024" for setting the amount of ram to 1 GB. # TEST_RUNQEMUPARAMS can be used to pass extra parameters to runqemu, e.g. "gl" to enable OpenGL acceleration. @@ -75,6 +76,7 @@ DEFAULT_TEST_SUITES_remove_qemumips64 = "${MIPSREMOVE}" TEST_SUITES ?= "${DEFAULT_TEST_SUITES}" TEST_QEMUBOOT_TIMEOUT ?= "1000" +TEST_OVERALL_TIMEOUT ?= "" TEST_TARGET ?= "qemu" TEST_QEMUPARAMS ?= "" TEST_RUNQEMUPARAMS ?= "" @@ -206,6 +208,10 @@ def testimage_main(d): """ os.kill(os.getpid(), signal.SIGINT) + def handle_test_timeout(timeout): + bb.warn("Global test timeout reached (%s seconds), stopping the tests." %(timeout)) + os.kill(os.getpid(), signal.SIGINT) + testimage_sanity(d) if (d.getVar('IMAGE_PKGTYPE') == 'rpm' @@ -275,11 +281,14 @@ def testimage_main(d): # Get use_kvm kvm = oe.types.qemu_use_kvm(d.getVar('QEMU_USE_KVM'), d.getVar('TARGET_ARCH')) + # Get OVMF + ovmf = d.getVar("QEMU_USE_OVMF") + slirp = False if d.getVar("QEMU_USE_SLIRP"): slirp = True - # TODO: We use the current implementatin of qemu runner because of + # TODO: We use the current implementation of qemu runner because of # time constrains, qemu runner really needs a refactor too. target_kwargs = { 'machine' : machine, 'rootfs' : rootfs, @@ -293,6 +302,7 @@ def testimage_main(d): 'slirp' : slirp, 'dump_dir' : d.getVar("TESTIMAGE_DUMP_DIR"), 'serial_ports': len(d.getVar("SERIAL_CONSOLES").split()), + 'ovmf' : ovmf, } if d.getVar("TESTIMAGE_BOOT_PATTERNS"): @@ -354,12 +364,19 @@ def testimage_main(d): package_extraction(d, tc.suites) results = None + complete = False orig_sigterm_handler = signal.signal(signal.SIGTERM, sigterm_exception) try: # We need to check if runqemu ends unexpectedly # or if the worker send us a SIGTERM tc.target.start(params=d.getVar("TEST_QEMUPARAMS"), runqemuparams=d.getVar("TEST_RUNQEMUPARAMS")) + import threading + try: + threading.Timer(int(d.getVar("TEST_OVERALL_TIMEOUT")), handle_test_timeout, (int(d.getVar("TEST_OVERALL_TIMEOUT")),)).start() + except ValueError: + pass results = tc.runTests() + complete = True except (KeyboardInterrupt, BlockingIOError) as err: if isinstance(err, KeyboardInterrupt): bb.error('testimage interrupted, shutting down...') @@ -367,20 +384,21 @@ def testimage_main(d): bb.error('runqemu failed, shutting down...') if results: results.stop() - results = None + results = tc.results finally: signal.signal(signal.SIGTERM, orig_sigterm_handler) tc.target.stop() # Show results (if we have them) - if not results: + if results: + configuration = get_testimage_configuration(d, 'runtime', machine) + results.logDetails(get_testimage_json_result_dir(d), + configuration, + get_testimage_result_id(configuration), + dump_streams=d.getVar('TESTREPORT_FULLLOGS')) + results.logSummary(pn) + if not results or not complete: bb.fatal('%s - FAILED - tests were interrupted during execution' % pn, forcelog=True) - configuration = get_testimage_configuration(d, 'runtime', machine) - results.logDetails(get_testimage_json_result_dir(d), - configuration, - get_testimage_result_id(configuration), - dump_streams=d.getVar('TESTREPORT_FULLLOGS')) - results.logSummary(pn) if not results.wasSuccessful(): bb.fatal('%s - FAILED - check the task log and the ssh log' % pn, forcelog=True) |