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

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

Issue 832493005: Add Instrumentation test support to remote device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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.
jbudorick 2015/01/21 02:39:34 Leave this one as-is for now. "gtest_test_run" is
rnephew (Wrong account) 2015/01/21 16:13:12 Done.
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 sys
10 import tempfile
11
12 from pylib import constants
13 from pylib.base import base_test_result
14 from pylib.remote.device import appurify_sanitized
15 from pylib.remote.device import remote_device_test_run
16 from pylib.remote.device import remote_device_helper
17
18
19 _EXTRA_COMMAND_LINE_FILE = (
20 'org.chromium.native_test.ChromeNativeTestActivity.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
26
27 class RemoteDeviceGtestRun(remote_device_test_run.RemoteDeviceTestRun):
28 """Run gtests and uirobot tests on a remote device."""
29
30 DEFAULT_RUNNER_PACKAGE = (
31 'org.chromium.native_test.ChromeNativeTestInstrumentationTestRunner')
32
33 #override
34 def TestPackage(self):
35 return self._test_instance.suite
36
37 #override
38 def _TriggerSetUp(self):
39 """Set up the triggering of a test run."""
40 logging.info('Triggering test run.')
41
42 if self._env.runner_type:
43 logging.warning('Ignoring configured runner_type "%s"',
44 self._env.runner_type)
45
46 if not self._env.runner_package:
47 runner_package = self.DEFAULT_RUNNER_PACKAGE
48 logging.info('Using default runner package: %s',
49 self.DEFAULT_RUNNER_PACKAGE)
50 else:
51 runner_package = self._env.runner_package
52
53 dummy_app_path = os.path.join(
54 constants.GetOutDirectory(), 'apks', 'remote_device_dummy.apk')
55 with tempfile.NamedTemporaryFile(suffix='.flags.txt') as flag_file:
56 env_vars = {}
57 filter_string = self._test_instance._GenerateDisabledFilterString(None)
58 if filter_string:
59 flag_file.write('_ --gtest_filter=%s' % filter_string)
60 flag_file.flush()
61 env_vars[_EXTRA_COMMAND_LINE_FILE] = os.path.basename(flag_file.name)
62 self._test_instance._data_deps.append(
63 (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(
67 dummy_app_path, self._test_instance.apk, runner_package,
68 environment_variables=env_vars)
69
70 _INSTRUMENTATION_STREAM_LEADER = 'INSTRUMENTATION_STATUS: stream='
71
72 #override
73 def _ParseTestResults(self):
74 logging.info('Parsing results from stdout.')
75 results = base_test_result.TestRunResults()
76 if self._results['results']['exception']:
77 results.AddResult(base_test_result.BaseTestResult(
78 self._results['results']['exception'],
79 base_test_result.ResultType.FAIL))
80 else:
81 output = self._results['results']['output'].splitlines()
82 output = (l[len(self._INSTRUMENTATION_STREAM_LEADER):] for l in output
83 if l.startswith(self._INSTRUMENTATION_STREAM_LEADER))
84 results_list = self._test_instance.ParseGTestOutput(output)
85 results.AddResults(results_list)
86 if self._env.only_output_failures:
87 logging.info('See logcat for more results information.')
88 if not self._results['results']['pass']:
89 results.AddResult(base_test_result.BaseTestResult(
90 'Remote Service detected error.',
91 base_test_result.ResultType.FAIL))
92 return results
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698