twister: abort on execution and retun 0 on exceptions
When something goes wrong with execution, due to twister issues and bugs, do not continue with execution and abort the process and report and return an error code. Fixes #72807 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
7f0b5edd8c
commit
d877d29913
2 changed files with 25 additions and 15 deletions
|
@ -1315,6 +1315,7 @@ class TwisterRunner:
|
||||||
|
|
||||||
|
|
||||||
def pipeline_mgr(self, pipeline, done_queue, lock, results):
|
def pipeline_mgr(self, pipeline, done_queue, lock, results):
|
||||||
|
try:
|
||||||
if sys.platform == 'linux':
|
if sys.platform == 'linux':
|
||||||
with self.jobserver.get_job():
|
with self.jobserver.get_job():
|
||||||
while True:
|
while True:
|
||||||
|
@ -1341,6 +1342,9 @@ class TwisterRunner:
|
||||||
pb.duts = self.duts
|
pb.duts = self.duts
|
||||||
pb.process(pipeline, done_queue, task, lock, results)
|
pb.process(pipeline, done_queue, task, lock, results)
|
||||||
return True
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"General exception: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def execute(self, pipeline, done):
|
def execute(self, pipeline, done):
|
||||||
lock = Lock()
|
lock = Lock()
|
||||||
|
@ -1360,6 +1364,11 @@ class TwisterRunner:
|
||||||
try:
|
try:
|
||||||
for p in processes:
|
for p in processes:
|
||||||
p.join()
|
p.join()
|
||||||
|
if p.exitcode != 0:
|
||||||
|
logger.error(f"Process {p.pid} failed, aborting execution")
|
||||||
|
for proc in processes:
|
||||||
|
proc.terminate()
|
||||||
|
sys.exit(1)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logger.info("Execution interrupted")
|
logger.info("Execution interrupted")
|
||||||
for p in processes:
|
for p in processes:
|
||||||
|
|
|
@ -2691,6 +2691,7 @@ def test_twisterrunner_execute(caplog):
|
||||||
|
|
||||||
process_mock = mock.Mock()
|
process_mock = mock.Mock()
|
||||||
process_mock().join = mock.Mock(side_effect=mock_join)
|
process_mock().join = mock.Mock(side_effect=mock_join)
|
||||||
|
process_mock().exitcode = 0
|
||||||
pipeline_mock = mock.Mock()
|
pipeline_mock = mock.Mock()
|
||||||
done_mock = mock.Mock()
|
done_mock = mock.Mock()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue