Modify the Android test running scripts so they can be used from WebKit

In order to avoid duplicating most of the run-tests-on-devices logic, make
sure that the Android scripts are able to be usable from a WebKit checkout.
Two flags have been added for this: --webkit, which is necessary as a file's
path on the host and device are not per se equal anymore, and --out-directory,
accepting a path as it's not always in the Chromium source directory.

BUG=


Review URL: https://chromiumcodereview.appspot.com/11312239

git-svn-id: http://src.chromium.org/svn/trunk/src/build@167999 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
peter@chromium.org 2012-11-15 19:57:16 +00:00
Родитель 8d07804078
Коммит 845b0d71a4
5 изменённых файлов: 52 добавлений и 19 удалений

Просмотреть файл

@ -595,9 +595,10 @@ class AndroidCommands(object):
if not self._md5sum_path:
default_build_type = os.environ.get('BUILD_TYPE', 'Debug')
md5sum_path = '%s/out/%s/md5sum_bin' % (CHROME_SRC, default_build_type)
md5sum_path = '%s/%s/md5sum_bin' % (cmd_helper.OutDirectory.get(),
default_build_type)
if not os.path.exists(md5sum_path):
md5sum_path = '%s/out/Release/md5sum_bin' % (CHROME_SRC)
md5sum_path = '%s/Release/md5sum_bin' % cmd_helper.OutDirectory.get()
if not os.path.exists(md5sum_path):
print >> sys.stderr, 'Please build md5sum.'
sys.exit(1)

Просмотреть файл

