summaryrefslogtreecommitdiffstats
path: root/testrunner
diff options
context:
space:
mode:
authorNicolas Catania <niko@google.com>2009-05-14 12:25:23 -0700
committerNicolas Catania <niko@google.com>2009-05-14 12:25:23 -0700
commitbcd93dc46a3e01d43768561fda7fa3744e57b146 (patch)
treef9aa225f59b1df0bda76c0dd143608e988f1beb8 /testrunner
parentc15ed2d771b4b02bab5f2a2281d08a050ee1df89 (diff)
downloadandroid_development-bcd93dc46a3e01d43768561fda7fa3744e57b146.tar.gz
android_development-bcd93dc46a3e01d43768561fda7fa3744e57b146.tar.bz2
android_development-bcd93dc46a3e01d43768561fda7fa3744e57b146.zip
Made valgrind optional. Capture the target output.
Don't fail if valgrind (system version not the google3 one) is missing. If the test fail, print the output of the test. Added .pyc to the gitignore file.
Diffstat (limited to 'testrunner')
-rw-r--r--testrunner/.gitignore1
-rwxr-xr-xtestrunner/run_command.py13
-rwxr-xr-xtestrunner/runtest.py19
3 files changed, 28 insertions, 5 deletions
diff --git a/testrunner/.gitignore b/testrunner/.gitignore
new file mode 100644
index 000000000..0d20b6487
--- /dev/null
+++ b/testrunner/.gitignore
@@ -0,0 +1 @@
+*.pyc
diff --git a/testrunner/run_command.py b/testrunner/run_command.py
index a98a943a2..ead80f1bd 100755
--- a/testrunner/run_command.py
+++ b/testrunner/run_command.py
@@ -145,7 +145,20 @@ def RunHostCommand(binary, valgrind=False):
print subproc.communicate()[0]
return subproc.returncode
else:
+ # Need the full path to valgrind to avoid other versions on the system.
subproc = subprocess.Popen(["/usr/bin/valgrind", "-q", full_path],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
subproc.wait()
return subproc.returncode
+
+
+def HasValgrind():
+ """Check that /usr/bin/valgrind exists.
+
+ We look for the fullpath to avoid picking up 'alternative' valgrind
+ on the system.
+
+ Returns:
+ True if a system valgrind was found.
+ """
+ return os.path.exists("/usr/bin/valgrind")
diff --git a/testrunner/runtest.py b/testrunner/runtest.py
index a87f9b5b6..05d29ec34 100755
--- a/testrunner/runtest.py
+++ b/testrunner/runtest.py
@@ -369,10 +369,13 @@ class TestRunner(object):
if run_command.RunHostCommand(f) != 0:
logger.Log("%s... failed" % f)
else:
- if run_command.RunHostCommand(f, valgrind=True) == 0:
- logger.Log("%s... ok\t\t[valgrind: ok]" % f)
+ if run_command.HasValgrind():
+ if run_command.RunHostCommand(f, valgrind=True) == 0:
+ logger.Log("%s... ok\t\t[valgrind: ok]" % f)
+ else:
+ logger.Log("%s... ok\t\t[valgrind: failed]" % f)
else:
- logger.Log("%s... ok\t\t[valgrind: failed]" % f)
+ logger.Log("%s... ok\t\t[valgrind: missing]" % f)
# Run on the device
logger.Log("\nRunning on target")
@@ -380,9 +383,15 @@ class TestRunner(object):
full_path = os.path.join(os.sep, "system", "bin", f)
# Single quotes are needed to prevent the shell splitting it.
- status = self._adb.SendShellCommand("'%s >/dev/null 2>&1;echo -n $?'" %
+ output = self._adb.SendShellCommand("'%s 2>&1;echo -n exit code:$?'" %
full_path)
- logger.Log("%s... %s" % (f, status == "0" and "ok" or "failed"))
+ success = output.endswith("exit code:0")
+ logger.Log("%s... %s" % (f, success and "ok" or "failed"))
+ # Print the captured output when the test failed.
+ if not success or self._options.verbose:
+ pos = output.rfind("exit code")
+ output = output[0:pos]
+ logger.Log(output)
# Cleanup
self._adb.SendShellCommand("rm %s" % full_path)