Revert "Add sbox tests related to warming up of locales."
[chromium-blink-merge.git] / build / android / pylib / remote / device / remote_device_gtest_run.py
blob6a98fc9bf3de82359a45cff19390f3d4dba34316
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
3 # found in the LICENSE file.
5 """Run specific test on specific environment."""
7 import logging
8 import os
9 import tempfile
11 from pylib import constants
12 from pylib.base import base_test_result
13 from pylib.remote.device import remote_device_test_run
16 _EXTRA_COMMAND_LINE_FILE = (
17 'org.chromium.native_test.NativeTestActivity.CommandLineFile')
20 class RemoteDeviceGtestTestRun(remote_device_test_run.RemoteDeviceTestRun):
21 """Run gtests and uirobot tests on a remote device."""
23 DEFAULT_RUNNER_PACKAGE = (
24 'org.chromium.native_test.NativeTestInstrumentationTestRunner')
26 #override
27 def TestPackage(self):
28 return self._test_instance.suite
30 #override
31 def _TriggerSetUp(self):
32 """Set up the triggering of a test run."""
33 logging.info('Triggering test run.')
35 if self._env.runner_type:
36 logging.warning('Ignoring configured runner_type "%s"',
37 self._env.runner_type)
39 if not self._env.runner_package:
40 runner_package = self.DEFAULT_RUNNER_PACKAGE
41 logging.info('Using default runner package: %s',
42 self.DEFAULT_RUNNER_PACKAGE)
43 else:
44 runner_package = self._env.runner_package
46 dummy_app_path = os.path.join(
47 constants.GetOutDirectory(), 'apks', 'remote_device_dummy.apk')
49 # pylint: disable=protected-access
50 with tempfile.NamedTemporaryFile(suffix='.flags.txt') as flag_file:
51 env_vars = {}
52 filter_string = self._test_instance._GenerateDisabledFilterString(None)
53 if filter_string:
54 flag_file.write('_ --gtest_filter=%s' % filter_string)
55 flag_file.flush()
56 env_vars[_EXTRA_COMMAND_LINE_FILE] = os.path.basename(flag_file.name)
57 self._test_instance._data_deps.append(
58 (os.path.abspath(flag_file.name), None))
59 self._AmInstrumentTestSetup(
60 dummy_app_path, self._test_instance.apk, runner_package,
61 environment_variables=env_vars)
63 _INSTRUMENTATION_STREAM_LEADER = 'INSTRUMENTATION_STATUS: stream='
65 #override
66 def _ParseTestResults(self):
67 logging.info('Parsing results from stdout.')
68 results = base_test_result.TestRunResults()
69 output = self._results['results']['output'].splitlines()
70 output = (l[len(self._INSTRUMENTATION_STREAM_LEADER):] for l in output
71 if l.startswith(self._INSTRUMENTATION_STREAM_LEADER))
72 results_list = self._test_instance.ParseGTestOutput(output)
73 results.AddResults(results_list)
74 if self._env.only_output_failures:
75 logging.info('See logcat for more results information.')
77 self._DetectPlatformErrors(results)
78 return results