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

Side by Side Diff: build/android/pylib/gtest/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 import logging 5 import logging
6 import os 6 import os
7 import re 7 import re
8 8
9 from pylib import android_commands 9 from pylib import android_commands
10 from pylib import constants 10 from pylib import constants
11 from pylib import pexpect 11 from pylib import pexpect
12 from pylib.base import base_test_result 12 from pylib.base import base_test_result
13 from pylib.base import base_test_runner 13 from pylib.base import base_test_runner
14 from pylib.utils import run_tests_helper 14 from pylib.utils import run_tests_helper
15 15
16 import test_package_apk 16 import test_package_apk
17 import test_package_exe 17 import test_package_exe
18 18
19 19
20 def _TestSuiteRequiresMockTestServer(test_suite_basename): 20 def _TestSuiteRequiresMockTestServer(suite_basename):
21 """Returns True if the test suite requires mock test server.""" 21 """Returns True if the test suite requires mock test server."""
22 tests_require_net_test_server = ['unit_tests', 'net_unittests', 22 tests_require_net_test_server = ['unit_tests', 'net_unittests',
23 'content_unittests', 23 'content_unittests',
24 'content_browsertests'] 24 'content_browsertests']
25 return (test_suite_basename in 25 return (suite_basename in
26 tests_require_net_test_server) 26 tests_require_net_test_server)
27 27
28 28
29 class TestRunner(base_test_runner.BaseTestRunner): 29 class TestRunner(base_test_runner.BaseTestRunner):
30 def __init__(self, device, test_suite, test_arguments, timeout, 30 def __init__(self, device, suite_name, test_arguments, timeout,
31 cleanup_test_files, tool_name, build_type, 31 cleanup_test_files, tool_name, build_type,
32 in_webkit_checkout, push_deps, test_apk_package_name=None, 32 in_webkit_checkout, push_deps, test_apk_package_name=None,
33 test_activity_name=None, command_line_file=None): 33 test_activity_name=None, command_line_file=None):
34 """Single test suite attached to a single device. 34 """Single test suite attached to a single device.
35 35
36 Args: 36 Args:
37 device: Device to run the tests. 37 device: Device to run the tests.
38 test_suite: A specific test suite to run, empty to run all. 38 suite_name: A specific test suite to run, empty to run all.
39 test_arguments: Additional arguments to pass to the test binary. 39 test_arguments: Additional arguments to pass to the test binary.
40 timeout: Timeout for each test. 40 timeout: Timeout for each test.
41 cleanup_test_files: Whether or not to cleanup test files on device. 41 cleanup_test_files: Whether or not to cleanup test files on device.
42 tool_name: Name of the Valgrind tool. 42 tool_name: Name of the Valgrind tool.
43 build_type: 'Release' or 'Debug'. 43 build_type: 'Release' or 'Debug'.
44 in_webkit_checkout: Whether the suite is being run from a WebKit checkout. 44 in_webkit_checkout: Whether the suite is being run from a WebKit checkout.
45 push_deps: If True, push all dependencies to the device. 45 push_deps: If True, push all dependencies to the device.
46 test_apk_package_name: Apk package name for tests running in APKs. 46 test_apk_package_name: Apk package name for tests running in APKs.
47 test_activity_name: Test activity to invoke for APK tests. 47 test_activity_name: Test activity to invoke for APK tests.
48 command_line_file: Filename to use to pass arguments to tests. 48 command_line_file: Filename to use to pass arguments to tests.
49 """ 49 """
50 super(TestRunner, self).__init__(device, tool_name, build_type, push_deps, 50 super(TestRunner, self).__init__(device, tool_name, build_type, push_deps,
51 cleanup_test_files) 51 cleanup_test_files)
52 self._test_arguments = test_arguments 52 self._test_arguments = test_arguments
53 self.in_webkit_checkout = in_webkit_checkout 53 self.in_webkit_checkout = in_webkit_checkout
54 if timeout == 0: 54 if timeout == 0:
55 timeout = 60 55 timeout = 60
56 # On a VM (e.g. chromium buildbots), this timeout is way too small. 56 # On a VM (e.g. chromium buildbots), this timeout is way too small.
57 if os.environ.get('BUILDBOT_SLAVENAME'): 57 if os.environ.get('BUILDBOT_SLAVENAME'):
58 timeout = timeout * 2 58 timeout = timeout * 2
59 self.timeout = timeout * self.tool.GetTimeoutScale() 59 self.timeout = timeout * self.tool.GetTimeoutScale()
60 60
61 logging.warning('Test suite: ' + test_suite) 61 logging.warning('Test suite: ' + str(suite_name))
62 if os.path.splitext(test_suite)[1] == '.apk': 62 if os.path.splitext(suite_name)[1] == '.apk':
63 self.test_package = test_package_apk.TestPackageApk( 63 self.test_package = test_package_apk.TestPackageApk(
64 self.adb, 64 self.adb,
65 device, 65 device,
66 test_suite, 66 suite_name,
67 self.tool, 67 self.tool,
68 test_apk_package_name, 68 test_apk_package_name,
69 test_activity_name, 69 test_activity_name,
70 command_line_file) 70 command_line_file)
71 else: 71 else:
72 # Put a copy into the android out/target directory, to allow stack trace 72 # Put a copy into the android out/target directory, to allow stack trace
73 # generation. 73 # generation.
74 symbols_dir = os.path.join(constants.DIR_SOURCE_ROOT, 'out', build_type, 74 symbols_dir = os.path.join(constants.DIR_SOURCE_ROOT, 'out', build_type,
75 'lib.target') 75 'lib.target')
76 self.test_package = test_package_exe.TestPackageExecutable( 76 self.test_package = test_package_exe.TestPackageExecutable(
77 self.adb, 77 self.adb,
78 device, 78 device,
79 test_suite, 79 suite_name,
80 self.tool, 80 self.tool,
81 symbols_dir) 81 symbols_dir)
82 82
83 #override 83 #override
84 def InstallTestPackage(self): 84 def InstallTestPackage(self):
85 self.test_package.Install() 85 self.test_package.Install()
86 86
87 #override 87 #override
88 def PushDataDeps(self): 88 def PushDataDeps(self):
89 self.adb.WaitForSdCardReady(20) 89 self.adb.WaitForSdCardReady(20)
90 self.tool.CopyFiles() 90 self.tool.CopyFiles()
91 if self.test_package.test_suite_basename == 'webkit_unit_tests': 91 if self.test_package.suite_basename == 'webkit_unit_tests':
92 self.PushWebKitUnitTestsData() 92 self.PushWebKitUnitTestsData()
93 return 93 return
94 94
95 if os.path.exists(constants.ISOLATE_DEPS_DIR): 95 if os.path.exists(constants.ISOLATE_DEPS_DIR):
96 device_dir = self.adb.GetExternalStorage() 96 device_dir = self.adb.GetExternalStorage()
97 # TODO(frankf): linux_dumper_unittest_helper needs to be in the same dir 97 # TODO(frankf): linux_dumper_unittest_helper needs to be in the same dir
98 # as breakpad_unittests exe. Find a better way to do this. 98 # as breakpad_unittests exe. Find a better way to do this.
99 if self.test_package.test_suite_basename == 'breakpad_unittests': 99 if self.test_package.suite_basename == 'breakpad_unittests':
100 device_dir = constants.TEST_EXECUTABLE_DIR 100 device_dir = constants.TEST_EXECUTABLE_DIR
101 for p in os.listdir(constants.ISOLATE_DEPS_DIR): 101 for p in os.listdir(constants.ISOLATE_DEPS_DIR):
102 self.adb.PushIfNeeded( 102 self.adb.PushIfNeeded(
103 os.path.join(constants.ISOLATE_DEPS_DIR, p), 103 os.path.join(constants.ISOLATE_DEPS_DIR, p),
104 os.path.join(device_dir, p)) 104 os.path.join(device_dir, p))
105 105
106 def PushWebKitUnitTestsData(self): 106 def PushWebKitUnitTestsData(self):
107 """Pushes the webkit_unit_tests data files to the device. 107 """Pushes the webkit_unit_tests data files to the device.
108 108
109 The path of this directory is different when the suite is being run as 109 The path of this directory is different when the suite is being run as
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 test_results.AddResults( 224 test_results.AddResults(
225 [base_test_result.BaseTestResult(t, base_test_result.ResultType.UNKNOWN) 225 [base_test_result.BaseTestResult(t, base_test_result.ResultType.UNKNOWN)
226 for t in unknown_tests]) 226 for t in unknown_tests])
227 retry = ':'.join([t.GetName() for t in test_results.GetNotPass()]) 227 retry = ':'.join([t.GetName() for t in test_results.GetNotPass()])
228 return test_results, retry 228 return test_results, retry
229 229
230 #override 230 #override
231 def SetUp(self): 231 def SetUp(self):
232 """Sets up necessary test enviroment for the test suite.""" 232 """Sets up necessary test enviroment for the test suite."""
233 super(TestRunner, self).SetUp() 233 super(TestRunner, self).SetUp()
234 if _TestSuiteRequiresMockTestServer(self.test_package.test_suite_basename): 234 if _TestSuiteRequiresMockTestServer(self.test_package.suite_basename):
235 self.LaunchChromeTestServerSpawner() 235 self.LaunchChromeTestServerSpawner()
236 self.tool.SetupEnvironment() 236 self.tool.SetupEnvironment()
237 237
238 #override 238 #override
239 def TearDown(self): 239 def TearDown(self):
240 """Cleans up the test enviroment for the test suite.""" 240 """Cleans up the test enviroment for the test suite."""
241 self.tool.CleanUpEnvironment() 241 self.tool.CleanUpEnvironment()
242 super(TestRunner, self).TearDown() 242 super(TestRunner, self).TearDown()
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/test_package_exe.py ('k') | build/android/pylib/host_driven/python_test_base.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698