From 1dc9faf7b150b6885ab6dffedbb9d5011d4187e0 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Wed, 2 Oct 2024 13:01:01 +0200 Subject: [PATCH] [chiptests] Check the exit code of the subprocesses and raise a failure if the exit code is not 0 AND if the process was responding (we ignore cases where the process is stuck) (#35817) --- scripts/tests/chiptest/test_definition.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/tests/chiptest/test_definition.py b/scripts/tests/chiptest/test_definition.py index 484f247f70b1b2..bdb0680010c5b1 100644 --- a/scripts/tests/chiptest/test_definition.py +++ b/scripts/tests/chiptest/test_definition.py @@ -159,10 +159,15 @@ def __terminateProcess(self): if self.process: self.process.terminate() # sends SIGTERM try: - self.process.wait(10) + exit_code = self.process.wait(10) + if exit_code: + raise Exception('Subprocess failed with exit code: %d' % exit_code) except subprocess.TimeoutExpired: logging.debug('Subprocess did not terminate on SIGTERM, killing it now') self.process.kill() + # The exit code when using Python subprocess will be the signal used to kill it. + # Ideally, we would recover the original exit code, but the process was already + # ignoring SIGTERM, indicating something was already wrong. self.process.wait(10) self.process = None self.outpipe = None