# Copyright 2016 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # Recipe module for Skia Swarming test. import json DEPS = [ 'env', 'flavor', 'recipe_engine/context', 'recipe_engine/file', 'recipe_engine/path', 'recipe_engine/platform', 'recipe_engine/properties', 'recipe_engine/python', 'recipe_engine/raw_io', 'recipe_engine/step', 'run', 'vars', ] def upload_dm_results(buildername): skip_upload_bots = [ 'ASAN', 'Coverage', 'MSAN', 'TSAN', 'Valgrind', ] for s in skip_upload_bots: if s in buildername: return False return True def test_steps(api): """Run the DM test.""" b = api.properties['buildername'] use_hash_file = False if upload_dm_results(b): host_dm_dir = str(api.flavor.host_dirs.dm_dir) api.flavor.create_clean_host_dir(api.path['start_dir'].join('test')) device_dm_dir = str(api.flavor.device_dirs.dm_dir) if host_dm_dir != device_dm_dir: api.flavor.create_clean_device_dir(device_dm_dir) # Obtain the list of already-generated hashes. hash_filename = 'uninteresting_hashes.txt' host_hashes_file = api.vars.tmp_dir.join(hash_filename) hashes_file = api.flavor.device_path_join( api.flavor.device_dirs.tmp_dir, hash_filename) api.run( api.python.inline, 'get uninteresting hashes', program=""" import contextlib import math import socket import sys import time import urllib2 HASHES_URL = sys.argv[1] RETRIES = 5 TIMEOUT = 60 WAIT_BASE = 15 socket.setdefaulttimeout(TIMEOUT) for retry in range(RETRIES): try: with contextlib.closing( urllib2.urlopen(HASHES_URL, timeout=TIMEOUT)) as w: hashes = w.read() with open(sys.argv[2], 'w') as f: f.write(hashes) break except Exception as e: print 'Failed to get uninteresting hashes from %s:' % HASHES_URL print e if retry == RETRIES: raise waittime = WAIT_BASE * math.pow(2, retry) print 'Retry in %d seconds.' % waittime time.sleep(waittime) """, args=[api.properties['gold_hashes_url'], host_hashes_file], abort_on_failure=False, fail_build_on_failure=False, infra_step=True) if api.path.exists(host_hashes_file): api.flavor.copy_file_to_device(host_hashes_file, hashes_file) use_hash_file = True # Find DM flags. args = json.loads(api.properties['dm_flags']) for i, arg in enumerate(args): if arg == '${SWARMING_BOT_ID}': args[i] = api.vars.swarming_bot_id elif arg == '${SWARMING_TASK_ID}': args[i] = api.vars.swarming_task_id elif arg == '': # Fix quoting issues on some platforms. args[i] = '""' # Paths to required resources. args.extend([ '--resourcePath', api.flavor.device_dirs.resource_dir, '--skps', api.flavor.device_dirs.skp_dir, '--images', api.flavor.device_path_join( api.flavor.device_dirs.images_dir, 'dm'), '--colorImages', api.flavor.device_path_join( api.flavor.device_dirs.images_dir, 'colorspace'), '--svgs', api.flavor.device_dirs.svg_dir, ]) if 'Lottie' in api.vars.builder_cfg.get('extra_config', ''): args.extend([ '--lotties', api.flavor.device_path_join( api.flavor.device_dirs.resource_dir, 'skottie'), api.flavor.device_dirs.lotties_dir, ]) if use_hash_file: args.extend(['--uninterestingHashesFile', hashes_file]) if upload_dm_results(b): args.extend(['--writePath', api.flavor.device_dirs.dm_dir]) # Run DM. api.run(api.flavor.step, 'dm', cmd=args, abort_on_failure=False) if upload_dm_results(b): # Copy images and JSON to host machine if needed. api.flavor.copy_directory_contents_to_host( api.flavor.device_dirs.dm_dir, api.flavor.host_dirs.dm_dir) def RunSteps(api): api.vars.setup() api.file.ensure_directory('makedirs tmp_dir', api.vars.tmp_dir) api.flavor.setup('dm') try: if 'Lottie' in api.vars.builder_name: api.flavor.install(resources=True, lotties=True) else: api.flavor.install(skps=True, images=True, svgs=True, resources=True) test_steps(api) finally: api.flavor.cleanup_steps() api.run.check_failure() TEST_BUILDERS = [ 'Test-Android-Clang-Pixel-GPU-Adreno530-arm-Debug-All-Android_ASAN', 'Test-Android-Clang-Pixel2XL-GPU-Adreno540-arm64-Debug-All-Android', 'Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-Lottie', 'Test-Win10-Clang-ShuttleC-GPU-GTX960-x86_64-Debug-All-ANGLE', ] def GenTests(api): for builder in TEST_BUILDERS: test = ( api.test(builder) + api.properties(buildername=builder, buildbucket_build_id='123454321', dm_flags=('["dm","--dummy","--flags",' '"--swarming-bot-id","${SWARMING_BOT_ID}",' '"--swarming-task-id","${SWARMING_TASK_ID}",' '"--empty-prop",""]'), revision='abc123', path_config='kitchen', gold_hashes_url='https://example.com/hashes.txt', swarm_out_dir='[SWARM_OUT_DIR]', task_id='task_12345') + api.path.exists( api.path['start_dir'].join('skia'), api.path['start_dir'].join('skia', 'infra', 'bots', 'assets', 'skimage', 'VERSION'), api.path['start_dir'].join('skia', 'infra', 'bots', 'assets', 'skp', 'VERSION'), api.path['start_dir'].join('skia', 'infra', 'bots', 'assets', 'svg', 'VERSION'), api.path['start_dir'].join('tmp', 'uninteresting_hashes.txt') ) + api.step_data('get swarming bot id', stdout=api.raw_io.output('skia-bot-123')) + api.step_data('get swarming task id', stdout=api.raw_io.output('123456')) ) if 'Win' in builder and not 'LenovoYogaC630' in builder: test += api.platform('win', 64) yield test