summaryrefslogtreecommitdiffstats
path: root/build/android/pylib/remote/device
diff options
context:
space:
mode:
Diffstat (limited to 'build/android/pylib/remote/device')
-rw-r--r--build/android/pylib/remote/device/remote_device_environment.py29
-rw-r--r--build/android/pylib/remote/device/remote_device_gtest_run.py27
-rw-r--r--build/android/pylib/remote/device/remote_device_test_run.py19
3 files changed, 57 insertions, 18 deletions
diff --git a/build/android/pylib/remote/device/remote_device_environment.py b/build/android/pylib/remote/device/remote_device_environment.py
index 0e48ee6..caf8a51 100644
--- a/build/android/pylib/remote/device/remote_device_environment.py
+++ b/build/android/pylib/remote/device/remote_device_environment.py
@@ -166,37 +166,42 @@ class RemoteDeviceEnvironment(environment.Environment):
raise remote_device_helper.RemoteDeviceError('No device found.')
@property
+ def collect(self):
+ return self._collect
+
+ @property
def device(self):
return self._device
@property
- def token(self):
- return self._access_token
+ def only_output_failures(self):
+ # TODO(jbudorick): Remove this once b/18981674 is fixed.
+ return True
@property
def results_path(self):
return self._results_path
@property
+ def runner_package(self):
+ return self._runner_package
+
+ @property
def runner_type(self):
return self._runner_type
@property
- def runner_package(self):
- return self._runner_package
+ def timeouts(self):
+ return self._timeouts
@property
- def trigger(self):
- return self._trigger
+ def token(self):
+ return self._access_token
@property
- def collect(self):
- return self._collect
+ def trigger(self):
+ return self._trigger
@property
def verbose_count(self):
return self._verbose_count
-
- @property
- def timeouts(self):
- return self._timeouts
diff --git a/build/android/pylib/remote/device/remote_device_gtest_run.py b/build/android/pylib/remote/device/remote_device_gtest_run.py
index 3a6c447..e5f6990 100644
--- a/build/android/pylib/remote/device/remote_device_gtest_run.py
+++ b/build/android/pylib/remote/device/remote_device_gtest_run.py
@@ -7,6 +7,7 @@
import logging
import os
import sys
+import tempfile
from pylib import constants
from pylib.base import base_test_result
@@ -15,6 +16,14 @@ from pylib.remote.device import remote_device_test_run
from pylib.remote.device import remote_device_helper
+_EXTRA_COMMAND_LINE_FILE = (
+ 'org.chromium.native_test.ChromeNativeTestActivity.CommandLineFile')
+# TODO(jbudorick): Remove this extra when b/18981674 is fixed.
+_EXTRA_ONLY_OUTPUT_FAILURES = (
+ 'org.chromium.native_test.ChromeNativeTestInstrumentationTestRunner.'
+ 'OnlyOutputFailures')
+
+
class RemoteDeviceGtestRun(remote_device_test_run.RemoteDeviceTestRun):
"""Run gtests and uirobot tests on a remote device."""
@@ -43,8 +52,20 @@ class RemoteDeviceGtestRun(remote_device_test_run.RemoteDeviceTestRun):
dummy_app_path = os.path.join(
constants.GetOutDirectory(), 'apks', 'remote_device_dummy.apk')
- self._AmInstrumentTestSetup(dummy_app_path, self._test_instance.apk,
- runner_package)
+ with tempfile.NamedTemporaryFile(suffix='.flags.txt') as flag_file:
+ env_vars = {}
+ filter_string = self._test_instance._GenerateDisabledFilterString(None)
+ if filter_string:
+ flag_file.write('_ --gtest_filter=%s' % filter_string)
+ flag_file.flush()
+ env_vars[_EXTRA_COMMAND_LINE_FILE] = os.path.basename(flag_file.name)
+ self._test_instance._data_deps.append(
+ (os.path.abspath(flag_file.name), None))
+ if self._env.only_output_failures:
+ env_vars[_EXTRA_ONLY_OUTPUT_FAILURES] = None
+ self._AmInstrumentTestSetup(
+ dummy_app_path, self._test_instance.apk, runner_package,
+ environment_variables=env_vars)
_INSTRUMENTATION_STREAM_LEADER = 'INSTRUMENTATION_STATUS: stream='
@@ -62,6 +83,8 @@ class RemoteDeviceGtestRun(remote_device_test_run.RemoteDeviceTestRun):
if l.startswith(self._INSTRUMENTATION_STREAM_LEADER))
results_list = self._test_instance.ParseGTestOutput(output)
results.AddResults(results_list)
+ if self._env.only_output_failures:
+ logging.info('See logcat for more results information.')
if not self._results['results']['pass']:
results.AddResult(base_test_result.BaseTestResult(
'Remote Service detected error.',
diff --git a/build/android/pylib/remote/device/remote_device_test_run.py b/build/android/pylib/remote/device/remote_device_test_run.py
index cdc8777..c77d0b4 100644
--- a/build/android/pylib/remote/device/remote_device_test_run.py
+++ b/build/android/pylib/remote/device/remote_device_test_run.py
@@ -170,8 +170,12 @@ class RemoteDeviceTestRun(test_run.TestRun):
self._results = test_check_res.json()['response']
return self._results['status']
- def _AmInstrumentTestSetup(self, app_path, test_path, runner_package):
+ def _AmInstrumentTestSetup(self, app_path, test_path, runner_package,
+ environment_variables):
config = {'runner': runner_package}
+ if environment_variables:
+ config['environment_vars'] = ','.join(
+ '%s=%s' % (k, v) for k, v in environment_variables.iteritems())
self._app_id = self._UploadAppToDevice(app_path)
@@ -183,11 +187,12 @@ class RemoteDeviceTestRun(test_run.TestRun):
with zipfile.ZipFile(test_with_deps.name, 'w') as zip_file:
zip_file.write(test_path, host_test, zipfile.ZIP_DEFLATED)
for h, _ in data_deps:
- zip_utils.WriteToZipFile(zip_file, h, '.')
if os.path.isdir(h):
+ zip_utils.WriteToZipFile(zip_file, h, '.')
sdcard_files.extend(os.listdir(h))
else:
- sdcard_files.extend(h)
+ zip_utils.WriteToZipFile(zip_file, h, os.path.basename(h))
+ sdcard_files.append(os.path.basename(h))
config['sdcard_files'] = ','.join(sdcard_files)
config['host_test'] = host_test
self._test_id = self._UploadTestToDevice(
@@ -232,7 +237,13 @@ class RemoteDeviceTestRun(test_run.TestRun):
"""
logging.info('Generating config file for test.')
with tempfile.TemporaryFile() as config:
- config_data = ['[appurify]', '[%s]' % runner_type]
+ config_data = [
+ '[appurify]',
+ 'pcap=0',
+ 'profiler=0',
+ 'videocapture=0',
+ '[%s]' % runner_type
+ ]
config_data.extend('%s=%s' % (k, v) for k, v in body.iteritems())
config.write(''.join('%s\n' % l for l in config_data))
config.flush()