Revert of [Android] Add an out-of-app instrumentation driver APK. (patchset #15 id:280001 of https://codereview.chromium.org/1034053002/)

Reason for revert:
Broke the "Android" bot:

http://build.chromium.org/p/chromium/builders/Android/builds/38661

Original issue's description:
> [Android] Add an out-of-app instrumentation driver APK.
>
> BUG=444049
>
> Committed: https://crrev.com/79d22ed2b74d0ff1082f6febfd3fd93c0574d130
> Cr-Commit-Position: refs/heads/master@{#326900}

TBR=tedchoc@chromium.org,klundberg@chromium.org,yfriedman@chromium.org,thestig@chromium.org,cjhopman@chromium.org,torne@chromium.org,jbudorick@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=444049

Review URL: https://codereview.chromium.org/1094903008

Cr-Original-Commit-Position: refs/heads/master@{#326914}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 47b4c2f01324a903410ae9530156c2469601e91b
This commit is contained in:
jdonnelly 2015-04-24 15:53:42 -07:00 коммит произвёл Commit bot
Родитель e5db8723ef
Коммит 122ac1fe54
7 изменённых файлов: 33 добавлений и 151 удалений

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

@ -30,17 +30,6 @@ _ACTIVITY_RESULT_OK = -1
_DEFAULT_ANNOTATIONS = [
'Smoke', 'SmallTest', 'MediumTest', 'LargeTest',
'EnormousTest', 'IntegrationTest']
_EXTRA_ENABLE_HTTP_SERVER = (
'org.chromium.chrome.test.ChromeInstrumentationTestRunner.'
+ 'EnableTestHttpServer')
_EXTRA_DRIVER_TEST_LIST = (
'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestList')
_EXTRA_DRIVER_TEST_LIST_FILE = (
'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestListFile')
_EXTRA_DRIVER_TARGET_PACKAGE = (
'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetPackage')
_EXTRA_DRIVER_TARGET_CLASS = (
'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetClass')
_NATIVE_CRASH_RE = re.compile('native crash', re.IGNORECASE)
_PICKLE_FORMAT_VERSION = 10
@ -141,35 +130,29 @@ class InstrumentationTestInstance(test_instance.TestInstance):
self._apk_under_test = None
self._package_info = None
self._suite = None
self._test_apk = None
self._test_jar = None
self._test_package = None
self._test_runner = None
self._test_support_apk = None
self._initializeApkAttributes(args, error_func)
self.__initializeApkAttributes(args, error_func)
self._data_deps = None
self._isolate_abs_path = None
self._isolate_delegate = None
self._isolated_abs_path = None
self._test_data = None
self._initializeDataDependencyAttributes(args, isolate_delegate)
self.__initializeDataDependencyAttributes(args, isolate_delegate)
self._annotations = None
self._excluded_annotations = None
self._test_filter = None
self._initializeTestFilterAttributes(args)
self.__initializeTestFilterAttributes(args)
self._flags = None
self._initializeFlagAttributes(args)
self.__initializeFlagAttributes(args)
self._driver_apk = None
self._driver_package = None
self._driver_name = None
self._initializeDriverAttributes()
def _initializeApkAttributes(self, args, error_func):
def __initializeApkAttributes(self, args, error_func):
if args.apk_under_test.endswith('.apk'):
self._apk_under_test = args.apk_under_test
else:
@ -181,20 +164,20 @@ class InstrumentationTestInstance(test_instance.TestInstance):
error_func('Unable to find APK under test: %s' % self._apk_under_test)
if args.test_apk.endswith('.apk'):
self._suite = os.path.splitext(os.path.basename(args.test_apk))[0]
test_apk_root = os.path.splitext(os.path.basename(args.test_apk))[0]
self._test_apk = args.test_apk
else:
self._suite = args.test_apk
test_apk_root = args.test_apk
self._test_apk = os.path.join(
constants.GetOutDirectory(), constants.SDK_BUILD_APKS_DIR,
'%s.apk' % args.test_apk)
self._test_jar = os.path.join(
constants.GetOutDirectory(), constants.SDK_BUILD_TEST_JAVALIB_DIR,
'%s.jar' % self._suite)
'%s.jar' % test_apk_root)
self._test_support_apk = os.path.join(
constants.GetOutDirectory(), constants.SDK_BUILD_TEST_JAVALIB_DIR,
'%sSupport.apk' % self._suite)
'%sSupport.apk' % test_apk_root)
if not os.path.exists(self._test_apk):
error_func('Unable to find test APK: %s' % self._test_apk)
@ -211,7 +194,7 @@ class InstrumentationTestInstance(test_instance.TestInstance):
if not self._package_info:
logging.warning('Unable to find package info for %s', self._test_package)
def _initializeDataDependencyAttributes(self, args, isolate_delegate):
def __initializeDataDependencyAttributes(self, args, isolate_delegate):
self._data_deps = []
if args.isolate_file_path:
self._isolate_abs_path = os.path.abspath(args.isolate_file_path)
@ -232,7 +215,7 @@ class InstrumentationTestInstance(test_instance.TestInstance):
if not self._isolate_delegate and not self._test_data:
logging.warning('No data dependencies will be pushed.')
def _initializeTestFilterAttributes(self, args):
def __initializeTestFilterAttributes(self, args):
self._test_filter = args.test_filter
def annotation_dict_element(a):
@ -257,7 +240,7 @@ class InstrumentationTestInstance(test_instance.TestInstance):
else:
self._excluded_annotations = {}
def _initializeFlagAttributes(self, args):
def __initializeFlagAttributes(self, args):
self._flags = ['--disable-fre', '--enable-test-intents']
# TODO(jbudorick): Transition "--device-flags" to "--device-flags-file"
if hasattr(args, 'device_flags') and args.device_flags:
@ -269,17 +252,9 @@ class InstrumentationTestInstance(test_instance.TestInstance):
stripped_lines = (l.strip() for l in device_flags_file)
self._flags.extend([flag for flag in stripped_lines if flag])
def _initializeDriverAttributes(self):
self._driver_apk = os.path.join(
constants.GetOutDirectory(), constants.SDK_BUILD_APKS_DIR,
'OnDeviceInstrumentationDriver.apk')
if os.path.exists(self._driver_apk):
self._driver_package = apk_helper.GetPackageName(
self._driver_apk)
self._driver_name = apk_helper.GetInstrumentationName(
self._driver_apk)
else:
self._driver_apk = None
@property
def suite(self):
return 'instrumentation'
@property
def apk_under_test(self):
@ -289,26 +264,10 @@ class InstrumentationTestInstance(test_instance.TestInstance):
def flags(self):
return self._flags
@property
def driver_apk(self):
return self._driver_apk
@property
def driver_package(self):
return self._driver_package
@property
def driver_name(self):
return self._driver_name
@property
def package_info(self):
return self._package_info
@property
def suite(self):
return self._suite
@property
def test_apk(self):
return self._test_apk
@ -486,28 +445,6 @@ class InstrumentationTestInstance(test_instance.TestInstance):
})
return inflated_tests
@staticmethod
def GetHttpServerEnvironmentVars():
return {
_EXTRA_ENABLE_HTTP_SERVER: None,
}
def GetDriverEnvironmentVars(
self, test_list=None, test_list_file_path=None):
env = {
_EXTRA_DRIVER_TARGET_PACKAGE: self.test_package,
_EXTRA_DRIVER_TARGET_CLASS: self.test_runner,
}
if test_list:
env[_EXTRA_DRIVER_TEST_LIST] = ','.join(test_list)
if test_list_file_path:
env[_EXTRA_DRIVER_TEST_LIST_FILE] = (
os.path.basename(test_list_file_path))
return env
@staticmethod
def ParseAmInstrumentRawOutput(raw_output):
return ParseAmInstrumentRawOutput(raw_output)

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

