Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: build/android/pylib/remote/device/remote_device_gtest_run.py

Issue 2488453002: [android] Remove pylib/{remote,uirobot}. (Closed)
Patch Set: Remove remote_device_dummy_apk from rules.gni. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 """Run specific test on specific environment."""
6
7 import logging
8 import os
9 import tempfile
10
11 from pylib import constants
12 from pylib.base import base_test_result
13 from pylib.gtest import gtest_test_instance
14 from pylib.remote.device import remote_device_test_run
15
16
17 _EXTRA_COMMAND_LINE_FILE = (
18 'org.chromium.native_test.NativeTest.CommandLineFile')
19
20
21 class RemoteDeviceGtestTestRun(remote_device_test_run.RemoteDeviceTestRun):
22 """Run gtests and uirobot tests on a remote device."""
23
24 DEFAULT_RUNNER_PACKAGE = (
25 'org.chromium.native_test.NativeTestInstrumentationTestRunner')
26
27 #override
28 def TestPackage(self):
29 return self._test_instance.suite
30
31 #override
32 def _TriggerSetUp(self):
33 """Set up the triggering of a test run."""
34 logging.info('Triggering test run.')
35
36 if self._env.runner_type:
37 logging.warning('Ignoring configured runner_type "%s"',
38 self._env.runner_type)
39
40 if not self._env.runner_package:
41 runner_package = self.DEFAULT_RUNNER_PACKAGE
42 logging.info('Using default runner package: %s',
43 self.DEFAULT_RUNNER_PACKAGE)
44 else:
45 runner_package = self._env.runner_package
46
47 dummy_app_path = os.path.join(
48 constants.GetOutDirectory(), 'apks', 'remote_device_dummy.apk')
49
50 # pylint: disable=protected-access
51 with tempfile.NamedTemporaryFile(suffix='.flags.txt') as flag_file:
52 env_vars = dict(self._test_instance.extras)
53 if gtest_test_instance.EXTRA_SHARD_NANO_TIMEOUT not in env_vars:
54 env_vars[gtest_test_instance.EXTRA_SHARD_NANO_TIMEOUT] = int(
55 self._test_instance.shard_timeout * 1e9)
56
57 flags = []
58
59 filter_string = self._test_instance._GenerateDisabledFilterString(None)
60 if filter_string:
61 flags.append('--gtest_filter=%s' % filter_string)
62
63 if self._test_instance.test_arguments:
64 flags.append(self._test_instance.test_arguments)
65
66 if flags:
67 flag_file.write('_ ' + ' '.join(flags))
68 flag_file.flush()
69 env_vars[_EXTRA_COMMAND_LINE_FILE] = os.path.basename(flag_file.name)
70 self._test_instance._data_deps.append(
71 (os.path.abspath(flag_file.name), None))
72 self._AmInstrumentTestSetup(
73 dummy_app_path, self._test_instance.apk, runner_package,
74 environment_variables=env_vars)
75
76 _INSTRUMENTATION_STREAM_LEADER = 'INSTRUMENTATION_STATUS: stream='
77
78 #override
79 def _ParseTestResults(self):
80 logging.info('Parsing results from stdout.')
81 results = base_test_result.TestRunResults()
82 output = self._results['results']['output'].splitlines()
83 output = (l[len(self._INSTRUMENTATION_STREAM_LEADER):] for l in output
84 if l.startswith(self._INSTRUMENTATION_STREAM_LEADER))
85 results_list = gtest_test_instance.ParseGTestOutput(output)
86 results.AddResults(results_list)
87
88 self._DetectPlatformErrors(results)
89 return results
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698