Don't lose stdout/stderr in AssertCommand
authorKlaus Aehlig <aehlig@google.com>
Tue, 4 Nov 2014 09:36:32 +0000 (10:36 +0100)
committerHrvoje Ribicic <riba@google.com>
Wed, 18 Mar 2015 17:05:50 +0000 (18:05 +0100)
If a command fails/succeeds that should not do so,
show stdout and stderr. This information can be
relevant for debugging.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>

Cherry-picked-from: 7f7c9c2cc2fa7acccc9040ae12e454dbeac48d6f
Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

qa/qa_utils.py

index 5ed9eba..b1d66b2 100644 (file)
@@ -187,7 +187,11 @@ def AssertCommand(cmd, fail=False, node=None, log_cmd=True, max_seconds=None):
   rcode = popen.returncode
   duration_seconds = TimedeltaToTotalSeconds(datetime.datetime.now() - start)
   if fail is not None:
-    _AssertRetCode(rcode, fail, cmdstr, nodename)
+    try:
+      _AssertRetCode(rcode, fail, cmdstr, nodename)
+    except:
+      print "Stdout was:\n%s\nStderr was:\n%s\n" % (stdout, stderr)
+      raise
 
   if max_seconds is not None:
     if duration_seconds > max_seconds: