summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-05-14 12:50:24 +0800
committerChromeBot <chrome-bot@google.com>2013-05-14 09:24:59 -0700
commitb167c7d3a67b5ca3118bc784184b7bd092be71f5 (patch)
tree5b0b236cb2ada450ba6b3c6535814b2a668c0e97
parent199252ea21d3090f057c333073fbeb8b80b5b141 (diff)
downloadchrome-ec-b167c7d3a67b5ca3118bc784184b7bd092be71f5.tar.gz
Redirect emulator output to stderr if a test fails
If a test fails, redirect emulator output to stderr so that it shows up even when V=1 is not set. BUG=chrome-os-partner:19235 TEST=Manual BRANCH=None Change-Id: I6d8e05eaa222ebe043556bfcd3f63ca7e27c2721 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/51097 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rwxr-xr-xutil/run_host_test28
1 files changed, 25 insertions, 3 deletions
diff --git a/util/run_host_test b/util/run_host_test
index bf8d8efd97..d4b64be40e 100755
--- a/util/run_host_test
+++ b/util/run_host_test
@@ -4,23 +4,45 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+from cStringIO import StringIO
import pexpect
import sys
TIMEOUT=10
+class Tee(object):
+ def __init__(self, target):
+ self._target = target
+
+ def write(self, data):
+ sys.stdout.write(data)
+ self._target.write(data)
+
+ def flush(self):
+ sys.stdout.flush()
+ self._target.flush()
+
+log = StringIO()
test_name = sys.argv[1]
child = pexpect.spawn('build/host/{0}/{0}.exe'.format(test_name),
timeout=TIMEOUT)
-child.logfile = sys.stdout
+child.logfile = Tee(log)
result_id = child.expect([pexpect.TIMEOUT, 'Pass!', 'Fail!'])
+failed = False
if result_id == 0:
sys.stderr.write('Test %s timed out after %d seconds!\n' %
(test_name, TIMEOUT))
- sys.exit(1)
+ failed = True
elif result_id == 1:
sys.stderr.write('Test %s passed!\n' % test_name)
- sys.exit(0)
elif result_id == 2:
sys.stderr.write('Test %s failed!\n' % test_name)
+ failed = True
+
+if failed:
+ sys.stderr.write('\n====== Emulator output ======\n')
+ sys.stderr.write(log.getvalue())
+ sys.stderr.write('\n=============================\n')
sys.exit(1)
+else:
+ sys.exit(0)