| 1 |
# Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 |
# Use of this source code is governed by a BSD-style license that can be |
| 3 |
# found in the LICENSE file. |
| 4 |
|
| 5 |
|
| 6 |
# Recipe module for Skia Swarming test. |
| 7 |
|
| 8 |
|
| 9 |
import json |
| 10 |
|
| 11 |
|
| 12 |
DEPS = [ |
| 13 |
'env', |
| 14 |
'flavor', |
| 15 |
'recipe_engine/context', |
| 16 |
'recipe_engine/file', |
| 17 |
'recipe_engine/path', |
| 18 |
'recipe_engine/platform', |
| 19 |
'recipe_engine/properties', |
| 20 |
'recipe_engine/raw_io', |
| 21 |
'recipe_engine/step', |
| 22 |
'gold_upload', |
| 23 |
'run', |
| 24 |
'vars', |
| 25 |
] |
| 26 |
|
| 27 |
DM_JSON = 'dm.json' |
| 28 |
|
| 29 |
def test_steps(api): |
| 30 |
"""Run the DM test.""" |
| 31 |
do_upload = api.properties.get('do_upload') == 'true' |
| 32 |
images = api.properties.get('images') == 'true' |
| 33 |
lotties = api.properties.get('lotties') == 'true' |
| 34 |
resources = api.properties.get('resources') == 'true' |
| 35 |
skps = api.properties.get('skps') == 'true' |
| 36 |
svgs = api.properties.get('svgs') == 'true' |
| 37 |
|
| 38 |
api.flavor.install( |
| 39 |
images=images, |
| 40 |
lotties=lotties, |
| 41 |
resources=resources, |
| 42 |
skps=skps, |
| 43 |
svgs=svgs, |
| 44 |
) |
| 45 |
|
| 46 |
use_hash_file = False |
| 47 |
if do_upload: |
| 48 |
host_dm_dir = str(api.flavor.host_dirs.dm_dir) |
| 49 |
api.flavor.create_clean_host_dir(api.path.start_dir.joinpath('test')) |
| 50 |
device_dm_dir = str(api.flavor.device_dirs.dm_dir) |
| 51 |
if host_dm_dir != device_dm_dir: |
| 52 |
api.flavor.create_clean_device_dir(device_dm_dir) |
| 53 |
|
| 54 |
# Obtain the list of already-generated hashes. |
| 55 |
hash_filename = 'uninteresting_hashes.txt' |
| 56 |
|
| 57 |
host_hashes_file = api.vars.tmp_dir.joinpath(hash_filename) |
| 58 |
hashes_file = api.flavor.device_path_join( |
| 59 |
api.flavor.device_dirs.tmp_dir, hash_filename) |
| 60 |
script = api.gold_upload.resource('get_uninteresting_hashes.py') |
| 61 |
api.run( |
| 62 |
api.step, |
| 63 |
'get uninteresting hashes', |
| 64 |
cmd=['python3', script, api.properties['gold_hashes_url'], |
| 65 |
host_hashes_file], |
| 66 |
# If this fails, we want to know about it because it means Gold is down |
| 67 |
# and proceeding onwards would take a very long time, but be hard to notice. |
| 68 |
abort_on_failure=True, |
| 69 |
fail_build_on_failure=True, |
| 70 |
infra_step=True) |
| 71 |
|
| 72 |
if api.path.exists(host_hashes_file): |
| 73 |
api.flavor.copy_file_to_device(host_hashes_file, hashes_file) |
| 74 |
use_hash_file = True |
| 75 |
|
| 76 |
# Find DM flags. |
| 77 |
args = json.loads(api.properties['dm_flags']) |
| 78 |
props = json.loads(api.properties['dm_properties']) |
| 79 |
args.append('--properties') |
| 80 |
# Map iteration order is arbitrary; in order to maintain a consistent step |
| 81 |
# ordering, sort by key. |
| 82 |
for k in sorted(props.keys()): |
| 83 |
v = props[k] |
| 84 |
if v == '${SWARMING_BOT_ID}': |
| 85 |
v = api.vars.swarming_bot_id |
| 86 |
elif v == '${SWARMING_TASK_ID}': |
| 87 |
v = api.vars.swarming_task_id |
| 88 |
if v != '': |
| 89 |
args.extend([k, v]) |
| 90 |
|
| 91 |
# Paths to required resources. |
| 92 |
if resources: |
| 93 |
args.extend(['--resourcePath', api.flavor.device_dirs.resource_dir]) |
| 94 |
if skps: |
| 95 |
args.extend(['--skps', api.flavor.device_dirs.skp_dir]) |
| 96 |
if images: |
| 97 |
args.extend([ |
| 98 |
'--images', api.flavor.device_path_join( |
| 99 |
api.flavor.device_dirs.images_dir, 'dm'), |
| 100 |
'--colorImages', api.flavor.device_path_join( |
| 101 |
api.flavor.device_dirs.images_dir, 'colorspace'), |
| 102 |
]) |
| 103 |
if svgs: |
| 104 |
# svg_dir is the root of the SVG corpus. Within that directory, |
| 105 |
# the *.svg inputs are in the 'svg' subdirectory. See skbug.com/40042605 |
| 106 |
args.extend(['--svgs', api.flavor.device_path_join( |
| 107 |
api.flavor.device_dirs.svg_dir, "svg")]) |
| 108 |
if lotties: |
| 109 |
args.extend([ |
| 110 |
'--lotties', |
| 111 |
api.flavor.device_path_join( |
| 112 |
api.flavor.device_dirs.resource_dir, 'skottie'), |
| 113 |
api.flavor.device_dirs.lotties_dir, |
| 114 |
]) |
| 115 |
if 'Fontations' in api.vars.builder_cfg.get('extra_config', []): |
| 116 |
args.extend(['--fontTestDataPath', api.flavor.device_dirs.fonts_dir]) |
| 117 |
|
| 118 |
if use_hash_file: |
| 119 |
args.extend(['--uninterestingHashesFile', hashes_file]) |
| 120 |
if do_upload: |
| 121 |
args.extend(['--writePath', api.flavor.device_dirs.dm_dir]) |
| 122 |
|
| 123 |
# Run DM. |
| 124 |
api.run(api.flavor.step, 'dm', cmd=args, abort_on_failure=False) |
| 125 |
|
| 126 |
if do_upload: |
| 127 |
# Copy images and JSON to host machine if needed. |
| 128 |
api.flavor.copy_directory_contents_to_host( |
| 129 |
api.flavor.device_dirs.dm_dir, api.flavor.host_dirs.dm_dir) |
| 130 |
# https://bugs.chromium.org/p/chromium/issues/detail?id=1192611 |
| 131 |
if 'Win' not in api.vars.builder_cfg.get('os', ''): |
| 132 |
api.gold_upload.upload() |
| 133 |
|
| 134 |
|
| 135 |
def RunSteps(api): |
| 136 |
api.vars.setup() |
| 137 |
api.file.ensure_directory('makedirs tmp_dir', api.vars.tmp_dir) |
| 138 |
api.flavor.setup('dm') |
| 139 |
|
| 140 |
try: |
| 141 |
test_steps(api) |
| 142 |
finally: |
| 143 |
api.flavor.cleanup_steps() |
| 144 |
api.run.check_failure() |
| 145 |
|
| 146 |
|
| 147 |
TEST_BUILDERS = [ |
| 148 |
'Test-Android12-Clang-Pixel5-GPU-Adreno620-arm64-Release-All-Android_Vulkan', |
| 149 |
'Test-Debian10-Clang-GCE-CPU-AVX2-x86_64-Release-All-Lottie', |
| 150 |
'Test-Win11-Clang-Dell3930-GPU-GTX1660-x86_64-Debug-All', |
| 151 |
'Test-Debian10-Clang-GCE-CPU-AVX2-x86_64-Debug-All-Fontations', |
| 152 |
] |
| 153 |
|
| 154 |
|
| 155 |
def GenTests(api): |
| 156 |
for builder in TEST_BUILDERS: |
| 157 |
props = dict( |
| 158 |
buildername=builder, |
| 159 |
buildbucket_build_id='123454321', |
| 160 |
dm_flags='["dm","--example","--flags"]', |
| 161 |
dm_properties=('{"key1":"value1","key2":"",' |
| 162 |
'"bot":"${SWARMING_BOT_ID}",' |
| 163 |
'"task":"${SWARMING_TASK_ID}"}'), |
| 164 |
revision='abc123', |
| 165 |
gs_bucket='skia-infra-gm', |
| 166 |
patch_ref='89/456789/12', |
| 167 |
patch_set=7, |
| 168 |
patch_issue=1234, |
| 169 |
path_config='kitchen', |
| 170 |
gold_hashes_url='https://example.com/hashes.txt', |
| 171 |
swarm_out_dir='[SWARM_OUT_DIR]', |
| 172 |
task_id='task_12345', |
| 173 |
resources='true', |
| 174 |
) |
| 175 |
if 'ASAN' not in builder: |
| 176 |
props['do_upload'] = 'true' |
| 177 |
if 'Lottie' in builder: |
| 178 |
props['lotties'] = 'true' |
| 179 |
else: |
| 180 |
props['images'] = 'true' |
| 181 |
props['skps'] = 'true' |
| 182 |
props['svgs'] = 'true' |
| 183 |
test = ( |
| 184 |
api.test(builder) + |
| 185 |
api.properties(**props) + |
| 186 |
api.path.exists( |
| 187 |
api.path.start_dir.joinpath('skia'), |
| 188 |
api.path.start_dir.joinpath('skia', 'infra', 'bots', 'assets', |
| 189 |
'skimage', 'VERSION'), |
| 190 |
api.path.start_dir.joinpath('skia', 'infra', 'bots', 'assets', |
| 191 |
'skp', 'VERSION'), |
| 192 |
api.path.start_dir.joinpath('skia', 'infra', 'bots', 'assets', |
| 193 |
'svg', 'VERSION'), |
| 194 |
api.path.start_dir.joinpath('tmp', 'uninteresting_hashes.txt') |
| 195 |
) + |
| 196 |
api.step_data('get swarming bot id', |
| 197 |
stdout=api.raw_io.output('skia-bot-123')) + |
| 198 |
api.step_data('get swarming task id', |
| 199 |
stdout=api.raw_io.output('123456')) |
| 200 |
) |
| 201 |
if 'Win' in builder: |
| 202 |
test += api.platform('win', 64) |
| 203 |
|
| 204 |
yield test |