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

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

Issue 952893003: Update from https://crrev.com/317530 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix gn for nacl 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_statuses, start_ms, duration_ms): 323 def _GenerateTestResult(self, test, instr_result_code, instr_result_bundle,
324 return instrumentation_test_instance.GenerateTestResult( 324 statuses, start_ms, duration_ms):
325 test, instr_statuses, start_ms, duration_ms) 325 results = instrumentation_test_instance.GenerateTestResults(
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)
326 333
327 #override 334 #override
328 def RunTest(self, test): 335 def RunTest(self, test):
329 results = base_test_result.TestRunResults() 336 results = base_test_result.TestRunResults()
330 timeout = (self._GetIndividualTestTimeoutSecs(test) * 337 timeout = (self._GetIndividualTestTimeoutSecs(test) *
331 self._GetIndividualTestTimeoutScale(test) * 338 self._GetIndividualTestTimeoutScale(test) *
332 self.tool.GetTimeoutScale()) 339 self.tool.GetTimeoutScale())
333 if (self.device.build_version_sdk 340 if (self.device.build_version_sdk
334 < constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN): 341 < constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN):
335 timeout *= 10 342 timeout *= 10
336 343
337 start_ms = 0 344 start_ms = 0
338 duration_ms = 0 345 duration_ms = 0
339 try: 346 try:
340 self.TestSetup(test) 347 self.TestSetup(test)
341 348
342 time_ms = lambda: int(time.time() * 1000) 349 time_ms = lambda: int(time.time() * 1000)
343 start_ms = time_ms() 350 start_ms = time_ms()
344 raw_output = self._RunTest(test, timeout) 351 raw_output = self._RunTest(test, timeout)
345 duration_ms = time_ms() - start_ms 352 duration_ms = time_ms() - start_ms
346 353
347 # Parse the test output 354 # Parse the test output
348 _, _, statuses = ( 355 result_code, result_bundle, statuses = (
349 instrumentation_test_instance.ParseAmInstrumentRawOutput(raw_output)) 356 instrumentation_test_instance.ParseAmInstrumentRawOutput(raw_output))
350 result = self._GenerateTestResult(test, statuses, start_ms, duration_ms) 357 result = self._GenerateTestResult(
358 test, result_code, result_bundle, statuses, start_ms, duration_ms)
351 if local_device_instrumentation_test_run.DidPackageCrashOnDevice( 359 if local_device_instrumentation_test_run.DidPackageCrashOnDevice(
352 self.test_pkg.GetPackageName(), self.device): 360 self.test_pkg.GetPackageName(), self.device):
353 result.SetType(base_test_result.ResultType.CRASH) 361 result.SetType(base_test_result.ResultType.CRASH)
354 results.AddResult(result) 362 results.AddResult(result)
355 except device_errors.CommandTimeoutError as e: 363 except device_errors.CommandTimeoutError as e:
356 results.AddResult(test_result.InstrumentationTestResult( 364 results.AddResult(test_result.InstrumentationTestResult(
357 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, 365 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms,
358 log=str(e) or 'No information')) 366 log=str(e) or 'No information'))
359 except device_errors.DeviceUnreachableError as e: 367 except device_errors.DeviceUnreachableError as e:
360 results.AddResult(test_result.InstrumentationTestResult( 368 results.AddResult(test_result.InstrumentationTestResult(
361 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, 369 test, base_test_result.ResultType.CRASH, start_ms, duration_ms,
362 log=str(e) or 'No information')) 370 log=str(e) or 'No information'))
363 self.TestTeardown(test, results) 371 self.TestTeardown(test, results)
364 return (results, None if results.DidRunPass() else test) 372 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