summaryrefslogtreecommitdiffstats
path: root/testrunner/run_command.py
diff options
context:
space:
mode:
authorNicolas Catania <niko@google.com>2009-04-30 19:27:52 -0700
committerNicolas Catania <niko@google.com>2009-04-30 19:27:52 -0700
commit1ecf93b37a8739357877f305f399bcb4831c111a (patch)
treef29c7419a996d18276df4eff14b18aaf1c279d17 /testrunner/run_command.py
parentfba8d837f5d926dc3f469a99edb22f55d69dff76 (diff)
downloadandroid_development-1ecf93b37a8739357877f305f399bcb4831c111a.tar.gz
android_development-1ecf93b37a8739357877f305f399bcb4831c111a.tar.bz2
android_development-1ecf93b37a8739357877f305f399bcb4831c111a.zip
Modified the command to run native test on the host:
- when valgrind is used, the output is discarded, always. - otherwise, the output of the test is printed only when the test failed.
Diffstat (limited to 'testrunner/run_command.py')
-rwxr-xr-xtestrunner/run_command.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/testrunner/run_command.py b/testrunner/run_command.py
index 5336f332d..56085212c 100755
--- a/testrunner/run_command.py
+++ b/testrunner/run_command.py
@@ -120,8 +120,11 @@ def RunOnce(cmd, timeout_time=None, return_output=True):
def RunHostCommand(binary, valgrind=False):
"""Run a command on the host (opt using valgrind).
- Runs the host binary. Does not capture any output but it
- returns the exit code. The command can be run under valgrind.
+ Runs the host binary and returns the exit code.
+ If successfull, the output (stdout and stderr) are discarded,
+ but printed in case of error.
+ The command can be run under valgrind in which case all the
+ output are always discarded.
Args:
binary: basename of the file to be run. It is expected to be under
@@ -133,6 +136,14 @@ def RunHostCommand(binary, valgrind=False):
"""
full_path = os.path.join("out", "host", "linux-x86", "bin", binary)
if not valgrind:
- return subprocess.call(full_path)
+ subproc = subprocess.Popen(full_path, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ subproc.wait()
+ if subproc.returncode != 0: # In case of error print the output
+ print subproc.communicate()[0]
+ return subproc.returncode
else:
- return subprocess.call(["/usr/bin/valgrind", "-q", full_path])
+ subproc = subprocess.Popen(["/usr/bin/valgrind", "-q", full_path],
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ subproc.wait()
+ return subproc.returncode