@ -130,41 +130,22 @@ class LocalDeviceInstrumentationTestRun(
#override
def _RunTest(self, device, test):
extras = self._test_instance.GetHttpServerEnvironmentVars()
if isinstance(test, list):
if not self._test_instance.driver_apk:
raise Exception('driver_apk does not exist. '
'Please build it and try again.')
def name_and_timeout(t):
n = self._GetTestName(t)
i = self._GetTimeoutFromAnnotations(t['annotations'], n)
return (n, i)
test_names, timeouts = zip(*(name_and_timeout(t) for t in test))
test_name = ','.join(test_names)
target = '%s/%s' % (
self._test_instance.driver_package,
self._test_instance.driver_name)
extras.update(
self._test_instance.GetDriverEnvironmentVars(
test_list=test_names))
timeout = sum(timeouts)
else:
test_name = self._GetTestName(test)
target = '%s/%s' % (
self._test_instance.test_package, self._test_instance.test_runner)
extras['class'] = test_name
timeout = self._GetTimeoutFromAnnotations(test['annotations'], test_name)
test_name = self._GetTestName(test)
logging.info('preparing to run %s: %s' % (test_name, test))
extras = {
'class': test_name,
'org.chromium.chrome.test.ChromeInstrumentationTestRunner'
'.EnableTestHttpServer': '',
}
timeout = self._GetTimeoutFromAnnotations(test['annotations'], test_name)
time_ms = lambda: int(time.time() * 1e3)
start_ms = time_ms()
output = device.StartInstrumentation(
target, raw=True, extras=extras, timeout=timeout, retries=0)
'%s/%s' % (self._test_instance.test_package,
self._test_instance.test_runner),
raw=True, extras=extras, timeout=timeout, retries=0)
duration_ms = time_ms() - start_ms
# TODO(jbudorick): Make instrumentation tests output a JSON so this

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

