Skip to content

Commit

Permalink
Android: allow a --single-step for test_runner.py perf.
Browse files Browse the repository at this point in the history
This is the src/ part of trying to make android up and downstream run more or
less the same stack for perf tests.
Instead of requiring all steps listed (which allows sharding), this instead
allows running a single step, with retries and other niceties such as adb
restarting, device fail over, etc..

BUG=

Review URL: https://codereview.chromium.org/66373004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234493 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
bulach@chromium.org committed Nov 12, 2013
1 parent e1cdaad commit def4bce
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
9 changes: 7 additions & 2 deletions build/android/pylib/perf/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ def Setup(test_options):
# Before running the tests, kill any leftover server.
_KillPendingServers()

with file(test_options.steps, 'r') as f:
tests = json.load(f)
if test_options.single_step:
# Running a single command, build the tests structure.
tests = [['single_step', test_options.single_step]]

if test_options.steps:
with file(test_options.steps, 'r') as f:
tests = json.load(f)

# The list is necessary to keep the steps order, but internally
# the format is squashed from a list of lists into a single dict:
Expand Down
1 change: 1 addition & 0 deletions build/android/pylib/perf/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
'no_timeout',
'test_filter',
'dry_run',
'single_step',
])
5 changes: 4 additions & 1 deletion build/android/pylib/perf/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,12 @@ def _LaunchPerfTest(self, test_name):
if self._options.dry_run:
full_cmd = 'echo %s' % cmd

logfile = sys.stdout
if self._options.single_step:
logfile = None
output, exit_code = pexpect.run(
full_cmd, cwd=os.path.abspath(constants.DIR_SOURCE_ROOT),
withexitstatus=True, logfile=sys.stdout, timeout=timeout,
withexitstatus=True, logfile=logfile, timeout=timeout,
env=os.environ)
end_time = datetime.datetime.now()
if exit_code is None:
Expand Down
25 changes: 20 additions & 5 deletions build/android/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,18 @@ def AddPerfTestOptions(option_parser):

option_parser.usage = '%prog perf [options]'
option_parser.commands_dict = {}
option_parser.example = ('%prog perf --steps perf_steps.json')
option_parser.example = ('%prog perf '
'[--single-step command] or '
'[--steps perf_steps.json] or '
'[--print-step step]')

option_parser.add_option(
'--single-step',
help='Execute the given command with retries, but only print the result '
'for the "most successful" round.')
option_parser.add_option(
'--steps',
help='JSON file containing the list of perf steps to run.')
help='JSON file containing the list of commands to run.')
option_parser.add_option(
'--flaky-steps',
help=('A JSON file containing steps that are flaky '
Expand Down Expand Up @@ -472,11 +479,15 @@ def ProcessPerfTestOptions(options, error_func):
A PerfOptions named tuple which contains all options relevant to
perf tests.
"""
if not options.steps and not options.print_step:
error_func('Please specify --steps or --print-step')
# Only one of steps, print_step or single_step must be provided.
count = len(filter(None,
[options.steps, options.print_step, options.single_step]))
if count != 1:
error_func('Please specify one of: --steps, --print-step, --single-step.')
return perf_test_options.PerfOptions(
options.steps, options.flaky_steps, options.print_step,
options.no_timeout, options.test_filter, options.dry_run)
options.no_timeout, options.test_filter, options.dry_run,
options.single_step)


def _RunGTests(options, error_func, devices):
Expand Down Expand Up @@ -634,6 +645,10 @@ def _RunPerfTests(options, error_func, devices):
results=results,
test_type='Perf',
test_package='Perf')

if perf_options.single_step:
return perf_test_runner.PrintTestOutput('single_step')

# Always return 0 on the sharding stage. Individual tests exit_code
# will be returned on the print_step stage.
return 0
Expand Down

0 comments on commit def4bce

Please sign in to comment.