Merge change 434 into donut
* changes: Added a method in run_command.py to run a host test. The run can also happen under valgrind.
This commit is contained in:
@@ -19,12 +19,12 @@
|
|||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
|
||||||
import threading
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
import logger
|
|
||||||
import errors
|
import errors
|
||||||
|
import logger
|
||||||
|
|
||||||
_abort_on_error = False
|
_abort_on_error = False
|
||||||
|
|
||||||
@@ -115,3 +115,24 @@ def RunOnce(cmd, timeout_time=None, return_output=True):
|
|||||||
raise errors.AbortError
|
raise errors.AbortError
|
||||||
|
|
||||||
return "".join(so)
|
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])
|
||||||
|
|||||||
@@ -290,12 +290,27 @@ class TestRunner(object):
|
|||||||
# find all test files, convert unicode names to ascii, take the basename
|
# find all test files, convert unicode names to ascii, take the basename
|
||||||
# and drop the .cc/.cpp extension.
|
# and drop the .cc/.cpp extension.
|
||||||
file_pattern = os.path.join(test_suite.GetBuildPath(), "test_*")
|
file_pattern = os.path.join(test_suite.GetBuildPath(), "test_*")
|
||||||
|
logger.SilentLog("Scanning %s" % test_suite.GetBuildPath())
|
||||||
file_list = []
|
file_list = []
|
||||||
for f in map(str, glob.glob(file_pattern)):
|
for f in map(str, glob.glob(file_pattern)):
|
||||||
f = os.path.basename(f)
|
f = os.path.basename(f)
|
||||||
f = re.split(".[cp]+$", f)[0]
|
f = re.split(".[cp]+$", f)[0]
|
||||||
|
logger.SilentLog("Found %s" % f)
|
||||||
file_list.append(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:
|
for f in file_list:
|
||||||
full_path = "/system/bin/%s" % f
|
full_path = "/system/bin/%s" % f
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user