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

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

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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 """Class for running instrumentation tests on a single device.""" 5 """Class for running instrumentation tests on a single device."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import re 9 import re
10 import sys 10 import sys
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 313
314 Returns: 314 Returns:
315 The raw output of am instrument as a list of lines. 315 The raw output of am instrument as a list of lines.
316 """ 316 """
317 extras = self._GetInstrumentationArgs() 317 extras = self._GetInstrumentationArgs()
318 extras['class'] = test 318 extras['class'] = test
319 return self.device.StartInstrumentation( 319 return self.device.StartInstrumentation(
320 '%s/%s' % (self.test_pkg.GetPackageName(), self.options.test_runner), 320 '%s/%s' % (self.test_pkg.GetPackageName(), self.options.test_runner),
321 raw=True, extras=extras, timeout=timeout, retries=3) 321 raw=True, extras=extras, timeout=timeout, retries=3)
322 322
323 def _GenerateTestResult(self, test, instr_result_code, instr_result_bundle, 323 def _GenerateTestResult(self, test, instr_statuses, start_ms, duration_ms):
324 statuses, start_ms, duration_ms): 324 return instrumentation_test_instance.GenerateTestResult(
325 results = instrumentation_test_instance.GenerateTestResults( 325 test, instr_statuses, start_ms, duration_ms)
326 instr_result_code, instr_result_bundle, statuses, start_ms, duration_ms)
327 for r in results:
328 if r.GetName() == test:
329 return r
330 logging.error('Could not find result for test: %s', test)
331 return test_result.InstrumentationTestResult(
332 test, base_test_result.ResultType.UNKNOWN, start_ms, duration_ms)
333 326
334 #override 327 #override
335 def RunTest(self, test): 328 def RunTest(self, test):
336 results = base_test_result.TestRunResults() 329 results = base_test_result.TestRunResults()
337 timeout = (self._GetIndividualTestTimeoutSecs(test) * 330 timeout = (self._GetIndividualTestTimeoutSecs(test) *
338 self._GetIndividualTestTimeoutScale(test) * 331 self._GetIndividualTestTimeoutScale(test) *
339 self.tool.GetTimeoutScale()) 332 self.tool.GetTimeoutScale())
340 if (self.device.build_version_sdk 333 if (self.device.build_version_sdk
341 < constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN): 334 < constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN):
342 timeout *= 10 335 timeout *= 10
343 336
344 start_ms = 0 337 start_ms = 0
345 duration_ms = 0 338 duration_ms = 0
346 try: 339 try:
347 self.TestSetup(test) 340 self.TestSetup(test)
348 341
349 time_ms = lambda: int(time.time() * 1000) 342 time_ms = lambda: int(time.time() * 1000)
350 start_ms = time_ms() 343 start_ms = time_ms()
351 raw_output = self._RunTest(test, timeout) 344 raw_output = self._RunTest(test, timeout)
352 duration_ms = time_ms() - start_ms 345 duration_ms = time_ms() - start_ms
353 346
354 # Parse the test output 347 # Parse the test output
355 result_code, result_bundle, statuses = ( 348 _, _, statuses = (
356 instrumentation_test_instance.ParseAmInstrumentRawOutput(raw_output)) 349 instrumentation_test_instance.ParseAmInstrumentRawOutput(raw_output))
357 result = self._GenerateTestResult( 350 result = self._GenerateTestResult(test, statuses, start_ms, duration_ms)
358 test, result_code, result_bundle, statuses, start_ms, duration_ms)
359 if local_device_instrumentation_test_run.DidPackageCrashOnDevice( 351 if local_device_instrumentation_test_run.DidPackageCrashOnDevice(
360 self.test_pkg.GetPackageName(), self.device): 352 self.test_pkg.GetPackageName(), self.device):
361 result.SetType(base_test_result.ResultType.CRASH) 353 result.SetType(base_test_result.ResultType.CRASH)
362 results.AddResult(result) 354 results.AddResult(result)
363 except device_errors.CommandTimeoutError as e: 355 except device_errors.CommandTimeoutError as e:
364 results.AddResult(test_result.InstrumentationTestResult( 356 results.AddResult(test_result.InstrumentationTestResult(
365 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, 357 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms,
366 log=str(e) or 'No information')) 358 log=str(e) or 'No information'))
367 except device_errors.DeviceUnreachableError as e: 359 except device_errors.DeviceUnreachableError as e:
368 results.AddResult(test_result.InstrumentationTestResult( 360 results.AddResult(test_result.InstrumentationTestResult(
369 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, 361 test, base_test_result.ResultType.CRASH, start_ms, duration_ms,
370 log=str(e) or 'No information')) 362 log=str(e) or 'No information'))
371 self.TestTeardown(test, results) 363 self.TestTeardown(test, results)
372 return (results, None if results.DidRunPass() else test) 364 return (results, None if results.DidRunPass() else test)
OLDNEW
« no previous file with comments | « build/android/pylib/instrumentation/instrumentation_test_instance_test.py ('k') | build/android/pylib/linker/test_case.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698