aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/bots/ct/run_ct_skps.py
blob: 9912abd8a05fccff45b7be03e69f3c031ea6b352 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python
# Copyright (c) 2015 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.

"""This script is meant to be run on a Swarming bot."""

import argparse
import os
import subprocess
import sys


PARENT_DIR = os.path.dirname(os.path.realpath(__file__))

REPOS_BASE_DIR = os.path.normpath(os.path.join(
    PARENT_DIR, os.pardir, os.pardir, os.pardir, os.pardir))

SKIA_SRC_DIR = os.path.join(REPOS_BASE_DIR, 'skia')


def main():
  parser = argparse.ArgumentParser()
  parser.add_argument('-s', '--slave_num', required=True, type=int,
                      help='The slave num of this CT run.')
  parser.add_argument('-t', '--tool', required=True,
                      choices=['dm', 'nanobench', 'get_images_from_skps'],
                      help='The tool to run on the SKPs.')
  parser.add_argument('-g', '--git_hash', required=True,
                      help='The Skia hash the tool was built at.')
  parser.add_argument('-c', '--configuration', required=True,
                      help='The build configuration to use.')
  parser.add_argument('-i', '--isolated_outdir', required=True,
                      help='Swarming will automatically upload to '
                           'isolateserver all artifacts in this dir.')
  parser.add_argument('-b', '--builder', required=True,
                      help='The name of the builder.')
  parser.add_argument('-r', '--chromium_build', required=True,
                      help='The chromium build used to create the SKP repo.')
  parser.add_argument('-p', '--page_type', required=True,
                      help='The CT page type.')
  parser.add_argument('-n', '--num_slaves', required=True,
                      help='Total number of slaves used to run the build.')
  args = parser.parse_args()

  tool_path = os.path.join(PARENT_DIR, args.tool)
  skps_dir = os.path.join(
      REPOS_BASE_DIR, 'skps', args.chromium_build, args.page_type,
      args.num_slaves, 'slave%d' % args.slave_num)
  resource_path = os.path.join(SKIA_SRC_DIR, 'resources')

  cmd = [tool_path]
  if args.tool == 'dm':
    # Add DM specific arguments.
    cmd.extend([
      '--src', 'skp',
      '--skps', skps_dir,
      '--resourcePath', resource_path,
      '--config', '8888',
      '--verbose',
    ])
  elif args.tool == 'nanobench':
    # Add Nanobench specific arguments.
    config = '8888'
    cpu_or_gpu = 'CPU'
    cpu_or_gpu_value = 'AVX2'
    if 'GPU' in args.builder:
      config = 'gpu'
      cpu_or_gpu = 'GPU'
      cpu_or_gpu_value = 'GT610'

    out_results_file = os.path.join(
        args.isolated_outdir, 'nanobench_%s_%s_slave%d.json' % (
            args.git_hash, config, args.slave_num))
    cmd.extend([
      '--skps', skps_dir,
      '--match', 'skp',
      '--resourcePath', resource_path,
      '--config', config,
      '--outResultsFile', out_results_file,
      '--properties', 'gitHash', args.git_hash,
      '--key', 'arch', 'x86_64',
               'compiler', 'GCC',
               'cpu_or_gpu', cpu_or_gpu,
               'cpu_or_gpu_value', cpu_or_gpu_value,
               'model', 'SWARM',
               'os', 'Ubuntu',
      '--verbose',
    ])
  elif args.tool == 'get_images_from_skps':
    # Add get_images_from_skps specific arguments.
    img_out = os.path.join(args.isolated_outdir, 'img_out')
    os.makedirs(img_out)
    failures_json_out = os.path.join(args.isolated_outdir, 'failures.json')
    cmd.extend([
      '--out', img_out,
      '--skps', skps_dir,
      '--failuresJsonPath', failures_json_out,
      '--writeImages', 'false',
      '--testDecode',
    ])

  return subprocess.call(cmd)


if __name__ == '__main__':
  sys.exit(main())