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

Side by Side Diff: build/android/pylib/instrumentation/test_runner.py

Issue 13577003: [Android] Specify dependency files for instrumentation tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor change: Also add ssl/certs dep to contentshell Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/instrumentation/test_package.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Runs the Java tests. See more information on run_instrumentation_tests.py.""" 5 """Runs the Java tests. See more information on run_instrumentation_tests.py."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import re 9 import re
10 import shutil 10 import shutil
11 import sys 11 import sys
12 import time 12 import time
13 13
14 from pylib import android_commands 14 from pylib import android_commands
15 from pylib import cmd_helper 15 from pylib import cmd_helper
16 from pylib import constants 16 from pylib import constants
17 from pylib import forwarder 17 from pylib import forwarder
18 from pylib import json_perf_parser 18 from pylib import json_perf_parser
19 from pylib import perf_tests_helper 19 from pylib import perf_tests_helper
20 from pylib import valgrind_tools 20 from pylib import valgrind_tools
21 from pylib.base import base_test_result 21 from pylib.base import base_test_result
22 from pylib.base import base_test_runner 22 from pylib.base import base_test_runner
23 23
24 import test_result 24 import test_result
25 25
26 26
27 _PERF_TEST_ANNOTATION = 'PerfTest' 27 _PERF_TEST_ANNOTATION = 'PerfTest'
28 28
29 29
30 def _GetDataFilesForTestSuite(test_suite_basename):
31 """Returns a list of data files/dirs needed by the test suite.
32
33 Args:
34 test_suite_basename: The test suite basename for which to return file paths.
35
36 Returns:
37 A list of test file and directory paths.
38 """
39 test_files = []
40 if test_suite_basename in ['ChromeTest', 'ContentShellTest']:
41 test_files += [
42 'net/data/ssl/certificates/',
43 ]
44 return test_files
45
46
30 class TestRunner(base_test_runner.BaseTestRunner): 47 class TestRunner(base_test_runner.BaseTestRunner):
31 """Responsible for running a series of tests connected to a single device.""" 48 """Responsible for running a series of tests connected to a single device."""
32 49
33 _DEVICE_DATA_DIR = 'chrome/test/data' 50 _DEVICE_DATA_DIR = 'chrome/test/data'
34 _EMMA_JAR = os.path.join(os.environ.get('ANDROID_BUILD_TOP', ''), 51 _EMMA_JAR = os.path.join(os.environ.get('ANDROID_BUILD_TOP', ''),
35 'external/emma/lib/emma.jar') 52 'external/emma/lib/emma.jar')
36 _COVERAGE_MERGED_FILENAME = 'unittest_coverage.es' 53 _COVERAGE_MERGED_FILENAME = 'unittest_coverage.es'
37 _COVERAGE_WEB_ROOT_DIR = os.environ.get('EMMA_WEB_ROOTDIR') 54 _COVERAGE_WEB_ROOT_DIR = os.environ.get('EMMA_WEB_ROOTDIR')
38 _COVERAGE_FILENAME = 'coverage.ec' 55 _COVERAGE_FILENAME = 'coverage.ec'
39 _COVERAGE_RESULT_PATH = ('/data/data/com.google.android.apps.chrome/files/' + 56 _COVERAGE_RESULT_PATH = ('/data/data/com.google.android.apps.chrome/files/' +
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 ' : Coverage meta info [' + 116 ' : Coverage meta info [' +
100 TestRunner._COVERAGE_META_INFO_PATH + 117 TestRunner._COVERAGE_META_INFO_PATH +
101 '] does not exist.') 118 '] does not exist.')
102 if (not TestRunner._COVERAGE_WEB_ROOT_DIR or 119 if (not TestRunner._COVERAGE_WEB_ROOT_DIR or
103 not os.path.exists(TestRunner._COVERAGE_WEB_ROOT_DIR)): 120 not os.path.exists(TestRunner._COVERAGE_WEB_ROOT_DIR)):
104 raise Exception('FATAL ERROR in ' + sys.argv[0] + 121 raise Exception('FATAL ERROR in ' + sys.argv[0] +
105 ' : Path specified in $EMMA_WEB_ROOTDIR [' + 122 ' : Path specified in $EMMA_WEB_ROOTDIR [' +
106 TestRunner._COVERAGE_WEB_ROOT_DIR + 123 TestRunner._COVERAGE_WEB_ROOT_DIR +
107 '] does not exist.') 124 '] does not exist.')
108 125
109 def CopyTestFilesOnce(self): 126 #override.
110 """Pushes the test data files to the device. Installs the apk if opted.""" 127 def PushDependencies(self):
128 # TODO(frankf): Implement a general approach for copying/installing
129 # once across test runners.
111 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): 130 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False):
112 logging.warning('Already copied test files to device %s, skipping.', 131 logging.warning('Already copied test files to device %s, skipping.',
113 self.device) 132 self.device)
114 return 133 return
134
135 test_data = _GetDataFilesForTestSuite(self.test_pkg.GetApkName())
136 if test_data:
137 # Make sure SD card is ready.
138 self.adb.WaitForSdCardReady(20)
139 for data in test_data:
140 self.CopyTestData([data], self.adb.GetExternalStorage())
141
142 # TODO(frankf): Specify test data in this file as opposed to passing
143 # as command-line.
115 for dest_host_pair in self.test_data: 144 for dest_host_pair in self.test_data:
116 dst_src = dest_host_pair.split(':',1) 145 dst_src = dest_host_pair.split(':',1)
117 dst_layer = dst_src[0] 146 dst_layer = dst_src[0]
118 host_src = dst_src[1] 147 host_src = dst_src[1]
119 host_test_files_path = constants.CHROME_DIR + '/' + host_src 148 host_test_files_path = constants.CHROME_DIR + '/' + host_src
120 if os.path.exists(host_test_files_path): 149 if os.path.exists(host_test_files_path):
121 self.adb.PushIfNeeded(host_test_files_path, 150 self.adb.PushIfNeeded(host_test_files_path,
122 self.adb.GetExternalStorage() + '/' + 151 self.adb.GetExternalStorage() + '/' +
123 TestRunner._DEVICE_DATA_DIR + '/' + dst_layer) 152 TestRunner._DEVICE_DATA_DIR + '/' + dst_layer)
124 if self.is_uiautomator_test: 153 if self.is_uiautomator_test or self.install_apk:
125 self.test_pkg.Install(self.adb) 154 self.test_pkg.Install(self.adb)
126 elif self.install_apk:
127 self.test_pkg.Install(self.adb)
128
129 self.tool.CopyFiles() 155 self.tool.CopyFiles()
130 TestRunner._DEVICE_HAS_TEST_FILES[self.device] = True 156 TestRunner._DEVICE_HAS_TEST_FILES[self.device] = True
131 157
132 def SaveCoverageData(self, test): 158 def SaveCoverageData(self, test):
133 """Saves the Emma coverage data before it's overwritten by the next test. 159 """Saves the Emma coverage data before it's overwritten by the next test.
134 160
135 Args: 161 Args:
136 test: the test whose coverage data is collected. 162 test: the test whose coverage data is collected.
137 """ 163 """
138 if not self.coverage: 164 if not self.coverage:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 def SetUp(self): 225 def SetUp(self):
200 """Sets up the test harness and device before all tests are run.""" 226 """Sets up the test harness and device before all tests are run."""
201 super(TestRunner, self).SetUp() 227 super(TestRunner, self).SetUp()
202 if not self.adb.IsRootEnabled(): 228 if not self.adb.IsRootEnabled():
203 logging.warning('Unable to enable java asserts for %s, non rooted device', 229 logging.warning('Unable to enable java asserts for %s, non rooted device',
204 self.device) 230 self.device)
205 else: 231 else:
206 if self.adb.SetJavaAssertsEnabled(enable=not self.disable_assertions): 232 if self.adb.SetJavaAssertsEnabled(enable=not self.disable_assertions):
207 self.adb.Reboot(full_reboot=False) 233 self.adb.Reboot(full_reboot=False)
208 234
209 self.CopyTestFilesOnce()
210 # We give different default value to launch HTTP server based on shard index 235 # We give different default value to launch HTTP server based on shard index
211 # because it may have race condition when multiple processes are trying to 236 # because it may have race condition when multiple processes are trying to
212 # launch lighttpd with same port at same time. 237 # launch lighttpd with same port at same time.
213 http_server_ports = self.LaunchTestHttpServer( 238 http_server_ports = self.LaunchTestHttpServer(
214 os.path.join(constants.CHROME_DIR), self._lighttp_port) 239 os.path.join(constants.CHROME_DIR), self._lighttp_port)
215 if self.ports_to_forward: 240 if self.ports_to_forward:
216 port_pairs = [(port, port) for port in self.ports_to_forward] 241 port_pairs = [(port, port) for port in self.ports_to_forward]
217 # We need to remember which ports the HTTP server is using, since the 242 # We need to remember which ports the HTTP server is using, since the
218 # forwarder will stomp on them otherwise. 243 # forwarder will stomp on them otherwise.
219 port_pairs.append(http_server_ports) 244 port_pairs.append(http_server_ports)
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 duration_ms = 0 462 duration_ms = 0
438 message = str(e) 463 message = str(e)
439 if not message: 464 if not message:
440 message = 'No information.' 465 message = 'No information.'
441 results.AddResult(test_result.InstrumentationTestResult( 466 results.AddResult(test_result.InstrumentationTestResult(
442 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, 467 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms,
443 log=message)) 468 log=message))
444 raw_result = None 469 raw_result = None
445 self.TestTeardown(test, raw_result) 470 self.TestTeardown(test, raw_result)
446 return (results, None if results.DidRunPass() else test) 471 return (results, None if results.DidRunPass() else test)
OLDNEW
« no previous file with comments | « build/android/pylib/instrumentation/test_package.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698