| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 #!/usr/bin/env python | 
|  | 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 
|  | 3 # Use of this source code is governed by a BSD-style license that can be | 
|  | 4 # found in the LICENSE file. | 
|  | 5 | 
|  | 6 """This script is meant to be run on a Swarming bot.""" | 
|  | 7 | 
|  | 8 import argparse | 
|  | 9 import os | 
|  | 10 import subprocess | 
|  | 11 import sys | 
|  | 12 | 
|  | 13 | 
|  | 14 PARENT_DIR = os.path.dirname(os.path.realpath(__file__)) | 
|  | 15 | 
|  | 16 REPOS_BASE_DIR = os.path.normpath(os.path.join( | 
|  | 17     PARENT_DIR, os.pardir, os.pardir, os.pardir, os.pardir)) | 
|  | 18 | 
|  | 19 SKIA_SRC_DIR = os.path.join(REPOS_BASE_DIR, 'skia') | 
|  | 20 | 
|  | 21 | 
|  | 22 def main(): | 
|  | 23   parser = argparse.ArgumentParser() | 
|  | 24   parser.add_argument('-s', '--slave_num', required=True, type=int, | 
|  | 25                       help='The slave num of this CT run.') | 
|  | 26   parser.add_argument('-t', '--tool', required=True, | 
|  | 27                       choices=['dm', 'nanobench', 'get_images_from_skps'], | 
|  | 28                       help='The tool to run on the SKPs.') | 
|  | 29   parser.add_argument('-g', '--git_hash', required=True, | 
|  | 30                       help='The Skia hash the tool was built at.') | 
|  | 31   parser.add_argument('-c', '--configuration', required=True, | 
|  | 32                       help='The build configuration to use.') | 
|  | 33   parser.add_argument('-i', '--isolated_outdir', required=True, | 
|  | 34                       help='Swarming will automatically upload to ' | 
|  | 35                            'isolateserver all artifacts in this dir.') | 
|  | 36   parser.add_argument('-b', '--builder', required=True, | 
|  | 37                       help='The name of the builder.') | 
|  | 38   args = parser.parse_args() | 
|  | 39 | 
|  | 40   tool_path = os.path.join(PARENT_DIR, args.tool) | 
|  | 41   skps_dir = os.path.join(REPOS_BASE_DIR, 'skps', args.builder, | 
|  | 42                           'slave%d' % args.slave_num) | 
|  | 43   resource_path = os.path.join(SKIA_SRC_DIR, 'resources') | 
|  | 44 | 
|  | 45   cmd = [tool_path] | 
|  | 46   if args.tool == 'dm': | 
|  | 47     # Add DM specific arguments. | 
|  | 48     cmd.extend([ | 
|  | 49       '--src', 'skp', | 
|  | 50       '--skps', skps_dir, | 
|  | 51       '--resourcePath', resource_path, | 
|  | 52       '--config', '8888', | 
|  | 53       '--verbose', | 
|  | 54     ]) | 
|  | 55   elif args.tool == 'nanobench': | 
|  | 56     # Add Nanobench specific arguments. | 
|  | 57     config = '8888' | 
|  | 58     cpu_or_gpu = 'CPU' | 
|  | 59     cpu_or_gpu_value = 'AVX2' | 
|  | 60     if 'GPU' in args.builder: | 
|  | 61       config = 'gpu' | 
|  | 62       cpu_or_gpu = 'GPU' | 
|  | 63       cpu_or_gpu_value = 'GT610' | 
|  | 64 | 
|  | 65     out_results_file = os.path.join( | 
|  | 66         args.isolated_outdir, 'nanobench_%s_%s_slave%d.json' % ( | 
|  | 67             args.git_hash, config, args.slave_num)) | 
|  | 68     cmd.extend([ | 
|  | 69       '--skps', skps_dir, | 
|  | 70       '--match', 'skp', | 
|  | 71       '--resourcePath', resource_path, | 
|  | 72       '--config', config, | 
|  | 73       '--outResultsFile', out_results_file, | 
|  | 74       '--properties', 'gitHash', args.git_hash, | 
|  | 75       '--key', 'arch', 'x86_64', | 
|  | 76                'compiler', 'GCC', | 
|  | 77                'cpu_or_gpu', cpu_or_gpu, | 
|  | 78                'cpu_or_gpu_value', cpu_or_gpu_value, | 
|  | 79                'model', 'SWARM', | 
|  | 80                'os', 'Ubuntu', | 
|  | 81       '--verbose', | 
|  | 82     ]) | 
|  | 83   elif args.tool == 'get_images_from_skps': | 
|  | 84     # Add get_images_from_skps specific arguments. | 
|  | 85     img_out = os.path.join(args.isolated_outdir, 'img_out') | 
|  | 86     os.makedirs(img_out) | 
|  | 87     failures_json_out = os.path.join(args.isolated_outdir, 'failures.json') | 
|  | 88     cmd.extend([ | 
|  | 89       '--out', img_out, | 
|  | 90       '--skps', skps_dir, | 
|  | 91       '--failuresJsonPath', failures_json_out, | 
|  | 92       '--writeImages', 'false', | 
|  | 93       '--testDecode', | 
|  | 94     ]) | 
|  | 95 | 
|  | 96   return subprocess.call(cmd) | 
|  | 97 | 
|  | 98 | 
|  | 99 if __name__ == '__main__': | 
|  | 100   sys.exit(main()) | 
| OLD | NEW | 
|---|