| 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 import tempfile | 10 import tempfile |
| 11 | 11 |
| 12 from pylib import constants | 12 from pylib import constants |
| 13 from pylib.base import base_test_result | 13 from pylib.base import base_test_result |
| 14 from pylib.remote.device import appurify_sanitized | 14 from pylib.remote.device import appurify_sanitized |
| 15 from pylib.remote.device import remote_device_test_run | 15 from pylib.remote.device import remote_device_test_run |
| 16 from pylib.remote.device import remote_device_helper | 16 from pylib.remote.device import remote_device_helper |
| 17 | 17 |
| 18 | 18 |
| 19 _EXTRA_COMMAND_LINE_FILE = ( | 19 _EXTRA_COMMAND_LINE_FILE = ( |
| 20 'org.chromium.native_test.ChromeNativeTestActivity.CommandLineFile') | 20 'org.chromium.native_test.NativeTestActivity.CommandLineFile') |
| 21 # TODO(jbudorick): Remove this extra when b/18981674 is fixed. | |
| 22 _EXTRA_ONLY_OUTPUT_FAILURES = ( | |
| 23 'org.chromium.native_test.ChromeNativeTestInstrumentationTestRunner.' | |
| 24 'OnlyOutputFailures') | |
| 25 | 21 |
| 26 | 22 |
| 27 class RemoteDeviceGtestTestRun(remote_device_test_run.RemoteDeviceTestRun): | 23 class RemoteDeviceGtestTestRun(remote_device_test_run.RemoteDeviceTestRun): |
| 28 """Run gtests and uirobot tests on a remote device.""" | 24 """Run gtests and uirobot tests on a remote device.""" |
| 29 | 25 |
| 30 DEFAULT_RUNNER_PACKAGE = ( | 26 DEFAULT_RUNNER_PACKAGE = ( |
| 31 'org.chromium.native_test.ChromeNativeTestInstrumentationTestRunner') | 27 'org.chromium.native_test.NativeTestInstrumentationTestRunner') |
| 32 | 28 |
| 33 #override | 29 #override |
| 34 def TestPackage(self): | 30 def TestPackage(self): |
| 35 return self._test_instance.suite | 31 return self._test_instance.suite |
| 36 | 32 |
| 37 #override | 33 #override |
| 38 def _TriggerSetUp(self): | 34 def _TriggerSetUp(self): |
| 39 """Set up the triggering of a test run.""" | 35 """Set up the triggering of a test run.""" |
| 40 logging.info('Triggering test run.') | 36 logging.info('Triggering test run.') |
| 41 | 37 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 54 constants.GetOutDirectory(), 'apks', 'remote_device_dummy.apk') | 50 constants.GetOutDirectory(), 'apks', 'remote_device_dummy.apk') |
| 55 with tempfile.NamedTemporaryFile(suffix='.flags.txt') as flag_file: | 51 with tempfile.NamedTemporaryFile(suffix='.flags.txt') as flag_file: |
| 56 env_vars = {} | 52 env_vars = {} |
| 57 filter_string = self._test_instance._GenerateDisabledFilterString(None) | 53 filter_string = self._test_instance._GenerateDisabledFilterString(None) |
| 58 if filter_string: | 54 if filter_string: |
| 59 flag_file.write('_ --gtest_filter=%s' % filter_string) | 55 flag_file.write('_ --gtest_filter=%s' % filter_string) |
| 60 flag_file.flush() | 56 flag_file.flush() |
| 61 env_vars[_EXTRA_COMMAND_LINE_FILE] = os.path.basename(flag_file.name) | 57 env_vars[_EXTRA_COMMAND_LINE_FILE] = os.path.basename(flag_file.name) |
| 62 self._test_instance._data_deps.append( | 58 self._test_instance._data_deps.append( |
| 63 (os.path.abspath(flag_file.name), None)) | 59 (os.path.abspath(flag_file.name), None)) |
| 64 if self._env.only_output_failures: | |
| 65 env_vars[_EXTRA_ONLY_OUTPUT_FAILURES] = None | |
| 66 self._AmInstrumentTestSetup( | 60 self._AmInstrumentTestSetup( |
| 67 dummy_app_path, self._test_instance.apk, runner_package, | 61 dummy_app_path, self._test_instance.apk, runner_package, |
| 68 environment_variables=env_vars) | 62 environment_variables=env_vars) |
| 69 | 63 |
| 70 _INSTRUMENTATION_STREAM_LEADER = 'INSTRUMENTATION_STATUS: stream=' | 64 _INSTRUMENTATION_STREAM_LEADER = 'INSTRUMENTATION_STATUS: stream=' |
| 71 | 65 |
| 72 #override | 66 #override |
| 73 def _ParseTestResults(self): | 67 def _ParseTestResults(self): |
| 74 logging.info('Parsing results from stdout.') | 68 logging.info('Parsing results from stdout.') |
| 75 results = base_test_result.TestRunResults() | 69 results = base_test_result.TestRunResults() |
| 76 output = self._results['results']['output'].splitlines() | 70 output = self._GetRawTestOutput().splitlines() |
| 77 output = (l[len(self._INSTRUMENTATION_STREAM_LEADER):] for l in output | 71 output = (l[len(self._INSTRUMENTATION_STREAM_LEADER):] for l in output |
| 78 if l.startswith(self._INSTRUMENTATION_STREAM_LEADER)) | 72 if l.startswith(self._INSTRUMENTATION_STREAM_LEADER)) |
| 79 results_list = self._test_instance.ParseGTestOutput(output) | 73 results_list = self._test_instance.ParseGTestOutput(output) |
| 80 results.AddResults(results_list) | 74 results.AddResults(results_list) |
| 81 if self._env.only_output_failures: | |
| 82 logging.info('See logcat for more results information.') | |
| 83 if not self._results['results']['pass']: | 75 if not self._results['results']['pass']: |
| 84 results.AddResult(base_test_result.BaseTestResult( | 76 results.AddResult(base_test_result.BaseTestResult( |
| 85 'Remote Service detected error.', | 77 'Remote Service detected error.', |
| 86 base_test_result.ResultType.FAIL)) | 78 base_test_result.ResultType.FAIL)) |
| 87 return results | 79 return results |
| OLD | NEW |