OLD | NEW |
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 a monkey test on a single device.""" | 5 """Runs a monkey test on a single device.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import random | 8 import random |
9 | 9 |
10 from pylib import constants | 10 from pylib import constants |
11 from pylib.base import base_test_result | 11 from pylib.base import base_test_result |
12 from pylib.base import base_test_runner | 12 from pylib.base import base_test_runner |
| 13 from pylib.device import device_errors |
13 from pylib.device import intent | 14 from pylib.device import intent |
14 | 15 |
| 16 _CHROME_PACKAGE = constants.PACKAGE_INFO['chrome'].package |
| 17 |
15 class TestRunner(base_test_runner.BaseTestRunner): | 18 class TestRunner(base_test_runner.BaseTestRunner): |
16 """A TestRunner instance runs a monkey test on a single device.""" | 19 """A TestRunner instance runs a monkey test on a single device.""" |
17 | 20 |
18 def __init__(self, test_options, device, _): | 21 def __init__(self, test_options, device, _): |
19 super(TestRunner, self).__init__(device, None) | 22 super(TestRunner, self).__init__(device, None) |
20 self._options = test_options | 23 self._options = test_options |
21 self._package = constants.PACKAGE_INFO[self._options.package].package | 24 self._package = constants.PACKAGE_INFO[self._options.package].package |
22 self._activity = constants.PACKAGE_INFO[self._options.package].activity | 25 self._activity = constants.PACKAGE_INFO[self._options.package].activity |
23 | 26 |
24 def _LaunchMonkeyTest(self): | 27 def _LaunchMonkeyTest(self): |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 results = base_test_result.TestRunResults() | 83 results = base_test_result.TestRunResults() |
81 success_pattern = 'Events injected: %d' % self._options.event_count | 84 success_pattern = 'Events injected: %d' % self._options.event_count |
82 if success_pattern in output and not crashed: | 85 if success_pattern in output and not crashed: |
83 result = base_test_result.BaseTestResult( | 86 result = base_test_result.BaseTestResult( |
84 test_name, base_test_result.ResultType.PASS, log=output) | 87 test_name, base_test_result.ResultType.PASS, log=output) |
85 else: | 88 else: |
86 result = base_test_result.BaseTestResult( | 89 result = base_test_result.BaseTestResult( |
87 test_name, base_test_result.ResultType.FAIL, log=output) | 90 test_name, base_test_result.ResultType.FAIL, log=output) |
88 if 'chrome' in self._options.package: | 91 if 'chrome' in self._options.package: |
89 logging.warning('Starting MinidumpUploadService...') | 92 logging.warning('Starting MinidumpUploadService...') |
| 93 # TODO(jbudorick): Update this after upstreaming. |
| 94 minidump_intent = intent.Intent( |
| 95 action='%s.crash.ACTION_FIND_ALL' % _CHROME_PACKAGE, |
| 96 package=self._package, |
| 97 activity='%s.crash.MinidumpUploadService' % _CHROME_PACKAGE) |
90 try: | 98 try: |
91 self.device.old_interface.StartCrashUploadService(self._package) | 99 self.device.RunShellCommand( |
92 except AssertionError as e: | 100 ['am', 'startservice'] + minidump_intent.am_args, |
93 logging.error('Failed to start MinidumpUploadService: %s', e) | 101 as_root=True, check_return=True) |
| 102 except device_errors.CommandFailedError: |
| 103 logging.exception('Failed to start MinidumpUploadService') |
| 104 |
94 results.AddResult(result) | 105 results.AddResult(result) |
95 return results, False | 106 return results, False |
OLD | NEW |