Change the client-side exit status handling to be consistent with the
server-side handling, and to not throw away codes indicating that a
signal was sent.
Signed-off-by: John Admanski <[email protected]>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1321 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/autotest_utils.py b/client/bin/autotest_utils.py
index 4091ec1..618ab06 100755
--- a/client/bin/autotest_utils.py
+++ b/client/bin/autotest_utils.py
@@ -251,6 +251,16 @@
return int(re.search(r'\d+', memtotal).group(0))
+def _convert_exit_status(sts):
+ if os.WIFSIGNALED(sts):
+ return -os.WTERMSIG(sts)
+ elif os.WIFEXITED(sts):
+ return os.WEXITSTATUS(sts)
+ else:
+ # impossible?
+ raise RuntimeError("Unknown exit status %d!" % sts)
+
+
def system(cmd, ignorestatus = 0):
"""os.system replacement
@@ -263,7 +273,8 @@
"""
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
try:
- status = os.system(cmd) >> 8
+ status = os.system(cmd)
+ status = _convert_exit_status(status)
finally:
signal.signal(signal.SIGPIPE, signal.SIG_IGN)
@@ -279,8 +290,9 @@
whether to raise a CmdError if command has a nonzero exit status
"""
(result, data) = commands.getstatusoutput(command)
+ result = _convert_exit_status(result)
if result != 0 and not ignorestatus:
- raise CmdError('command failed: %s' % command, result >> 8)
+ raise CmdError('command failed: %s' % command, result)
return data