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