runtest: Remove run_command -> android_build dependency.
This is desired because run_command is used by puppetmaster which should have no dependency on android build system.
This commit is contained in:
@@ -23,7 +23,6 @@ import threading
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
import android_build
|
|
||||||
import errors
|
import errors
|
||||||
import logger
|
import logger
|
||||||
|
|
||||||
@@ -129,16 +128,14 @@ def RunHostCommand(binary, valgrind=False):
|
|||||||
output are always discarded.
|
output are always discarded.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
binary: basename of the file to be run. It is expected to be under
|
binary: full path of the file to be run.
|
||||||
out/host/<os>-<arch>/bin.
|
|
||||||
valgrind: If True the command will be run under valgrind.
|
valgrind: If True the command will be run under valgrind.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The command exit code (int)
|
The command exit code (int)
|
||||||
"""
|
"""
|
||||||
full_path = os.path.join(android_build.GetHostBin(), binary)
|
|
||||||
if not valgrind:
|
if not valgrind:
|
||||||
subproc = subprocess.Popen(full_path, stdout=subprocess.PIPE,
|
subproc = subprocess.Popen(binary, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
subproc.wait()
|
subproc.wait()
|
||||||
if subproc.returncode != 0: # In case of error print the output
|
if subproc.returncode != 0: # In case of error print the output
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
"""TestSuite for running native Android tests."""
|
"""TestSuite for running native Android tests."""
|
||||||
|
|
||||||
# python imports
|
# python imports
|
||||||
|
import re
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
@@ -93,9 +94,9 @@ class NativeTestSuite(AbstractTestSuite):
|
|||||||
full_path = os.path.join(os.sep, "system", "bin", f)
|
full_path = os.path.join(os.sep, "system", "bin", f)
|
||||||
|
|
||||||
# Single quotes are needed to prevent the shell splitting it.
|
# Single quotes are needed to prevent the shell splitting it.
|
||||||
output = self._adb.SendShellCommand("'%s 2>&1;echo -n exit code:$?'" %
|
output = adb.SendShellCommand("'%s 2>&1;echo -n exit code:$?'" %
|
||||||
full_path,
|
full_path,
|
||||||
int(self._options.timeout))
|
int(options.timeout))
|
||||||
success = output.endswith("exit code:0")
|
success = output.endswith("exit code:0")
|
||||||
logger.Log("%s... %s" % (f, success and "ok" or "failed"))
|
logger.Log("%s... %s" % (f, success and "ok" or "failed"))
|
||||||
# Print the captured output when the test failed.
|
# Print the captured output when the test failed.
|
||||||
@@ -150,3 +151,23 @@ class NativeTestSuite(AbstractTestSuite):
|
|||||||
if os.path.exists(full_path):
|
if os.path.exists(full_path):
|
||||||
binaries.append(binary)
|
binaries.append(binary)
|
||||||
return binaries
|
return binaries
|
||||||
|
|
||||||
|
def _RunHostCommand(self, binary, valgrind=False):
|
||||||
|
"""Run a command on the host (opt using 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
|
||||||
|
out/host/<os>-<arch>/bin.
|
||||||
|
valgrind: If True the command will be run under valgrind.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The command exit code (int)
|
||||||
|
"""
|
||||||
|
full_path = os.path.join(android_build.GetHostBin(), binary)
|
||||||
|
return run_command.RunHostCommand(full_path, valgrind=valgrind)
|
||||||
|
|||||||
Reference in New Issue
Block a user