diff options
authorAlexander Kanavin <alex.kanavin@gmail.com>2020-04-17 16:18:45 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-04-25 16:34:13 +0100
commitd77546e910ad9048f0057f4465716d417b810065 (patch)
parent06568a06ca22ee279d1829d26d4c38738233c06a (diff)
testimage: add an overall timeout setting
This is useful when tests misbehave and get stuck, or when a significant increase in testing time is undesirable and needs to be caught automatically. Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
1 files changed, 11 insertions, 0 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 53945478af..00f0c29836 100644
--- a/meta/classes/testimage.bbclass
+++ b/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_TARGET ?= "qemu"
@@ -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)
if (d.getVar('IMAGE_PKGTYPE') == 'rpm'
@@ -363,6 +369,11 @@ def testimage_main(d):
# 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()
except (KeyboardInterrupt, BlockingIOError) as err:
if isinstance(err, KeyboardInterrupt):