Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: build/android/pylib/perf/setup.py

Issue 2198613002: [Android] Get rid of old perf test runner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get rid of test_env Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/android/pylib/perf/test_options.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2013 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 """Generates test runner factory and tests for performance tests."""
6
7 import json
8 import fnmatch
9 import logging
10 import os
11 import shutil
12
13 from devil.android import device_list
14 from devil.android import device_utils
15 from pylib import constants
16 from pylib.perf import test_runner
17 from pylib.utils import test_environment
18
19
20 def _GetAllDevices(active_devices, devices_path):
21 try:
22 if devices_path:
23 devices = [device_utils.DeviceUtils(s)
24 for s in device_list.GetPersistentDeviceList(devices_path)]
25 if not devices and active_devices:
26 logging.warning('%s is empty. Falling back to active devices.',
27 devices_path)
28 devices = active_devices
29 else:
30 logging.warning('Known devices file path not being passed. For device '
31 'affinity to work properly, it must be passed.')
32 devices = active_devices
33 except IOError as e:
34 logging.error('Unable to find %s [%s]', devices_path, e)
35 devices = active_devices
36 return sorted(devices)
37
38
39 def _GetStepsDictFromSingleStep(test_options):
40 # Running a single command, build the tests structure.
41 steps_dict = {
42 'version': 1,
43 'steps': {
44 'single_step': {
45 'device_affinity': 0,
46 'cmd': test_options.single_step
47 },
48 }
49 }
50 return steps_dict
51
52
53 def _GetStepsDict(test_options):
54 if test_options.single_step:
55 return _GetStepsDictFromSingleStep(test_options)
56 if test_options.steps:
57 with file(test_options.steps, 'r') as f:
58 steps = json.load(f)
59
60 # Already using the new format.
61 assert steps['version'] == 1
62 return steps
63
64
65 def Setup(test_options, active_devices):
66 """Create and return the test runner factory and tests.
67
68 Args:
69 test_options: A PerformanceOptions object.
70
71 Returns:
72 A tuple of (TestRunnerFactory, tests, devices).
73 """
74 # TODO(bulach): remove this once the bot side lands. BUG=318369
75 constants.SetBuildType('Release')
76 if os.path.exists(constants.PERF_OUTPUT_DIR):
77 shutil.rmtree(constants.PERF_OUTPUT_DIR)
78 os.makedirs(constants.PERF_OUTPUT_DIR)
79
80 # Before running the tests, kill any leftover server.
81 test_environment.CleanupLeftoverProcesses(active_devices)
82
83 # We want to keep device affinity, so return all devices ever seen.
84 all_devices = _GetAllDevices(active_devices, test_options.known_devices_file)
85
86 steps_dict = _GetStepsDict(test_options)
87 sorted_step_names = sorted(steps_dict['steps'].keys())
88
89 if test_options.test_filter:
90 sorted_step_names = fnmatch.filter(sorted_step_names,
91 test_options.test_filter)
92
93 flaky_steps = []
94 if test_options.flaky_steps:
95 with file(test_options.flaky_steps, 'r') as f:
96 flaky_steps = json.load(f)
97
98 def TestRunnerFactory(device, shard_index):
99 if str(device) in active_devices:
100 return test_runner.TestRunner(
101 test_options, device, shard_index, len(all_devices),
102 steps_dict, flaky_steps)
103 return None
104
105 return (TestRunnerFactory, sorted_step_names, all_devices)
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/perf/test_options.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698