OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Run specific test on specific environment.""" | 5 """Run specific test on specific environment.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 | 10 |
11 from pylib import constants | 11 from pylib import constants |
12 from pylib.base import base_test_result | 12 from pylib.base import base_test_result |
| 13 from pylib.remote.device import appurify_sanitized |
13 from pylib.remote.device import remote_device_test_run | 14 from pylib.remote.device import remote_device_test_run |
14 from pylib.remote.device import remote_device_helper | 15 from pylib.remote.device import remote_device_helper |
15 | 16 |
16 sys.path.append(os.path.join( | |
17 constants.DIR_SOURCE_ROOT, 'third_party', 'requests', 'src')) | |
18 sys.path.append(os.path.join( | |
19 constants.DIR_SOURCE_ROOT, 'third_party', 'appurify-python', 'src')) | |
20 import appurify.api | |
21 import appurify.utils | |
22 | 17 |
23 class RemoteDeviceGtestRun(remote_device_test_run.RemoteDeviceTestRun): | 18 class RemoteDeviceGtestRun(remote_device_test_run.RemoteDeviceTestRun): |
24 """Run gtests and uirobot tests on a remote device.""" | 19 """Run gtests and uirobot tests on a remote device.""" |
25 | 20 |
26 DEFAULT_RUNNER_TYPE = 'robotium' | 21 DEFAULT_RUNNER_TYPE = 'robotium' |
27 DEFAULT_RUNNER_PACKAGE = ( | 22 DEFAULT_RUNNER_PACKAGE = ( |
28 'org.chromium.native_test.ChromiumNativeTestInstrumentationTestRunner') | 23 'org.chromium.native_test.ChromiumNativeTestInstrumentationTestRunner') |
29 | 24 |
| 25 #override |
30 def TestPackage(self): | 26 def TestPackage(self): |
31 pass | 27 return self._test_instance.suite |
32 | 28 |
33 #override | 29 #override |
34 def _TriggerSetUp(self): | 30 def _TriggerSetUp(self): |
35 """Set up the triggering of a test run.""" | 31 """Set up the triggering of a test run.""" |
| 32 logging.info('Triggering test run.') |
36 self._app_id = self._UploadAppToDevice(self._test_instance.apk) | 33 self._app_id = self._UploadAppToDevice(self._test_instance.apk) |
37 | 34 |
38 if not self._env.runner_type: | 35 if not self._env.runner_type: |
39 runner_type = self.DEFAULT_RUNNER_TYPE | 36 runner_type = self.DEFAULT_RUNNER_TYPE |
40 logging.info('Using default runner type: %s', self.DEFAULT_RUNNER_TYPE) | 37 logging.info('Using default runner type: %s', self.DEFAULT_RUNNER_TYPE) |
41 else: | 38 else: |
42 runner_type = self._env.runner_type | 39 runner_type = self._env.runner_type |
43 | 40 |
44 if not self._env.runner_package: | 41 if not self._env.runner_package: |
45 runner_package = self.DEFAULT_RUNNER_PACKAGE | 42 runner_package = self.DEFAULT_RUNNER_PACKAGE |
46 logging.info('Using default runner package: %s', | 43 logging.info('Using default runner package: %s', |
47 self.DEFAULT_RUNNER_TYPE) | 44 self.DEFAULT_RUNNER_TYPE) |
48 else: | 45 else: |
49 runner_package = self._env.runner_package | 46 runner_package = self._env.runner_package |
50 | 47 |
51 self._test_id = self._UploadTestToDevice(runner_type) | 48 self._test_id = self._UploadTestToDevice(runner_type) |
52 config_body = {'runner': runner_package} | 49 config_body = {'runner': runner_package} |
53 self._SetTestConfig(runner_type, config_body) | 50 self._SetTestConfig(runner_type, config_body) |
54 | 51 |
| 52 _INSTRUMENTATION_STREAM_LEADER = 'INSTRUMENTATION_STATUS: stream=' |
| 53 |
55 #override | 54 #override |
56 def _ParseTestResults(self): | 55 def _ParseTestResults(self): |
57 # TODO(rnephew): Populate test results object. | 56 logging.info('Parsing results from stdout.') |
| 57 output = self._results['results']['output'].splitlines() |
| 58 output = (l[len(self._INSTRUMENTATION_STREAM_LEADER):] for l in output |
| 59 if l.startswith(self._INSTRUMENTATION_STREAM_LEADER)) |
| 60 results_list = self._test_instance.ParseGTestOutput(output) |
58 results = base_test_result.TestRunResults() | 61 results = base_test_result.TestRunResults() |
| 62 results.AddResults(results_list) |
59 return results | 63 return results |
OLD | NEW |