OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """This script is meant to be run on a Swarming bot.""" | 6 """This script is meant to be run on a Swarming bot.""" |
7 | 7 |
8 import argparse | 8 import argparse |
9 import os | 9 import os |
10 import subprocess | 10 import subprocess |
11 import sys | 11 import sys |
| 12 import zipfile |
12 | 13 |
13 | 14 |
14 PARENT_DIR = os.path.dirname(os.path.realpath(__file__)) | 15 PARENT_DIR = os.path.dirname(os.path.realpath(__file__)) |
15 | 16 |
16 REPOS_BASE_DIR = os.path.normpath(os.path.join( | 17 REPOS_BASE_DIR = os.path.normpath(os.path.join( |
17 PARENT_DIR, os.pardir, os.pardir, os.pardir, os.pardir)) | 18 PARENT_DIR, os.pardir, os.pardir, os.pardir, os.pardir)) |
18 | 19 |
19 SKIA_SRC_DIR = os.path.join(REPOS_BASE_DIR, 'skia') | 20 SKIA_SRC_DIR = os.path.join(REPOS_BASE_DIR, 'skia') |
20 | 21 |
21 | 22 |
22 def main(): | 23 def main(): |
23 parser = argparse.ArgumentParser() | 24 parser = argparse.ArgumentParser() |
24 parser.add_argument('-s', '--slave_num', required=True, type=int, | 25 parser.add_argument('-s', '--slave_num', required=True, type=int, |
25 help='The slave num of this CT run.') | 26 help='The slave num of this CT run.') |
26 parser.add_argument('-t', '--tool', required=True, | 27 parser.add_argument('-t', '--tool', required=True, |
27 choices=['dm', 'nanobench'], | 28 choices=['dm', 'nanobench'], |
28 help='The tool to run on the SKPs.') | 29 help='The tool to run on the SKPs.') |
29 parser.add_argument('-g', '--git_hash', required=True, | 30 parser.add_argument('-g', '--git_hash', required=True, |
30 help='The Skia hash the tool was built at.') | 31 help='The Skia hash the tool was built at.') |
31 parser.add_argument('-c', '--configuration', required=True, | 32 parser.add_argument('-c', '--configuration', required=True, |
32 help='The build configuration to use.') | 33 help='The build configuration to use.') |
33 parser.add_argument('-i', '--isolated_outdir', required=True, | 34 parser.add_argument('-i', '--isolated_outdir', required=True, |
34 help='Swarming will automatically upload to ' | 35 help='Swarming will automatically upload to ' |
35 'isolateserver all artifacts in this dir.') | 36 'isolateserver all artifacts in this dir.') |
36 args = parser.parse_args() | 37 args = parser.parse_args() |
37 | 38 |
| 39 # Unzip SKPs into a directory. |
| 40 skps_zip = os.path.join(REPOS_BASE_DIR, 'skps', |
| 41 'slave%d.zip' % args.slave_num) |
| 42 skps_dir = os.path.join(REPOS_BASE_DIR, 'skps', 'slave%d' % args.slave_num) |
| 43 os.makedirs(skps_dir) |
| 44 with zipfile.ZipFile(skps_zip, 'r') as zip_ref: |
| 45 zip_ref.extractall(skps_dir) |
| 46 |
38 tool_path = os.path.join(SKIA_SRC_DIR, 'out', args.configuration, args.tool) | 47 tool_path = os.path.join(SKIA_SRC_DIR, 'out', args.configuration, args.tool) |
39 skps_dir = os.path.join(REPOS_BASE_DIR, 'skps', 'slave%d' % args.slave_num) | |
40 resource_path = os.path.join(SKIA_SRC_DIR, 'resources') | 48 resource_path = os.path.join(SKIA_SRC_DIR, 'resources') |
41 | 49 |
42 cmd = [tool_path] | 50 cmd = [tool_path] |
43 if args.tool == 'dm': | 51 if args.tool == 'dm': |
44 # Add DM specific arguments. | 52 # Add DM specific arguments. |
45 cmd.extend([ | 53 cmd.extend([ |
46 '--src', 'skp', | 54 '--src', 'skp', |
47 '--skps', skps_dir, | 55 '--skps', skps_dir, |
48 '--resourcePath', resource_path, | 56 '--resourcePath', resource_path, |
49 '--config', '8888', | 57 '--config', '8888', |
(...skipping 14 matching lines...) Expand all Loading... |
64 '--key', 'arch', 'x86_64', 'compiler', 'GCC', 'cpu_or_gpu', 'CPU', | 72 '--key', 'arch', 'x86_64', 'compiler', 'GCC', 'cpu_or_gpu', 'CPU', |
65 'cpu_or_gpu_value', 'AVX2', 'model', 'SWARM', 'os', 'Ubuntu', | 73 'cpu_or_gpu_value', 'AVX2', 'model', 'SWARM', 'os', 'Ubuntu', |
66 '--verbose', | 74 '--verbose', |
67 ]) | 75 ]) |
68 | 76 |
69 return subprocess.call(cmd) | 77 return subprocess.call(cmd) |
70 | 78 |
71 | 79 |
72 if __name__ == '__main__': | 80 if __name__ == '__main__': |
73 sys.exit(main()) | 81 sys.exit(main()) |
OLD | NEW |