1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 13:09:50 +00:00

testimage.bbclass: correctly process SIGTERM

Python's unittest will not propagate exceptions upside
of itself, but rather will just catch and print them.

The working way to make it stop is to send a SIGINT
(e.g. simulate a ctrl-c press), which will make it exit
with a KeyboardInterrupt exception.

This also makes pressing ctrl-c twice from bitbake work
again (previously hanging instances of bitbake and qemu were
left around, and bitbake would no longer start until they
were killed manually).

(From OE-Core rev: 72a19f5f0f4bc4472d13b29e46a5c1673977e37a)

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>
This commit is contained in:
Alexander Kanavin
2020-04-17 16:18:44 +02:00
committed by Richard Purdie
parent 447653f340
commit 37d1220985
+4 -4
View File
@@ -204,7 +204,7 @@ def testimage_main(d):
"""
Catch SIGTERM from worker in order to stop qemu.
"""
raise RuntimeError
os.kill(os.getpid(), signal.SIGINT)
testimage_sanity(d)
@@ -360,9 +360,9 @@ def testimage_main(d):
# or if the worker send us a SIGTERM
tc.target.start(params=d.getVar("TEST_QEMUPARAMS"), runqemuparams=d.getVar("TEST_RUNQEMUPARAMS"))
results = tc.runTests()
except (RuntimeError, BlockingIOError) as err:
if isinstance(err, RuntimeError):
bb.error('testimage received SIGTERM, shutting down...')
except (KeyboardInterrupt, BlockingIOError) as err:
if isinstance(err, KeyboardInterrupt):
bb.error('testimage interrupted, shutting down...')
else:
bb.error('runqemu failed, shutting down...')
if results: