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

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

Issue 221823011: [Android] Change object types from AndroidCommands to DeviceUtils in build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Frank's comments. Created 6 years, 8 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Runs perf tests. 5 """Runs perf tests.
6 6
7 Our buildbot infrastructure requires each slave to run steps serially. 7 Our buildbot infrastructure requires each slave to run steps serially.
8 This is sub-optimal for android, where these steps can run independently on 8 This is sub-optimal for android, where these steps can run independently on
9 multiple connected devices. 9 multiple connected devices.
10 10
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 """Runs a perf test. 168 """Runs a perf test.
169 169
170 Args: 170 Args:
171 test_name: the name of the test to be executed. 171 test_name: the name of the test to be executed.
172 172
173 Returns: 173 Returns:
174 A tuple containing (Output, base_test_result.ResultType) 174 A tuple containing (Output, base_test_result.ResultType)
175 """ 175 """
176 try: 176 try:
177 logging.warning('Unmapping device ports') 177 logging.warning('Unmapping device ports')
178 forwarder.Forwarder.UnmapAllDevicePorts(self.adb) 178 forwarder.Forwarder.UnmapAllDevicePorts(self.device)
179 self.adb.RestartAdbdOnDevice() 179 self.device.old_interface.RestartAdbdOnDevice()
180 except Exception as e: 180 except Exception as e:
181 logging.error('Exception when tearing down device %s', e) 181 logging.error('Exception when tearing down device %s', e)
182 182
183 cmd = ('%s --device %s' % 183 cmd = ('%s --device %s' %
184 (self._tests[test_name], self.device)) 184 (self._tests[test_name], str(self.device)))
185 logging.info('%s : %s', test_name, cmd) 185 logging.info('%s : %s', test_name, cmd)
186 start_time = datetime.datetime.now() 186 start_time = datetime.datetime.now()
187 187
188 timeout = 5400 188 timeout = 5400
189 if self._options.no_timeout: 189 if self._options.no_timeout:
190 timeout = None 190 timeout = None
191 full_cmd = cmd 191 full_cmd = cmd
192 if self._options.dry_run: 192 if self._options.dry_run:
193 full_cmd = 'echo %s' % cmd 193 full_cmd = 'echo %s' % cmd
194 194
(...skipping 10 matching lines...) Expand all
205 withexitstatus=True, logfile=logfile, timeout=timeout, 205 withexitstatus=True, logfile=logfile, timeout=timeout,
206 env=os.environ) 206 env=os.environ)
207 if self._options.single_step: 207 if self._options.single_step:
208 # Stop the logger. 208 # Stop the logger.
209 logfile.stop() 209 logfile.stop()
210 end_time = datetime.datetime.now() 210 end_time = datetime.datetime.now()
211 if exit_code is None: 211 if exit_code is None:
212 exit_code = -1 212 exit_code = -1
213 logging.info('%s : exit_code=%d in %d secs at %s', 213 logging.info('%s : exit_code=%d in %d secs at %s',
214 test_name, exit_code, (end_time - start_time).seconds, 214 test_name, exit_code, (end_time - start_time).seconds,
215 self.device) 215 str(self.device))
216 result_type = base_test_result.ResultType.FAIL 216 result_type = base_test_result.ResultType.FAIL
217 if exit_code == 0: 217 if exit_code == 0:
218 result_type = base_test_result.ResultType.PASS 218 result_type = base_test_result.ResultType.PASS
219 actual_exit_code = exit_code 219 actual_exit_code = exit_code
220 if test_name in self._flaky_tests: 220 if test_name in self._flaky_tests:
221 # The exit_code is used at the second stage when printing the 221 # The exit_code is used at the second stage when printing the
222 # test output. If the test is flaky, force to "0" to get that step green 222 # test output. If the test is flaky, force to "0" to get that step green
223 # whilst still gathering data to the perf dashboards. 223 # whilst still gathering data to the perf dashboards.
224 # The result_type is used by the test_dispatcher to retry the test. 224 # The result_type is used by the test_dispatcher to retry the test.
225 exit_code = 0 225 exit_code = 0
226 226
227 persisted_result = { 227 persisted_result = {
228 'name': test_name, 228 'name': test_name,
229 'output': output, 229 'output': output,
230 'exit_code': exit_code, 230 'exit_code': exit_code,
231 'actual_exit_code': actual_exit_code, 231 'actual_exit_code': actual_exit_code,
232 'result_type': result_type, 232 'result_type': result_type,
233 'total_time': (end_time - start_time).seconds, 233 'total_time': (end_time - start_time).seconds,
234 'device': self.device, 234 'device': str(self.device),
235 'cmd': cmd, 235 'cmd': cmd,
236 } 236 }
237 self._SaveResult(persisted_result) 237 self._SaveResult(persisted_result)
238 238
239 return (output, result_type) 239 return (output, result_type)
240 240
241 def RunTest(self, test_name): 241 def RunTest(self, test_name):
242 """Run a perf test on the device. 242 """Run a perf test on the device.
243 243
244 Args: 244 Args:
245 test_name: String to use for logging the test result. 245 test_name: String to use for logging the test result.
246 246
247 Returns: 247 Returns:
248 A tuple of (TestRunResults, retry). 248 A tuple of (TestRunResults, retry).
249 """ 249 """
250 _, result_type = self._LaunchPerfTest(test_name) 250 _, result_type = self._LaunchPerfTest(test_name)
251 results = base_test_result.TestRunResults() 251 results = base_test_result.TestRunResults()
252 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) 252 results.AddResult(base_test_result.BaseTestResult(test_name, result_type))
253 retry = None 253 retry = None
254 if not results.DidRunPass(): 254 if not results.DidRunPass():
255 retry = test_name 255 retry = test_name
256 return results, retry 256 return results, retry
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698