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

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

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 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 (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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 super(TestRunner, self).SetUp() 93 super(TestRunner, self).SetUp()
94 if not self.device.HasRoot(): 94 if not self.device.HasRoot():
95 logging.warning('Unable to enable java asserts for %s, non rooted device', 95 logging.warning('Unable to enable java asserts for %s, non rooted device',
96 str(self.device)) 96 str(self.device))
97 else: 97 else:
98 if self.device.SetJavaAsserts(self.options.set_asserts): 98 if self.device.SetJavaAsserts(self.options.set_asserts):
99 # TODO(jbudorick) How to best do shell restart after the 99 # TODO(jbudorick) How to best do shell restart after the
100 # android_commands refactor? 100 # android_commands refactor?
101 self.device.RunShellCommand('stop') 101 self.device.RunShellCommand('stop')
102 self.device.RunShellCommand('start') 102 self.device.RunShellCommand('start')
103 self.device.WaitUntilFullyBooted()
103 104
104 # We give different default value to launch HTTP server based on shard index 105 # We give different default value to launch HTTP server based on shard index
105 # because it may have race condition when multiple processes are trying to 106 # because it may have race condition when multiple processes are trying to
106 # launch lighttpd with same port at same time. 107 # launch lighttpd with same port at same time.
107 self.LaunchTestHttpServer( 108 self.LaunchTestHttpServer(
108 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) 109 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port)
109 if self.flags: 110 if self.flags:
110 self.flags.AddFlags(['--disable-fre', '--enable-test-intents']) 111 self.flags.AddFlags(['--disable-fre', '--enable-test-intents'])
111 if self.options.device_flags: 112 if self.options.device_flags:
112 with open(self.options.device_flags) as device_flags_file: 113 with open(self.options.device_flags) as device_flags_file:
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 results = base_test_result.TestRunResults() 336 results = base_test_result.TestRunResults()
336 timeout = (self._GetIndividualTestTimeoutSecs(test) * 337 timeout = (self._GetIndividualTestTimeoutSecs(test) *
337 self._GetIndividualTestTimeoutScale(test) * 338 self._GetIndividualTestTimeoutScale(test) *
338 self.tool.GetTimeoutScale()) 339 self.tool.GetTimeoutScale())
339 340
340 start_ms = 0 341 start_ms = 0
341 duration_ms = 0 342 duration_ms = 0
342 try: 343 try:
343 self.TestSetup(test) 344 self.TestSetup(test)
344 345
346 try:
347 self.device.GoHome()
348 except device_errors.CommandTimeoutError:
349 logging.exception('Failed to focus the launcher.')
350
345 time_ms = lambda: int(time.time() * 1000) 351 time_ms = lambda: int(time.time() * 1000)
346 start_ms = time_ms() 352 start_ms = time_ms()
347 raw_output = self._RunTest(test, timeout) 353 raw_output = self._RunTest(test, timeout)
348 duration_ms = time_ms() - start_ms 354 duration_ms = time_ms() - start_ms
349 355
350 # Parse the test output 356 # Parse the test output
351 result_code, result_bundle, statuses = ( 357 result_code, result_bundle, statuses = (
352 instrumentation_test_instance.ParseAmInstrumentRawOutput(raw_output)) 358 instrumentation_test_instance.ParseAmInstrumentRawOutput(raw_output))
353 result = self._GenerateTestResult( 359 result = self._GenerateTestResult(
354 test, result_code, result_bundle, statuses, start_ms, duration_ms) 360 test, result_code, result_bundle, statuses, start_ms, duration_ms)
355 if local_device_instrumentation_test_run.DidPackageCrashOnDevice( 361 if local_device_instrumentation_test_run.DidPackageCrashOnDevice(
356 self.test_pkg.GetPackageName(), self.device): 362 self.test_pkg.GetPackageName(), self.device):
357 result.SetType(base_test_result.ResultType.CRASH) 363 result.SetType(base_test_result.ResultType.CRASH)
358 results.AddResult(result) 364 results.AddResult(result)
359 except device_errors.CommandTimeoutError as e: 365 except device_errors.CommandTimeoutError as e:
360 results.AddResult(test_result.InstrumentationTestResult( 366 results.AddResult(test_result.InstrumentationTestResult(
361 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, 367 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms,
362 log=str(e) or 'No information')) 368 log=str(e) or 'No information'))
363 except device_errors.DeviceUnreachableError as e: 369 except device_errors.DeviceUnreachableError as e:
364 results.AddResult(test_result.InstrumentationTestResult( 370 results.AddResult(test_result.InstrumentationTestResult(
365 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, 371 test, base_test_result.ResultType.CRASH, start_ms, duration_ms,
366 log=str(e) or 'No information')) 372 log=str(e) or 'No information'))
367 self.TestTeardown(test, results) 373 self.TestTeardown(test, results)
368 return (results, None if results.DidRunPass() else test) 374 return (results, None if results.DidRunPass() else test)
OLDNEW
« no previous file with comments | « build/android/pylib/instrumentation/test_options.py ('k') | build/android/pylib/local/device/local_device_environment.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698