1# Copyright 2017 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 5PYTHON_VERSION_COMPATIBILITY = "PY3" 6 7DEPS = [ 8 'flavor', 9 'recipe_engine/platform', 10 'recipe_engine/properties', 11 'recipe_engine/raw_io', 12 'run', 13 'vars', 14] 15 16 17def test_exceptions(api): 18 try: 19 api.flavor.copy_directory_contents_to_device('src', 'dst') 20 except ValueError: 21 pass 22 try: 23 api.flavor.copy_directory_contents_to_host('src', 'dst') 24 except ValueError: 25 pass 26 try: 27 api.flavor.copy_file_to_device('src', 'dst') 28 except ValueError: 29 pass 30 31 32def RunSteps(api): 33 api.vars.setup() 34 35 builder = api.properties['buildername'] 36 app = None 37 if 'SkottieTracing' in builder: 38 app = None 39 elif 'Test' in builder: 40 app = 'dm' 41 elif 'Perf' in builder: 42 app = 'nanobench' 43 api.flavor.setup(app) 44 45 if api.properties.get('is_testing_exceptions') == 'True': 46 return test_exceptions(api) 47 48 try: 49 api.flavor.copy_file_to_device('file.txt', 'file.txt') 50 api.flavor.read_file_on_device('file.txt') 51 api.flavor.remove_file_on_device('file.txt') 52 api.flavor.create_clean_host_dir('results_dir') 53 api.flavor.create_clean_device_dir('device_results_dir') 54 55 if 'Lottie' in builder: 56 api.flavor.install(lotties=True) 57 elif all(v in builder for v in ['Perf', 'Android', 'CPU']): 58 api.flavor.install(skps=True, images=True, svgs=True, 59 resources=True, texttraces=True) 60 else: 61 api.flavor.install(skps=True, images=True, lotties=False, 62 svgs=True, resources=True) 63 if 'Test' in builder: 64 api.flavor.step('dm', ['dm', '--some-flag']) 65 api.flavor.copy_directory_contents_to_host( 66 api.flavor.device_dirs.dm_dir, api.flavor.host_dirs.dm_dir) 67 elif 'Perf' in builder: 68 if 'SkottieTracing' in builder: 69 api.flavor.step('dm', ['dm', '--some-flag']) 70 else: 71 api.flavor.step('nanobench', ['nanobench', '--some-flag']) 72 api.flavor.copy_directory_contents_to_host( 73 api.flavor.device_dirs.perf_data_dir, 74 api.flavor.host_dirs.perf_data_dir) 75 finally: 76 api.flavor.cleanup_steps() 77 api.run.check_failure() 78 79 80TEST_BUILDERS = [ 81 'Perf-Android-Clang-AndroidOne-GPU-Mali400MP2-arm-Release-All-Android_SkottieTracing', 82 'Perf-Android-Clang-GalaxyS7_G930FD-GPU-MaliT880-arm64-Debug-All-Android', 83 'Perf-Android-Clang-NVIDIA_Shield-CPU-TegraX1-arm64-Release-All-Android', 84 'Perf-Android-Clang-Nexus5x-GPU-Adreno418-arm64-Debug-All-Android', 85 'Perf-Android-Clang-GalaxyS20-GPU-MaliG77-arm64-Release-All-Android_Vulkan', 86 'Perf-Android-Clang-Pixel6-GPU-Adreno620-arm64-Release-All-Android', 87 'Perf-ChromeOS-Clang-SamsungChromebookPlus-GPU-MaliT860-arm-Release-All', 88 'Perf-Debian10-Clang-GCE-CPU-AVX2-x86_64-Debug-All-MSAN', 89 'Perf-Debian10-Clang-GCE-CPU-AVX2-x86_64-Release-All-ASAN', 90 'Perf-Win2019-Clang-GCE-CPU-AVX2-x86_64-Debug-All-ASAN', 91 'Test-Android-Clang-AndroidOne-GPU-Mali400MP2-arm-Release-All-Android', 92 'Test-Android-Clang-GalaxyS7_G930FD-GPU-MaliT880-arm64-Debug-All-Android', 93 'Test-Android-Clang-Nexus5x-GPU-Adreno418-arm64-Debug-All-Android', 94 'Test-Android-Clang-Nexus5x-GPU-Adreno418-arm64-Release-All-Android_ASAN', 95 'Test-Android-Clang-Pixel3a-GPU-Adreno615-arm64-Debug-All-Android_Vulkan', 96 'Test-ChromeOS-Clang-SamsungChromebookPlus-GPU-MaliT860-arm-Release-All', 97 'Test-Debian10-Clang-GCE-CPU-AVX2-x86_64-Debug-All-Coverage', 98 'Test-Debian10-Clang-GCE-CPU-AVX2-x86_64-Release-All-Lottie', 99 'Test-Debian10-Clang-GCE-CPU-AVX2-x86_64-Release-All-TSAN', 100 'Test-Debian10-Clang-GCE-GPU-SwiftShader-x86_64-Debug-All-SwiftShader', 101 'Test-Debian10-Clang-NUC7i5BNK-GPU-IntelIris640-x86_64-Debug-All-Vulkan', 102 'Test-Mac10.13-Clang-MacBookPro11.5-CPU-AVX2-x86_64-Debug-All-ASAN', 103 ('Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Release-All' 104 '-Valgrind_AbandonGpuContext_SK_CPU_LIMIT_SSE41'), 105 'Test-Debian10-Clang-NUC7i5BNK-GPU-IntelIris640-x86_64-Debug-All-ASAN_Vulkan', 106 'Test-Debian11-Clang-NUC11TZi5-GPU-IntelIrisXe-x86_64-Debug-All', 107 'Test-Win10-Clang-NUC5i7RYH-CPU-AVX2-x86_64-Debug-All-NativeFonts_DWriteCore', 108] 109 110# Default properties used for TEST_BUILDERS. 111defaultProps = lambda buildername: dict( 112 buildername=buildername, 113 repository='https://skia.googlesource.com/skia.git', 114 revision='abc123', 115 path_config='kitchen', 116 patch_set=2, 117 swarm_out_dir='[SWARM_OUT_DIR]' 118) 119 120def GenTests(api): 121 for buildername in TEST_BUILDERS: 122 test = ( 123 api.test(buildername) + 124 api.properties(**defaultProps(buildername)) 125 ) 126 if 'Win' in buildername: 127 test += api.platform('win', 64) 128 yield test 129 130 builder = 'Test-Debian10-Clang-GCE-CPU-AVX2-x86_64-Release-All' 131 yield ( 132 api.test('exceptions') + 133 api.properties(buildername=builder, 134 repository='https://skia.googlesource.com/skia.git', 135 revision='abc123', 136 path_config='kitchen', 137 swarm_out_dir='[SWARM_OUT_DIR]', 138 is_testing_exceptions='True') 139 ) 140 141 builder = ('Perf-Android-Clang-Nexus5x-GPU-Adreno418-arm64-Debug-All' 142 '-Android') 143 yield ( 144 api.test('failed_infra_step') + 145 api.properties(buildername=builder, 146 repository='https://skia.googlesource.com/skia.git', 147 revision='abc123', 148 path_config='kitchen', 149 swarm_out_dir='[SWARM_OUT_DIR]') + 150 api.step_data('get swarming bot id', 151 stdout=api.raw_io.output('build123-m2--device5')) + 152 api.step_data('dump log', retcode=1) 153 ) 154 155 yield ( 156 api.test('failed_read_version') + 157 api.properties(buildername=builder, 158 repository='https://skia.googlesource.com/skia.git', 159 revision='abc123', 160 path_config='kitchen', 161 swarm_out_dir='[SWARM_OUT_DIR]') + 162 api.step_data('read /sdcard/revenge_of_the_skiabot/SK_IMAGE_VERSION', 163 retcode=1) 164 ) 165 166 yield ( 167 api.test('retry_adb_command') + 168 api.properties(buildername=builder, 169 repository='https://skia.googlesource.com/skia.git', 170 revision='abc123', 171 path_config='kitchen', 172 swarm_out_dir='[SWARM_OUT_DIR]') + 173 api.step_data('mkdir /sdcard/revenge_of_the_skiabot/resources', 174 retcode=1) 175 ) 176 177 fail_step_name = 'mkdir /sdcard/revenge_of_the_skiabot/resources' 178 yield ( 179 api.test('retry_adb_command_retries_exhausted') + 180 api.properties(buildername=builder, 181 repository='https://skia.googlesource.com/skia.git', 182 revision='abc123', 183 path_config='kitchen', 184 swarm_out_dir='[SWARM_OUT_DIR]') + 185 api.step_data('get swarming bot id', 186 stdout=api.raw_io.output('build123-m2--device5')) + 187 api.step_data(fail_step_name, retcode=1) + 188 api.step_data(fail_step_name + ' (attempt 2)', retcode=1) + 189 api.step_data(fail_step_name + ' (attempt 3)', retcode=1) 190 ) 191 192 builder = 'Test-iOS-Clang-iPhone7-GPU-PowerVRGT7600-arm64-Release-All' 193 fail_step_name = 'install dm' 194 yield ( 195 api.test('retry_ios_install') + 196 api.properties(buildername=builder, 197 repository='https://skia.googlesource.com/skia.git', 198 revision='abc123', 199 path_config='kitchen', 200 swarm_out_dir='[SWARM_OUT_DIR]') + 201 api.step_data(fail_step_name, retcode=1) 202 ) 203 204 yield ( 205 api.test('retry_ios_install_retries_exhausted') + 206 api.properties(buildername=builder, 207 repository='https://skia.googlesource.com/skia.git', 208 revision='abc123', 209 path_config='kitchen', 210 swarm_out_dir='[SWARM_OUT_DIR]') + 211 api.step_data(fail_step_name, retcode=1) + 212 api.step_data(fail_step_name + ' (attempt 2)', retcode=1) 213 ) 214 fail_step_name = 'dm' 215 yield ( 216 api.test('ios_rerun_with_debug') + 217 api.properties(buildername=builder, 218 repository='https://skia.googlesource.com/skia.git', 219 revision='abc123', 220 path_config='kitchen', 221 swarm_out_dir='[SWARM_OUT_DIR]') + 222 api.step_data(fail_step_name, retcode=1) 223 ) 224 225 builder = ('Perf-Android-Clang-Nexus5x-GPU-Adreno418-arm64-Debug-All' 226 '-Android') 227 yield ( 228 api.test('cpu_scale_failed_once') + 229 api.properties(buildername=builder, 230 revision='abc123', 231 path_config='kitchen', 232 swarm_out_dir='[SWARM_OUT_DIR]') + 233 api.step_data('Scale CPU 4 to 0.600000', retcode=1) 234 ) 235 236 yield ( 237 api.test('cpu_scale_failed') + 238 api.properties(buildername=builder, 239 revision='abc123', 240 path_config='kitchen', 241 swarm_out_dir='[SWARM_OUT_DIR]') + 242 api.step_data('get swarming bot id', 243 stdout=api.raw_io.output('skia-rpi-022')) + 244 api.step_data('Scale CPU 4 to 0.600000', retcode=1)+ 245 api.step_data('Scale CPU 4 to 0.600000 (attempt 2)', retcode=1)+ 246 api.step_data('Scale CPU 4 to 0.600000 (attempt 3)', retcode=1) 247 ) 248 249 builder = ('Perf-Android-Clang-Nexus5x-GPU-Adreno418-arm64-Release' 250 '-All-Android') 251 yield ( 252 api.test('cpu_scale_failed_golo') + 253 api.properties(buildername=builder, 254 revision='abc123', 255 path_config='kitchen', 256 swarm_out_dir='[SWARM_OUT_DIR]') + 257 api.step_data('get swarming bot id', 258 stdout=api.raw_io.output('build123-m2--device5')) + 259 api.step_data('Scale CPU 4 to 0.600000', retcode=1)+ 260 api.step_data('Scale CPU 4 to 0.600000 (attempt 2)', retcode=1)+ 261 api.step_data('Scale CPU 4 to 0.600000 (attempt 3)', retcode=1) 262 ) 263