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

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

Issue 18770008: [Android] Redesigns the sharder to allow replicated vs distributed tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-adds -f short form to gtest_filter switch Created 7 years, 5 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
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 """Class for running instrumentation tests on a single device.""" 5 """Class for running instrumentation tests on a single device."""
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 json_perf_parser 17 from pylib import json_perf_parser
18 from pylib import perf_tests_helper 18 from pylib import perf_tests_helper
19 from pylib import valgrind_tools 19 from pylib import valgrind_tools
20 from pylib.base import base_test_result 20 from pylib.base import base_test_result
21 from pylib.base import base_test_runner 21 from pylib.base import base_test_runner
22 22
23 import test_result 23 import test_result
24 24
25 25
26 _PERF_TEST_ANNOTATION = 'PerfTest' 26 _PERF_TEST_ANNOTATION = 'PerfTest'
27 27
28 28
29 def _GetDataFilesForTestSuite(test_suite_basename): 29 def _GetDataFilesForTestSuite(suite_basename):
30 """Returns a list of data files/dirs needed by the test suite. 30 """Returns a list of data files/dirs needed by the test suite.
31 31
32 Args: 32 Args:
33 test_suite_basename: The test suite basename for which to return file paths. 33 suite_basename: The test suite basename for which to return file paths.
34 34
35 Returns: 35 Returns:
36 A list of test file and directory paths. 36 A list of test file and directory paths.
37 """ 37 """
38 test_files = [] 38 test_files = []
39 if test_suite_basename in ['ChromeTest', 'ContentShellTest']: 39 if suite_basename in ['ChromeTest', 'ContentShellTest']:
40 test_files += [ 40 test_files += [
41 'net/data/ssl/certificates/', 41 'net/data/ssl/certificates/',
42 ] 42 ]
43 return test_files 43 return test_files
44 44
45 45
46 class TestRunner(base_test_runner.BaseTestRunner): 46 class TestRunner(base_test_runner.BaseTestRunner):
47 """Responsible for running a series of tests connected to a single device.""" 47 """Responsible for running a series of tests connected to a single device."""
48 48
49 _DEVICE_DATA_DIR = 'chrome/test/data' 49 _DEVICE_DATA_DIR = 'chrome/test/data'
50 _HOSTMACHINE_PERF_OUTPUT_FILE = '/tmp/chrome-profile' 50 _HOSTMACHINE_PERF_OUTPUT_FILE = '/tmp/chrome-profile'
51 _DEVICE_PERF_OUTPUT_SEARCH_PREFIX = (constants.DEVICE_PERF_OUTPUT_DIR + 51 _DEVICE_PERF_OUTPUT_SEARCH_PREFIX = (constants.DEVICE_PERF_OUTPUT_DIR +
52 '/chrome-profile*') 52 '/chrome-profile*')
53 _DEVICE_HAS_TEST_FILES = {} 53 _DEVICE_HAS_TEST_FILES = {}
54 54
55 def __init__(self, options, device, shard_index, test_pkg, ports_to_forward): 55 def __init__(self, build_type, test_data, install_apk, save_perf_json,
56 screenshot_failures, tool, wait_for_debugger, disable_assertions,
57 push_deps, cleanup_test_files, device, shard_index, test_pkg,
58 ports_to_forward):
56 """Create a new TestRunner. 59 """Create a new TestRunner.
57 60
58 Args: 61 Args:
59 options: An options object with the following required attributes: 62 build_type: 'Release' or 'Debug'.
60 - build_type: 'Release' or 'Debug'. 63 test_data: Location of the test data.
61 - install_apk: Re-installs the apk if opted. 64 install_apk: Re-installs the apk if opted.
62 - save_perf_json: Whether or not to save the JSON file from UI perf 65 save_perf_json: Whether or not to save the JSON file from UI perf tests.
63 tests. 66 screenshot_failures: Take a screenshot for a test failure
64 - screenshot_failures: Take a screenshot for a test failure 67 tool: Name of the Valgrind tool.
65 - tool: Name of the Valgrind tool. 68 wait_for_debugger: Blocks until the debugger is connected.
66 - wait_for_debugger: blocks until the debugger is connected. 69 disable_assertions: Whether to disable java assertions on the device.
67 - disable_assertions: Whether to disable java assertions on the device. 70 push_deps: If True, push all dependencies to the device.
68 - push_deps: If True, push all dependencies to the device. 71 cleanup_test_files: Whether or not to cleanup test files on device.
69 - cleanup_test_files: Whether or not to cleanup test files on device.
70 device: Attached android device. 72 device: Attached android device.
71 shard_index: Shard index. 73 shard_index: Shard index.
72 test_pkg: A TestPackage object. 74 test_pkg: A TestPackage object.
73 ports_to_forward: A list of port numbers for which to set up forwarders. 75 ports_to_forward: A list of port numbers for which to set up forwarders.
74 Can be optionally requested by a test case. 76 Can be optionally requested by a test case.
75 """ 77 """
76 super(TestRunner, self).__init__( 78 super(TestRunner, self).__init__(device, tool, build_type, push_deps,
77 device, options.tool, options.build_type, options.push_deps, 79 cleanup_test_files)
78 options.cleanup_test_files)
79 self._lighttp_port = constants.LIGHTTPD_RANDOM_PORT_FIRST + shard_index 80 self._lighttp_port = constants.LIGHTTPD_RANDOM_PORT_FIRST + shard_index
80 81
81 self.build_type = options.build_type 82 self.build_type = build_type
82 self.test_data = options.test_data 83 self.test_data = test_data
83 self.save_perf_json = options.save_perf_json 84 self.save_perf_json = save_perf_json
84 self.screenshot_failures = options.screenshot_failures 85 self.screenshot_failures = screenshot_failures
85 self.wait_for_debugger = options.wait_for_debugger 86 self.wait_for_debugger = wait_for_debugger
86 self.disable_assertions = options.disable_assertions 87 self.disable_assertions = disable_assertions
87 self.test_pkg = test_pkg 88 self.test_pkg = test_pkg
88 self.ports_to_forward = ports_to_forward 89 self.ports_to_forward = ports_to_forward
89 self.install_apk = options.install_apk 90 self.install_apk = install_apk
90 91
91 #override 92 #override
92 def InstallTestPackage(self): 93 def InstallTestPackage(self):
93 if self.install_apk: 94 if self.install_apk:
94 self.test_pkg.Install(self.adb) 95 self.test_pkg.Install(self.adb)
95 96
96 #override 97 #override
97 def PushDataDeps(self): 98 def PushDataDeps(self):
98 # TODO(frankf): Implement a general approach for copying/installing 99 # TODO(frankf): Implement a general approach for copying/installing
99 # once across test runners. 100 # once across test runners.
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 duration_ms = 0 354 duration_ms = 0
354 message = str(e) 355 message = str(e)
355 if not message: 356 if not message:
356 message = 'No information.' 357 message = 'No information.'
357 results.AddResult(test_result.InstrumentationTestResult( 358 results.AddResult(test_result.InstrumentationTestResult(
358 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, 359 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms,
359 log=message)) 360 log=message))
360 raw_result = None 361 raw_result = None
361 self.TestTeardown(test, raw_result) 362 self.TestTeardown(test, raw_result)
362 return (results, None if results.DidRunPass() else test) 363 return (results, None if results.DidRunPass() else test)
OLDNEW
« no previous file with comments | « build/android/pylib/instrumentation/setup.py ('k') | build/android/pylib/uiautomator/dispatch.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698