summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2020-08-08 12:40:53 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-08-12 10:53:47 +0100
commitd89ffa3af434212be6deba225a5a14d07a1aea9a (patch)
tree035da793240ee76d1b72503507c6f2e2f1c28efa
parent5e238f8684c66a307046c856791edc7b381eb572 (diff)
downloadpoky-d89ffa3af434212be6deba225a5a14d07a1aea9a.tar.gz
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. (From OE-Core rev: d77546e910ad9048f0057f4465716d417b810065) (From OE-Core rev: eb57207f983b454dbdf2321da330fc1ec8a8bcbf) Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/testimage.bbclass11
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"
31# 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. 31# 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.
32# Booting is handled by this class, and it's not a test in itself. 32# Booting is handled by this class, and it's not a test in itself.
33# TEST_QEMUBOOT_TIMEOUT can be used to set the maximum time in seconds the launch code will wait for the login prompt. 33# TEST_QEMUBOOT_TIMEOUT can be used to set the maximum time in seconds the launch code will wait for the login prompt.
34# TEST_OVERALL_TIMEOUT can be used to set the maximum time in seconds the tests will be allowed to run (defaults to no limit).
34# TEST_QEMUPARAMS can be used to pass extra parameters to qemu, e.g. "-m 1024" for setting the amount of ram to 1 GB. 35# TEST_QEMUPARAMS can be used to pass extra parameters to qemu, e.g. "-m 1024" for setting the amount of ram to 1 GB.
35# TEST_RUNQEMUPARAMS can be used to pass extra parameters to runqemu, e.g. "gl" to enable OpenGL acceleration. 36# TEST_RUNQEMUPARAMS can be used to pass extra parameters to runqemu, e.g. "gl" to enable OpenGL acceleration.
36 37
@@ -75,6 +76,7 @@ DEFAULT_TEST_SUITES_remove_qemumips64 = "${MIPSREMOVE}"
75TEST_SUITES ?= "${DEFAULT_TEST_SUITES}" 76TEST_SUITES ?= "${DEFAULT_TEST_SUITES}"
76 77
77TEST_QEMUBOOT_TIMEOUT ?= "1000" 78TEST_QEMUBOOT_TIMEOUT ?= "1000"
79TEST_OVERALL_TIMEOUT ?= ""
78TEST_TARGET ?= "qemu" 80TEST_TARGET ?= "qemu"
79TEST_QEMUPARAMS ?= "" 81TEST_QEMUPARAMS ?= ""
80TEST_RUNQEMUPARAMS ?= "" 82TEST_RUNQEMUPARAMS ?= ""
@@ -206,6 +208,10 @@ def testimage_main(d):
206 """ 208 """
207 os.kill(os.getpid(), signal.SIGINT) 209 os.kill(os.getpid(), signal.SIGINT)
208 210
211 def handle_test_timeout(timeout):
212 bb.warn("Global test timeout reached (%s seconds), stopping the tests." %(timeout))
213 os.kill(os.getpid(), signal.SIGINT)
214
209 testimage_sanity(d) 215 testimage_sanity(d)
210 216
211 if (d.getVar('IMAGE_PKGTYPE') == 'rpm' 217 if (d.getVar('IMAGE_PKGTYPE') == 'rpm'
@@ -363,6 +369,11 @@ def testimage_main(d):
363 # We need to check if runqemu ends unexpectedly 369 # We need to check if runqemu ends unexpectedly
364 # or if the worker send us a SIGTERM 370 # or if the worker send us a SIGTERM
365 tc.target.start(params=d.getVar("TEST_QEMUPARAMS"), runqemuparams=d.getVar("TEST_RUNQEMUPARAMS")) 371 tc.target.start(params=d.getVar("TEST_QEMUPARAMS"), runqemuparams=d.getVar("TEST_RUNQEMUPARAMS"))
372 import threading
373 try:
374 threading.Timer(int(d.getVar("TEST_OVERALL_TIMEOUT")), handle_test_timeout, (int(d.getVar("TEST_OVERALL_TIMEOUT")),)).start()
375 except ValueError:
376 pass
366 results = tc.runTests() 377 results = tc.runTests()
367 except (KeyboardInterrupt, BlockingIOError) as err: 378 except (KeyboardInterrupt, BlockingIOError) as err:
368 if isinstance(err, KeyboardInterrupt): 379 if isinstance(err, KeyboardInterrupt):