am 7b10ec3: Merge change 434 into donut

Merge commit '7b10ec3d1f271e25793f71e9af1b36ec69a21f3c'

* commit '7b10ec3d1f271e25793f71e9af1b36ec69a21f3c':
  Added a method in run_command.py to run a host test.
This commit is contained in:
Android (Google) Code Review
2009-04-29 12:06:39 -07:00
committed by The Android Open Source Project
2 changed files with 56 additions and 20 deletions

View File

@@ -19,12 +19,12 @@
import os
import signal
import subprocess
import time
import threading
import time
# local imports
import logger
import errors
import logger
_abort_on_error = False
@@ -115,3 +115,24 @@ def RunOnce(cmd, timeout_time=None, return_output=True):
raise errors.AbortError
return "".join(so)
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.
Args:
binary: basename of the file to be run. It is expected to be under
out/host/linux-x86/bin.
valgrind: If True the command will be run under valgrind.
Returns:
The command exit code (int)
"""
full_path = os.path.join("out", "host", "linux-x86", "bin", binary)
if not valgrind:
return subprocess.call(full_path)
else:
return subprocess.call(["/usr/bin/valgrind", "-q", full_path])

View File

@@ -290,12 +290,27 @@ class TestRunner(object):
# find all test files, convert unicode names to ascii, take the basename
# and drop the .cc/.cpp extension.
file_pattern = os.path.join(test_suite.GetBuildPath(), "test_*")
logger.SilentLog("Scanning %s" % test_suite.GetBuildPath())
file_list = []
for f in map(str, glob.glob(file_pattern)):
f = os.path.basename(f)
f = re.split(".[cp]+$", f)[0]
logger.SilentLog("Found %s" % f)
file_list.append(f)
# Run on the host
logger.Log("\nRunning on host")
for f in file_list:
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)
else:
logger.Log("%s... ok\t\t[valgrind: failed]" % f)
# Run on the device
logger.Log("\nRunning on target")
for f in file_list:
full_path = "/system/bin/%s" % f