Commit 5b5ab2c4 authored by Jamie Madill's avatar Jamie Madill Committed by Commit Bot

Add render output flag to Android test runner.

This allows the runner to capture the contents of this directory
from the device. The directory is used by ANGLE tests to produce
images for Skia Gold.

Bug: angleproject:4090
Bug: b/168049670
Change-Id: I10a669c21357366a2535d13d5f578771b52e8612
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2434088
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811445}
parent 4692b984
...@@ -308,6 +308,7 @@ class GtestTestInstance(test_instance.TestInstance): ...@@ -308,6 +308,7 @@ class GtestTestInstance(test_instance.TestInstance):
self._isolated_script_test_output = args.isolated_script_test_output self._isolated_script_test_output = args.isolated_script_test_output
self._isolated_script_test_perf_output = ( self._isolated_script_test_perf_output = (
args.isolated_script_test_perf_output) args.isolated_script_test_perf_output)
self._render_test_output_dir = args.render_test_output_dir
self._shard_timeout = args.shard_timeout self._shard_timeout = args.shard_timeout
self._store_tombstones = args.store_tombstones self._store_tombstones = args.store_tombstones
self._suite = args.suite_name[0] self._suite = args.suite_name[0]
...@@ -460,6 +461,10 @@ class GtestTestInstance(test_instance.TestInstance): ...@@ -460,6 +461,10 @@ class GtestTestInstance(test_instance.TestInstance):
def isolated_script_test_perf_output(self): def isolated_script_test_perf_output(self):
return self._isolated_script_test_perf_output return self._isolated_script_test_perf_output
@property
def render_test_output_dir(self):
return self._render_test_output_dir
@property @property
def package(self): def package(self):
return self._apk_helper and self._apk_helper.GetPackageName() return self._apk_helper and self._apk_helper.GetPackageName()
......
...@@ -581,6 +581,24 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun): ...@@ -581,6 +581,24 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun):
return link return link
return None return None
def _PullRenderTestOutput(self, device, render_test_output_device_dir):
# We pull the render tests into a temp directory then copy them over
# individually. Otherwise we end up with a temporary directory name
# in the host output directory.
with tempfile_ext.NamedTemporaryDirectory() as tmp_host_dir:
try:
device.PullFile(render_test_output_device_dir, tmp_host_dir)
except device_errors.CommandFailedError:
logging.exception('Failed to pull render test output dir %s',
render_test_output_device_dir)
temp_host_dir = os.path.join(
tmp_host_dir, os.path.basename(render_test_output_device_dir))
for output_file in os.listdir(temp_host_dir):
src_path = os.path.join(temp_host_dir, output_file)
dst_path = os.path.join(self._test_instance.render_test_output_dir,
output_file)
shutil.move(src_path, dst_path)
@contextlib.contextmanager @contextlib.contextmanager
def _ArchiveLogcat(self, device, test): def _ArchiveLogcat(self, device, test):
if isinstance(test, str): if isinstance(test, str):
...@@ -638,59 +656,72 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun): ...@@ -638,59 +656,72 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun):
device_temp_file.DeviceTempFile( device_temp_file.DeviceTempFile(
adb=device.adb, dir=self._delegate.ResultsDirectory(device)), adb=device.adb, dir=self._delegate.ResultsDirectory(device)),
test_perf_output_filename)) as isolated_script_test_perf_output: test_perf_output_filename)) as isolated_script_test_perf_output:
with contextlib_ext.Optional(
flags = list(self._test_instance.flags) device_temp_file.NamedDeviceTemporaryDirectory(adb=device.adb,
if self._test_instance.enable_xml_result_parsing: dir='/sdcard/'),
flags.append('--gtest_output=xml:%s' % device_tmp_results_file.name) self._test_instance.render_test_output_dir
) as render_test_output_dir:
if self._test_instance.gs_test_artifacts_bucket:
flags.append('--test_artifacts_dir=%s' % test_artifacts_dir.name) flags = list(self._test_instance.flags)
if self._test_instance.enable_xml_result_parsing:
if self._test_instance.isolated_script_test_output: flags.append('--gtest_output=xml:%s' %
flags.append('--isolated-script-test-output=%s' % device_tmp_results_file.name)
device_tmp_results_file.name)
if self._test_instance.gs_test_artifacts_bucket:
if test_perf_output_filename: flags.append('--test_artifacts_dir=%s' % test_artifacts_dir.name)
flags.append('--isolated_script_test_perf_output=%s' %
isolated_script_test_perf_output.name) if self._test_instance.isolated_script_test_output:
flags.append('--isolated-script-test-output=%s' %
logging.info('flags:') device_tmp_results_file.name)
for f in flags:
logging.info(' %s', f) if test_perf_output_filename:
flags.append('--isolated_script_test_perf_output=%s' %
with self._ArchiveLogcat(device, test) as logcat_file: isolated_script_test_perf_output.name)
output = self._delegate.Run(test,
device, if self._test_instance.render_test_output_dir:
flags=' '.join(flags), flags.append('--render-test-output-dir=%s' %
timeout=timeout, render_test_output_dir.name)
retries=0)
logging.info('flags:')
if self._test_instance.enable_xml_result_parsing: for f in flags:
try: logging.info(' %s', f)
gtest_xml = device.ReadFile(device_tmp_results_file.name)
except device_errors.CommandFailedError: with self._ArchiveLogcat(device, test) as logcat_file:
logging.exception('Failed to pull gtest results XML file %s', output = self._delegate.Run(test,
device_tmp_results_file.name) device,
gtest_xml = None flags=' '.join(flags),
timeout=timeout,
if self._test_instance.isolated_script_test_output: retries=0)
try:
gtest_json = device.ReadFile(device_tmp_results_file.name) if self._test_instance.enable_xml_result_parsing:
except device_errors.CommandFailedError: try:
logging.exception('Failed to pull gtest results JSON file %s', gtest_xml = device.ReadFile(device_tmp_results_file.name)
device_tmp_results_file.name) except device_errors.CommandFailedError:
gtest_json = None logging.exception('Failed to pull gtest results XML file %s',
device_tmp_results_file.name)
if test_perf_output_filename: gtest_xml = None
try:
device.PullFile(isolated_script_test_perf_output.name, if self._test_instance.isolated_script_test_output:
test_perf_output_filename) try:
except device_errors.CommandFailedError: gtest_json = device.ReadFile(device_tmp_results_file.name)
logging.exception('Failed to pull chartjson results %s', except device_errors.CommandFailedError:
isolated_script_test_perf_output.name) logging.exception('Failed to pull gtest results JSON file %s',
device_tmp_results_file.name)
test_artifacts_url = self._UploadTestArtifacts(device, gtest_json = None
test_artifacts_dir)
if test_perf_output_filename:
try:
device.PullFile(isolated_script_test_perf_output.name,
test_perf_output_filename)
except device_errors.CommandFailedError:
logging.exception('Failed to pull chartjson results %s',
isolated_script_test_perf_output.name)
test_artifacts_url = self._UploadTestArtifacts(
device, test_artifacts_dir)
if render_test_output_dir:
self._PullRenderTestOutput(device, render_test_output_dir.name)
for s in self._servers[str(device)]: for s in self._servers[str(device)]:
s.Reset() s.Reset()
......
...@@ -227,7 +227,7 @@ def AddCommonOptions(parser): ...@@ -227,7 +227,7 @@ def AddCommonOptions(parser):
dest='run_disabled', action='store_true', dest='run_disabled', action='store_true',
help='Also run disabled tests if applicable.') help='Also run disabled tests if applicable.')
# This is currently only implemented for gtests. # These are currently only implemented for gtests.
parser.add_argument('--isolated-script-test-output', parser.add_argument('--isolated-script-test-output',
help='If present, store test results on this path.') help='If present, store test results on this path.')
parser.add_argument('--isolated-script-test-perf-output', parser.add_argument('--isolated-script-test-perf-output',
...@@ -378,6 +378,9 @@ def AddGTestOptions(parser): ...@@ -378,6 +378,9 @@ def AddGTestOptions(parser):
'--gs-test-artifacts-bucket', '--gs-test-artifacts-bucket',
help=('If present, test artifacts will be uploaded to this Google ' help=('If present, test artifacts will be uploaded to this Google '
'Storage bucket.')) 'Storage bucket.'))
parser.add_argument(
'--render-test-output-dir',
help='If present, store rendering artifacts in this path.')
parser.add_argument( parser.add_argument(
'--runtime-deps-path', '--runtime-deps-path',
dest='runtime_deps_path', type=os.path.realpath, dest='runtime_deps_path', type=os.path.realpath,
......
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