@ -4,10 +4,11 @@
"""A wrapper for subprocess to make calling shell commands easier."""
import os
import logging
import subprocess
import constants
def RunCmd(args, cwd=None):
"""Opens a subprocess to execute a program and returns its return value.
@ -65,3 +66,12 @@ def GetCmdStatusAndOutput(args, cwd=None, shell=False):
logging.critical(stderr)
logging.info(stdout[:4096]) # Truncate output longer than 4k.
return (exit_code, stdout)
class OutDirectory(object):
_out_directory = constants.CHROME_DIR
@staticmethod
def set(out_directory):
OutDirectory._out_directory = out_directory
@staticmethod
def get():
return OutDirectory._out_directory

Просмотреть файл

@ -17,7 +17,7 @@ from pylib import pexpect
def _MakeBinaryPath(build_type, binary_name):
return os.path.join(constants.CHROME_DIR, 'out', build_type, binary_name)
return os.path.join(cmd_helper.OutDirectory.get(), build_type, binary_name)
class Forwarder(object):

Просмотреть файл

@ -35,11 +35,13 @@ class SingleTestRunner(BaseTestRunner):
shard_index: index number of the shard on which the test suite will run.
dump_debug_info: Whether or not to dump debug information.
build_type: 'Release' or 'Debug'.
in_webkit_checkout: Whether the suite is being run from a WebKit checkout.
"""
def __init__(self, device, test_suite, gtest_filter, test_arguments, timeout,
rebaseline, performance_test, cleanup_test_files, tool_name,
shard_index, dump_debug_info, fast_and_loose, build_type):
shard_index, dump_debug_info, fast_and_loose, build_type,
in_webkit_checkout):
BaseTestRunner.__init__(self, device, tool_name, shard_index, build_type)
self._running_on_emulator = self.device.startswith('emulator')
self._gtest_filter = gtest_filter
@ -51,6 +53,7 @@ class SingleTestRunner(BaseTestRunner):
else:
self.dump_debug_info = None
self.fast_and_loose = fast_and_loose
self.in_webkit_checkout = in_webkit_checkout
logging.warning('Test suite: ' + test_suite)
if os.path.splitext(test_suite)[1] == '.apk':
@ -226,10 +229,6 @@ class SingleTestRunner(BaseTestRunner):
'chrome/test/perf/sunspider_uitest.js',
'chrome/test/perf/v8_benchmark_uitest.js',
]
elif self.test_package.test_suite_basename == 'webkit_unit_tests':
return [
'third_party/WebKit/Source/WebKit/chromium/tests/data',
]
elif self.test_package.test_suite_basename == 'content_unittests':
return [
'content/test/data/gpu/webgl_conformance_test_expectations.txt',
@ -263,6 +262,23 @@ class SingleTestRunner(BaseTestRunner):
self.adb.WaitForSdCardReady(20)
for data in test_data:
self.CopyTestData([data], self.adb.GetExternalStorage())
if self.test_package.test_suite_basename == 'webkit_unit_tests':
self.PushWebKitUnitTestsData()
def PushWebKitUnitTestsData(self):
"""Pushes the webkit_unit_tests data files to the device.
The path of this directory is different when the suite is being run as
part of a WebKit check-out.
"""
webkit_src = os.path.join(constants.CHROME_DIR, 'third_party', 'WebKit')
if self.in_webkit_checkout:
webkit_src = os.path.join(constants.CHROME_DIR, '..', '..', '..')
self.adb.PushIfNeeded(
os.path.join(webkit_src, 'Source/WebKit/chromium/tests/data'),
os.path.join(self.adb.GetExternalStorage(),
'third_party/WebKit/Source/WebKit/chromium/tests/data'))
def RunTestsWithFilter(self):
"""Runs a tests via a small, temporary shell script."""

Просмотреть файл

@ -62,6 +62,7 @@ import time
from pylib import android_commands
from pylib.base_test_sharder import BaseTestSharder
from pylib import buildbot_report
from pylib import cmd_helper
from pylib import constants
from pylib import debug_info
import emulator
@ -87,10 +88,6 @@ _TEST_SUITES = ['base_unittests',
]
def TestSuiteDir(build_type):
"""Return the base directory of test suites."""
return os.path.abspath(os.path.join(constants.CHROME_DIR, 'out', build_type))
def FullyQualifiedTestSuites(exe, option_test_suite, build_type):
"""Return a fully qualified list
@ -99,7 +96,7 @@ def FullyQualifiedTestSuites(exe, option_test_suite, build_type):
option_test_suite: the test_suite specified as an option.
build_type: 'Release' or 'Debug'.
"""
test_suite_dir = TestSuiteDir(build_type)
test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type)
if option_test_suite:
all_test_suites = [option_test_suite]
else:
@ -195,7 +192,7 @@ class TestSharder(BaseTestSharder):
def __init__(self, attached_devices, test_suite, gtest_filter,
test_arguments, timeout, rebaseline, performance_test,
cleanup_test_files, tool, log_dump_name, fast_and_loose,
build_type):
build_type, in_webkit_checkout):
BaseTestSharder.__init__(self, attached_devices, build_type)
self.test_suite = test_suite
self.test_suite_basename = os.path.basename(test_suite)
@ -209,6 +206,7 @@ class TestSharder(BaseTestSharder):
self.log_dump_name = log_dump_name
self.fast_and_loose = fast_and_loose
self.build_type = build_type
self.in_webkit_checkout = in_webkit_checkout
self.tests = []
if not self.gtest_filter:
# No filter has been specified, let's add all tests then.
@ -238,7 +236,7 @@ class TestSharder(BaseTestSharder):
self.performance_test, self.cleanup_test_files,
self.tool, 0,
not not self.log_dump_name, self.fast_and_loose,
self.build_type)
self.build_type, self.in_webkit_checkout)
# The executable/apk needs to be copied before we can call GetAllTests.
test.test_package.StripAndCopyExecutable()
all_tests = test.test_package.GetAllTests()
@ -270,7 +268,7 @@ class TestSharder(BaseTestSharder):
self.rebaseline, self.performance_test,
self.cleanup_test_files, self.tool, index,
not not self.log_dump_name, self.fast_and_loose,
self.build_type)
self.build_type, self.in_webkit_checkout)
def OnTestsCompleted(self, test_runners, test_results):
"""Notifies that we completed the tests."""
@ -282,7 +280,8 @@ class TestSharder(BaseTestSharder):
if self.log_dump_name:
# Zip all debug info outputs into a file named by log_dump_name.
debug_info.GTestDebugInfo.ZipAndCleanResults(
os.path.join(TestSuiteDir(self.build_type), 'debug_info_dumps'),
os.path.join(cmd_helper.OutDirectory.get(), self.build_type,
'debug_info_dumps'),
self.log_dump_name)
@ -343,7 +342,7 @@ def _RunATestSuite(options):
options.performance_test,
options.cleanup_test_files, options.tool,
options.log_dump, options.fast_and_loose,
options.build_type)
options.build_type, options.webkit)
test_results = sharder.RunShardedTests()
for buildbot_emulator in buildbot_emulators:
@ -399,6 +398,9 @@ def main(argv):
option_parser.add_option('-s', '--suite', dest='test_suite',
help='Executable name of the test suite to run '
'(use -s help to list them)')
option_parser.add_option('--out-directory', dest='out_directory',
help='Path to the out/ directory, irrespective of '
'the build type. Only for non-Chromium uses.')
option_parser.add_option('-d', '--device', dest='test_device',
help='Target device the test suite to run ')
option_parser.add_option('-r', dest='rebaseline',
@ -425,6 +427,8 @@ def main(argv):
option_parser.add_option('-x', '--xvfb', dest='use_xvfb',
action='store_true',
help='Use Xvfb around tests (ignored if not Linux)')
option_parser.add_option('--webkit', action='store_true',
help='Run the tests from a WebKit checkout.')
option_parser.add_option('--fast', '--fast_and_loose', dest='fast_and_loose',
action='store_true',
help='Go faster (but be less stable), '
@ -449,6 +453,8 @@ def main(argv):
option_parser.print_usage()
sys.exit(1)
run_tests_helper.SetLogLevel(options.verbose_count)
if options.out_directory:
cmd_helper.OutDirectory.set(options.out_directory)
emulator.DeleteAllTempAVDs()
failed_tests_count = Dispatch(options)