Commit e627ef8b authored by Edward Lemur's avatar Edward Lemur Committed by Commit Bot

Add support to extract ChartJSON test results from android devices.

Add a '--chartjson_result_file' flag to extract ChartJSON test results from
android devices.

R=jbudorick@chromium.org

Bug: webrtc:8566
Change-Id: I050d1f714471a5525e91d36d1e792815cb4578ae
Reviewed-on: https://chromium-review.googlesource.com/819831
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: default avatarJohn Budorick <jbudorick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523758}
parent 6ecbe1f5
......@@ -282,16 +282,17 @@ class GtestTestInstance(test_instance.TestInstance):
# TODO(jbudorick): Support multiple test suites.
if len(args.suite_name) > 1:
raise ValueError('Platform mode currently supports only 1 gtest suite')
self._chartjson_result_file = args.chartjson_result_file
self._exe_dist_dir = None
self._external_shard_index = args.test_launcher_shard_index
self._extract_test_list_from_filter = args.extract_test_list_from_filter
self._filter_tests_lock = threading.Lock()
self._gs_test_artifacts_bucket = args.gs_test_artifacts_bucket
self._shard_timeout = args.shard_timeout
self._store_tombstones = args.store_tombstones
self._total_external_shards = args.test_launcher_total_shards
self._suite = args.suite_name[0]
self._symbolizer = stack_symbolizer.Symbolizer(None, False)
self._gs_test_artifacts_bucket = args.gs_test_artifacts_bucket
self._total_external_shards = args.test_launcher_total_shards
self._wait_for_java_debugger = args.wait_for_java_debugger
# GYP:
......@@ -429,6 +430,10 @@ class GtestTestInstance(test_instance.TestInstance):
def gtest_filter(self):
return self._gtest_filter
@property
def chartjson_result_file(self):
return self._chartjson_result_file
@property
def package(self):
return self._apk_helper and self._apk_helper.GetPackageName()
......
......@@ -469,54 +469,71 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun):
device_temp_file.NamedDeviceTemporaryDirectory(
adb=device.adb, dir='/sdcard/'),
self._test_instance.gs_test_artifacts_bucket) as test_artifacts_dir:
flags = list(self._test_instance.flags)
if self._test_instance.enable_xml_result_parsing:
flags.append('--gtest_output=xml:%s' % device_tmp_results_file.name)
if self._test_instance.gs_test_artifacts_bucket:
flags.append('--test_artifacts_dir=%s' % test_artifacts_dir.name)
logging.info('flags:')
for f in flags:
logging.info(' %s', f)
stream_name = 'logcat_%s_%s_%s' % (
hash(tuple(test)),
time.strftime('%Y%m%dT%H%M%S-UTC', time.gmtime()),
device.serial)
with self._env.output_manager.ArchivedTempfile(
stream_name, 'logcat') as logcat_file:
with logcat_monitor.LogcatMonitor(
device.adb,
filter_specs=local_device_environment.LOGCAT_FILTERS,
output_file=logcat_file.name) as logmon:
with contextlib_ext.Optional(
trace_event.trace(str(test)),
self._env.trace_output):
output = self._delegate.Run(
test, device, flags=' '.join(flags),
timeout=timeout, retries=0)
logmon.Close()
if logcat_file.Link():
logging.info('Logcat saved to %s', logcat_file.Link())
if self._test_instance.enable_xml_result_parsing:
try:
gtest_xml = device.ReadFile(
device_tmp_results_file.name,
as_root=True)
except device_errors.CommandFailedError as e:
logging.warning(
'Failed to pull gtest results XML file %s: %s',
device_tmp_results_file.name,
str(e))
gtest_xml = None
test_artifacts_url = self._UploadTestArtifacts(device,
test_artifacts_dir)
with contextlib_ext.Optional(
device_temp_file.DeviceTempFile(
adb=device.adb, dir=self._delegate.ResultsDirectory(device)),
self._test_instance.chartjson_result_file) as chartjson_result_file:
flags = list(self._test_instance.flags)
if self._test_instance.enable_xml_result_parsing:
flags.append('--gtest_output=xml:%s' % device_tmp_results_file.name)
if self._test_instance.gs_test_artifacts_bucket:
flags.append('--test_artifacts_dir=%s' % test_artifacts_dir.name)
if self._test_instance.chartjson_result_file:
flags.append('--chartjson_result_file=%s'
% chartjson_result_file.name)
logging.info('flags:')
for f in flags:
logging.info(' %s', f)
stream_name = 'logcat_%s_%s_%s' % (
hash(tuple(test)),
time.strftime('%Y%m%dT%H%M%S-UTC', time.gmtime()),
device.serial)
with self._env.output_manager.ArchivedTempfile(
stream_name, 'logcat') as logcat_file:
with logcat_monitor.LogcatMonitor(
device.adb,
filter_specs=local_device_environment.LOGCAT_FILTERS,
output_file=logcat_file.name) as logmon:
with contextlib_ext.Optional(
trace_event.trace(str(test)),
self._env.trace_output):
output = self._delegate.Run(
test, device, flags=' '.join(flags),
timeout=timeout, retries=0)
logmon.Close()
if logcat_file.Link():
logging.info('Logcat saved to %s', logcat_file.Link())
if self._test_instance.enable_xml_result_parsing:
try:
gtest_xml = device.ReadFile(
device_tmp_results_file.name,
as_root=True)
except device_errors.CommandFailedError as e:
logging.warning(
'Failed to pull gtest results XML file %s: %s',
device_tmp_results_file.name,
str(e))
gtest_xml = None
if self._test_instance.chartjson_result_file:
try:
device.PullFile(chartjson_result_file.name,
self._test_instance.chartjson_result_file)
except device_errors.CommandFailedError as e:
logging.warning(
'Failed to pull chartjson results %s: %s',
chartjson_result_file.name, str(e))
test_artifacts_url = self._UploadTestArtifacts(device,
test_artifacts_dir)
for s in self._servers[str(device)]:
s.Reset()
......
......@@ -299,6 +299,9 @@ def AddGTestOptions(parser):
'--app-data-file-dir',
help='Host directory to which app data files will be'
' saved. Used with --app-data-file.')
parser.add_argument(
'--chartjson-result-file',
help='If present, store chartjson results on this path.')
parser.add_argument(
'--delete-stale-data',
dest='delete_stale_data', action='store_true',
......@@ -319,6 +322,10 @@ def AddGTestOptions(parser):
'device for the list of all tests. Speeds up local '
'development, but is not safe to use on bots ('
'http://crbug.com/549214')
parser.add_argument(
'--gs-test-artifacts-bucket',
help=('If present, test artifacts will be uploaded to this Google '
'Storage bucket.'))
parser.add_argument(
'--gtest_also_run_disabled_tests', '--gtest-also-run-disabled-tests',
dest='run_disabled', action='store_true',
......@@ -360,11 +367,6 @@ def AddGTestOptions(parser):
help='Path to file that contains googletest-style filter strings. '
'See also //testing/buildbot/filters/README.md.')
parser.add_argument(
'--gs-test-artifacts-bucket',
help=('If present, test artifacts will be uploaded to this Google '
'Storage bucket.'))
def AddInstrumentationTestOptions(parser):
"""Adds Instrumentation test options to |parser|."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment