Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Unified Diff: build/android/pylib/gtest/test_package_exe.py

Issue 20649002: [Android] Dedup content_browsertests test setup from gtests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed bulach's comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/gtest/test_package_apk.py ('k') | build/android/pylib/gtest/test_runner.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/gtest/test_package_exe.py
diff --git a/build/android/pylib/gtest/test_package_exe.py b/build/android/pylib/gtest/test_package_exe.py
index a458243285e2a0c211d895384f25075525415a8d..f0238b81aa92223d9c33606bb41d733f8442655c 100644
--- a/build/android/pylib/gtest/test_package_exe.py
+++ b/build/android/pylib/gtest/test_package_exe.py
@@ -22,30 +22,24 @@ class TestPackageExecutable(TestPackage):
_TEST_RUNNER_RET_VAL_FILE = 'gtest_retval'
- def __init__(self, adb, device, suite_path_full, tool, symbols_dir=None):
+ def __init__(self, suite_name, build_type):
"""
Args:
- adb: ADB interface the tests are using.
- device: Device to run the tests.
- suite_path_full: Absolute path to a specific test suite to run,
- empty to run all.
- tool: Name of the Valgrind tool.
- symbols_dir: Directory to put the stripped binaries.
+ suite_name: Name of the test suite (e.g. base_unittests).
+ build_type: 'Release' or 'Debug'.
"""
- TestPackage.__init__(self, adb, device, suite_path_full, tool)
- self.symbols_dir = symbols_dir
-
- def _GetTestSuiteBaseName(self):
- """Returns the base name of the test suite."""
- return os.path.basename(self.suite_path)
+ TestPackage.__init__(self, suite_name)
+ product_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type)
+ self.suite_path = os.path.join(product_dir, suite_name)
+ self._symbols_dir = os.path.join(product_dir, 'lib.target')
#override
- def GetGTestReturnCode(self):
+ def GetGTestReturnCode(self, adb):
ret = None
ret_code = 1 # Assume failure if we can't find it
ret_code_file = tempfile.NamedTemporaryFile()
try:
- if not self.adb.Adb().Pull(
+ if not adb.Adb().Pull(
constants.TEST_EXECUTABLE_DIR + '/' +
TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE,
ret_code_file.name):
@@ -60,7 +54,7 @@ class TestPackageExecutable(TestPackage):
ret = 1
return ret
- def _AddNativeCoverageExports(self):
+ def _AddNativeCoverageExports(self, adb):
# export GCOV_PREFIX set the path for native coverage results
# export GCOV_PREFIX_STRIP indicates how many initial directory
# names to strip off the hardwired absolute paths.
@@ -75,16 +69,16 @@ class TestPackageExecutable(TestPackage):
'No native coverage.')
return ''
export_string = ('export GCOV_PREFIX="%s/gcov"\n' %
- self.adb.GetExternalStorage())
+ adb.GetExternalStorage())
export_string += 'export GCOV_PREFIX_STRIP=%s\n' % depth
return export_string
#override
- def ClearApplicationState(self):
- self.adb.KillAllBlocking(self.suite_basename, 30)
+ def ClearApplicationState(self, adb):
+ adb.KillAllBlocking(self.suite_name, 30)
#override
- def CreateCommandLineFileOnDevice(self, test_filter, test_arguments):
+ def CreateCommandLineFileOnDevice(self, adb, test_filter, test_arguments):
tool_wrapper = self.tool.GetTestWrapper()
sh_script_file = tempfile.NamedTemporaryFile()
# We need to capture the exit status from the script since adb shell won't
@@ -94,14 +88,14 @@ class TestPackageExecutable(TestPackage):
'%s %s/%s --gtest_filter=%s %s\n'
'echo $? > %s' %
(constants.TEST_EXECUTABLE_DIR,
- self._AddNativeCoverageExports(),
+ self._AddNativeCoverageExports(adb),
tool_wrapper, constants.TEST_EXECUTABLE_DIR,
- self.suite_basename,
+ self.suite_name,
test_filter, test_arguments,
TestPackageExecutable._TEST_RUNNER_RET_VAL_FILE))
sh_script_file.flush()
cmd_helper.RunCmd(['chmod', '+x', sh_script_file.name])
- self.adb.PushIfNeeded(
+ adb.PushIfNeeded(
sh_script_file.name,
constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh')
logging.info('Conents of the test runner script: ')
@@ -109,27 +103,27 @@ class TestPackageExecutable(TestPackage):
logging.info(' ' + line.rstrip())
#override
- def GetAllTests(self):
- all_tests = self.adb.RunShellCommand(
+ def GetAllTests(self, adb):
+ all_tests = adb.RunShellCommand(
'%s %s/%s --gtest_list_tests' %
(self.tool.GetTestWrapper(),
constants.TEST_EXECUTABLE_DIR,
- self.suite_basename))
+ self.suite_name))
return self._ParseGTestListTests(all_tests)
#override
- def SpawnTestProcess(self):
- args = ['adb', '-s', self.device, 'shell', 'sh',
+ def SpawnTestProcess(self, adb):
+ args = ['adb', '-s', adb.GetDevice(), 'shell', 'sh',
constants.TEST_EXECUTABLE_DIR + '/chrome_test_runner.sh']
logging.info(args)
return pexpect.spawn(args[0], args[1:], logfile=sys.stdout)
#override
- def Install(self):
+ def Install(self, adb):
if self.tool.NeedsDebugInfo():
target_name = self.suite_path
else:
- target_name = self.suite_path + '_' + self.device + '_stripped'
+ target_name = self.suite_path + '_' + adb.GetDevice() + '_stripped'
should_strip = True
if os.path.isfile(target_name):
logging.info('Found target file %s' % target_name)
@@ -145,11 +139,10 @@ class TestPackageExecutable(TestPackage):
'new one (%s).' % target_name)
# Whenever we generate a stripped binary, copy to the symbols dir. If we
# aren't stripping a new binary, assume it's there.
- if self.symbols_dir:
- if not os.path.exists(self.symbols_dir):
- os.makedirs(self.symbols_dir)
- shutil.copy(self.suite_path, self.symbols_dir)
+ if not os.path.exists(self._symbols_dir):
+ os.makedirs(self._symbols_dir)
+ shutil.copy(self.suite_path, self._symbols_dir)
strip = os.environ['STRIP']
cmd_helper.RunCmd([strip, self.suite_path, '-o', target_name])
- test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_basename
- self.adb.PushIfNeeded(target_name, test_binary)
+ test_binary = constants.TEST_EXECUTABLE_DIR + '/' + self.suite_name
+ adb.PushIfNeeded(target_name, test_binary)
« no previous file with comments | « build/android/pylib/gtest/test_package_apk.py ('k') | build/android/pylib/gtest/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698