• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2012 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
5"""Parses options for the instrumentation tests."""
6
7import os
8
9
10# TODO(gkanwar): Some downstream scripts current rely on these functions
11# existing. This dependency should be removed, and this file deleted, in the
12# future.
13def AddBuildTypeOption(option_parser):
14  """Decorates OptionParser with build type option."""
15  default_build_type = 'Debug'
16  if 'BUILDTYPE' in os.environ:
17    default_build_type = os.environ['BUILDTYPE']
18  option_parser.add_option('--debug', action='store_const', const='Debug',
19                           dest='build_type', default=default_build_type,
20                           help='If set, run test suites under out/Debug. '
21                           'Default is env var BUILDTYPE or Debug')
22  option_parser.add_option('--release', action='store_const', const='Release',
23                           dest='build_type',
24                           help='If set, run test suites under out/Release. '
25                           'Default is env var BUILDTYPE or Debug.')
26
27
28def AddTestRunnerOptions(option_parser, default_timeout=60):
29  """Decorates OptionParser with options applicable to all tests."""
30
31  option_parser.add_option('-t', dest='timeout',
32                           help='Timeout to wait for each test',
33                           type='int',
34                           default=default_timeout)
35  option_parser.add_option('-c', dest='cleanup_test_files',
36                           help='Cleanup test files on the device after run',
37                           action='store_true')
38  option_parser.add_option('--num_retries', dest='num_retries', type='int',
39                           default=2,
40                           help='Number of retries for a test before '
41                           'giving up.')
42  option_parser.add_option('-v',
43                           '--verbose',
44                           dest='verbose_count',
45                           default=0,
46                           action='count',
47                           help='Verbose level (multiple times for more)')
48  profilers = ['devicestatsmonitor', 'chrometrace', 'dumpheap', 'smaps',
49               'traceview']
50  option_parser.add_option('--profiler', dest='profilers', action='append',
51                           choices=profilers,
52                           help='Profiling tool to run during test. '
53                           'Pass multiple times to run multiple profilers. '
54                           'Available profilers: %s' % profilers)
55  option_parser.add_option('--tool',
56                           dest='tool',
57                           help='Run the test under a tool '
58                           '(use --tool help to list them)')
59  option_parser.add_option('--flakiness-dashboard-server',
60                           dest='flakiness_dashboard_server',
61                           help=('Address of the server that is hosting the '
62                                 'Chrome for Android flakiness dashboard.'))
63  option_parser.add_option('--skip-deps-push', dest='push_deps',
64                           action='store_false', default=True,
65                           help='Do not push dependencies to the device. '
66                           'Use this at own risk for speeding up test '
67                           'execution on local machine.')
68  AddBuildTypeOption(option_parser)
69