@ -20,5 +20,4 @@ def TestHttpResponse(response, error_msg):
error_msg: Error message to display if bad response is seen.
"""
if response.status_code != 200:
raise RemoteDeviceError(
'%s (%d: %s)' % (error_msg, response.status_code, response.reason))
raise RemoteDeviceError(error_msg)

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

@ -8,7 +8,6 @@ import logging
import os
import tempfile
from pylib import constants
from pylib.base import base_test_result
from pylib.remote.device import remote_device_test_run
from pylib.utils import apk_helper
@ -26,33 +25,9 @@ class RemoteDeviceInstrumentationTestRun(
def _TriggerSetUp(self):
"""Set up the triggering of a test run."""
logging.info('Triggering test run.')
with tempfile.NamedTemporaryFile(suffix='.txt') as test_list_file:
tests = self._test_instance.GetTests()
logging.debug('preparing to run %d instrumentation tests remotely:',
len(tests))
for t in tests:
test_name = '%s#%s' % (t['class'], t['method'])
logging.debug(' %s', test_name)
test_list_file.write('%s\n' % test_name)
test_list_file.flush()
self._test_instance._data_deps.append(
(os.path.abspath(test_list_file.name), None))
env_vars = self._test_instance.GetDriverEnvironmentVars(
test_list_file_path=test_list_file.name)
env_vars.update(self._test_instance.GetHttpServerEnvironmentVars())
logging.debug('extras:')
for k, v in env_vars.iteritems():
logging.debug(' %s: %s', k, v)
self._AmInstrumentTestSetup(
self._test_instance.apk_under_test,
self._test_instance.driver_apk,
self._test_instance.driver_name,
environment_variables=env_vars,
extra_apks=[self._test_instance.test_apk])
self._AmInstrumentTestSetup(
self._test_instance._apk_under_test, self._test_instance.test_apk,
self._test_instance.test_runner, environment_variables={})
#override
def _ParseTestResults(self):

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

@ -201,7 +201,7 @@ class RemoteDeviceTestRun(test_run.TestRun):
return self._results['status']
def _AmInstrumentTestSetup(self, app_path, test_path, runner_package,
environment_variables, extra_apks=None):
environment_variables):
config = {'runner': runner_package}
if environment_variables:
config['environment_vars'] = ','.join(
@ -213,7 +213,6 @@ class RemoteDeviceTestRun(test_run.TestRun):
if data_deps:
with tempfile.NamedTemporaryFile(suffix='.zip') as test_with_deps:
sdcard_files = []
additional_apks = []
host_test = os.path.basename(test_path)
with zipfile.ZipFile(test_with_deps.name, 'w') as zip_file:
zip_file.write(test_path, host_test, zipfile.ZIP_DEFLATED)
@ -224,14 +223,8 @@ class RemoteDeviceTestRun(test_run.TestRun):
else:
zip_utils.WriteToZipFile(zip_file, h, os.path.basename(h))
sdcard_files.append(os.path.basename(h))
for a in extra_apks or ():
zip_utils.WriteToZipFile(zip_file, a, os.path.basename(a));
additional_apks.append(os.path.basename(a))
config['sdcard_files'] = ','.join(sdcard_files)
config['host_test'] = host_test
if additional_apks:
config['additional_apks'] = ','.join(additional_apks)
self._test_id = self._UploadTestToDevice(
'robotium', test_with_deps.name, app_id=self._app_id)
else:
@ -245,8 +238,7 @@ class RemoteDeviceTestRun(test_run.TestRun):
def _UploadAppToDevice(self, app_path):
"""Upload app to device."""
logging.info('Uploading %s to remote service as %s.', app_path,
self._test_instance.suite)
logging.info('Uploading %s to remote service.', app_path)
with open(app_path, 'rb') as apk_src:
with appurify_sanitized.SanitizeLogging(self._env.verbose_count,
logging.WARNING):
@ -305,4 +297,4 @@ class RemoteDeviceTestRun(test_run.TestRun):
config_response = appurify_sanitized.api.config_upload(
self._env.token, config, self._test_id)
remote_device_helper.TestHttpResponse(
config_response, 'Unable to upload test config.')
config_response, 'Unable to upload test config.')

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

@ -22,7 +22,6 @@
'<(DEPTH)/base/base.gyp:base_java',
'<(DEPTH)/build/android/pylib/device/commands/commands.gyp:chromium_commands',
'<(DEPTH)/build/android/pylib/remote/device/dummy/dummy.gyp:remote_device_dummy_apk',
'<(DEPTH)/testing/android/appurify_support.gyp:appurify_support_java',
'<(DEPTH)/tools/android/android_tools.gyp:android_tools',
],
'conditions': [

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

@ -1566,7 +1566,6 @@ template("unittest_apk") {
deps = [
"//base:base_java",
"//build/android/pylib/remote/device/dummy:remote_device_dummy_apk",
"//testing/android/appurify_support:appurify_support_java",
]
if (defined(invoker.deps)) {
deps += invoker.deps