scripts: twister: output error message

Sometimes custom script fails, but we can't see the
error information in twister log, because the twister
uses _ to ignore the stderr.

Signed-off-by: Jingru Wang <jingru@synopsys.com>
This commit is contained in:
Jingru Wang 2022-02-10 10:26:52 +08:00 committed by Anas Nashif
commit eb614e268c

View file

@ -723,8 +723,10 @@ class DeviceHandler(Handler):
def run_custom_script(script, timeout):
with subprocess.Popen(script, stderr=subprocess.PIPE, stdout=subprocess.PIPE) as proc:
try:
stdout, _ = proc.communicate(timeout=timeout)
stdout, stderr = proc.communicate(timeout=timeout)
logger.debug(stdout.decode())
if proc.returncode != 0:
logger.error(f"Custom script failure: {stderr.decode(errors='ignore')}")
except subprocess.TimeoutExpired:
proc.kill()