audiovido_CRASFormatConversion - Logs command return code even when test failed.
This information is lost when the test is failed due to something else.
Modified the code to log the return code (at least). It could be useful at debugging.
TEST=Run the test on link
BUG=None
Change-Id: I6d8f25c90833f117dc17ba726b67f3043f5d3b4d
Reviewed-on: https://chromium-review.googlesource.com/179760
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Owen Lin <owenlin@chromium.org>
Commit-Queue: Owen Lin <owenlin@chromium.org>
diff --git a/client/cros/audio/cmd_utils.py b/client/cros/audio/cmd_utils.py
index 9beda3f..3b8ec27 100644
--- a/client/cros/audio/cmd_utils.py
+++ b/client/cros/audio/cmd_utils.py
@@ -11,18 +11,20 @@
_popen_lock = threading.Lock()
-def kill_silently(*popens):
- '''Kill all the processes of the given Popens without rasie any exceptions
- in any cases.
+def kill_or_log_returncode(*popens):
+ '''Kills all the processes of the given Popens or logs the return code.
@param poopens: The Popens to be killed.
'''
for p in popens:
- if p and p.pid:
+ if p.poll() is None:
try:
p.kill()
- except:
- logging.exception('failed to kill %d', p.pid)
+ except Exception as e:
+ logging.warning('failed to kill %d, %s', p.pid, e)
+ else:
+ logging.warning('command exit (pid=%d, rc=%d): %s',
+ p.pid, p.returncode, p.command)
def wait_and_check_returncode(*popens):