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

Side by Side Diff: build/android/run_tests.py

Issue 11817033: Move android buildbot steps into buildbot dir (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Runs all the native unit tests. 7 """Runs all the native unit tests.
8 8
9 1. Copy over test binary to /data/local on device. 9 1. Copy over test binary to /data/local on device.
10 2. Resources: chrome/unit_tests requires resources (chrome.pak and en-US.pak) 10 2. Resources: chrome/unit_tests requires resources (chrome.pak and en-US.pak)
(...skipping 28 matching lines...) Expand all
39 import fnmatch 39 import fnmatch
40 import logging 40 import logging
41 import optparse 41 import optparse
42 import os 42 import os
43 import signal 43 import signal
44 import subprocess 44 import subprocess
45 import sys 45 import sys
46 import time 46 import time
47 47
48 from pylib import android_commands 48 from pylib import android_commands
49 from pylib import buildbot_report 49 from pylib import buildbot_report
frankf 2013/01/10 02:22:31 We can remove this import.
Isaac (away) 2013/01/10 02:54:24 Done.
50 from pylib import cmd_helper 50 from pylib import cmd_helper
51 from pylib import ports 51 from pylib import ports
52 from pylib.base_test_sharder import BaseTestSharder 52 from pylib.base_test_sharder import BaseTestSharder
53 from pylib.gtest import debug_info 53 from pylib.gtest import debug_info
54 from pylib.gtest import gtest_config
54 from pylib.gtest.single_test_runner import SingleTestRunner 55 from pylib.gtest.single_test_runner import SingleTestRunner
55 from pylib.utils import emulator 56 from pylib.utils import emulator
56 from pylib.utils import run_tests_helper 57 from pylib.utils import run_tests_helper
57 from pylib.utils import test_options_parser 58 from pylib.utils import test_options_parser
58 from pylib.utils import time_profile 59 from pylib.utils import time_profile
59 from pylib.utils import xvfb 60 from pylib.utils import xvfb
60 61
61 62
62 _TEST_SUITES = ['base_unittests',
63 'cc_unittests',
64 'content_unittests',
65 'gpu_unittests',
66 'ipc_tests',
67 'media_unittests',
68 'net_unittests',
69 'sql_unittests',
70 'sync_unit_tests',
71 'ui_unittests',
72 'unit_tests',
73 'webkit_compositor_bindings_unittests',
74 'android_webview_unittests',
75 ]
76
77
78 def FullyQualifiedTestSuites(exe, option_test_suite, build_type): 63 def FullyQualifiedTestSuites(exe, option_test_suite, build_type):
79 """Get a list of absolute paths to test suite targets. 64 """Get a list of absolute paths to test suite targets.
80 65
81 Args: 66 Args:
82 exe: if True, use the executable-based test runner. 67 exe: if True, use the executable-based test runner.
83 option_test_suite: the test_suite specified as an option. 68 option_test_suite: the test_suite specified as an option.
84 build_type: 'Release' or 'Debug'. 69 build_type: 'Release' or 'Debug'.
85 """ 70 """
86 test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type) 71 test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type)
87 if option_test_suite: 72 if option_test_suite:
88 all_test_suites = [option_test_suite] 73 all_test_suites = [option_test_suite]
89 else: 74 else:
90 all_test_suites = _TEST_SUITES 75 all_test_suites = gtest_config.STABLE_TEST_SUITES
91 76
92 if exe: 77 if exe:
93 qualified_test_suites = [os.path.join(test_suite_dir, t) 78 qualified_test_suites = [os.path.join(test_suite_dir, t)
94 for t in all_test_suites] 79 for t in all_test_suites]
95 else: 80 else:
96 # out/(Debug|Release)/$SUITE_apk/$SUITE-debug.apk 81 # out/(Debug|Release)/$SUITE_apk/$SUITE-debug.apk
97 qualified_test_suites = [os.path.join(test_suite_dir, 82 qualified_test_suites = [os.path.join(test_suite_dir,
98 t + '_apk', 83 t + '_apk',
99 t + '-debug.apk') 84 t + '-debug.apk')
100 for t in all_test_suites] 85 for t in all_test_suites]
101 for t, q in zip(all_test_suites, qualified_test_suites): 86 for t, q in zip(all_test_suites, qualified_test_suites):
102 if not os.path.exists(q): 87 if not os.path.exists(q):
103 raise Exception('Test suite %s not found in %s.\n' 88 raise Exception('Test suite %s not found in %s.\n'
104 'Supported test suites:\n %s\n' 89 'Supported test suites:\n %s\n'
105 'Ensure it has been built.\n' % 90 'Ensure it has been built.\n' %
106 (t, q, _TEST_SUITES)) 91 (t, q, gtest_config.STABLE_TEST_SUITES))
107 return qualified_test_suites 92 return qualified_test_suites
108 93
109 94
110 class TestSharder(BaseTestSharder): 95 class TestSharder(BaseTestSharder):
111 """Responsible for sharding the tests on the connected devices.""" 96 """Responsible for sharding the tests on the connected devices."""
112 97
113 def __init__(self, attached_devices, test_suite, gtest_filter, 98 def __init__(self, attached_devices, test_suite, gtest_filter,
114 test_arguments, timeout, cleanup_test_files, tool, 99 test_arguments, timeout, cleanup_test_files, tool,
115 log_dump_name, build_type, in_webkit_checkout, 100 log_dump_name, build_type, in_webkit_checkout,
116 flakiness_server=None): 101 flakiness_server=None):
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 test bundles. If using the emulator, we start it on entry and stop 217 test bundles. If using the emulator, we start it on entry and stop
233 it on exit. 218 it on exit.
234 219
235 Args: 220 Args:
236 options: options for running the tests. 221 options: options for running the tests.
237 222
238 Returns: 223 Returns:
239 0 if successful, number of failing tests otherwise. 224 0 if successful, number of failing tests otherwise.
240 """ 225 """
241 step_name = os.path.basename(options.test_suite).replace('-debug.apk', '') 226 step_name = os.path.basename(options.test_suite).replace('-debug.apk', '')
242 buildbot_report.PrintNamedStep(step_name)
243 attached_devices = [] 227 attached_devices = []
244 buildbot_emulators = [] 228 buildbot_emulators = []
245 229
246 if options.use_emulator: 230 if options.use_emulator:
247 buildbot_emulators = emulator.LaunchEmulators(options.emulator_count, 231 buildbot_emulators = emulator.LaunchEmulators(options.emulator_count,
248 wait_for_boot=True) 232 wait_for_boot=True)
249 attached_devices = [e.device for e in buildbot_emulators] 233 attached_devices = [e.device for e in buildbot_emulators]
250 elif options.test_device: 234 elif options.test_device:
251 attached_devices = [options.test_device] 235 attached_devices = [options.test_device]
252 else: 236 else:
253 attached_devices = android_commands.GetAttachedDevices() 237 attached_devices = android_commands.GetAttachedDevices()
254 238
255 if not attached_devices: 239 if not attached_devices:
256 logging.critical('A device must be attached and online.') 240 logging.critical('A device must be attached and online.')
257 buildbot_report.PrintError() 241 buildbot_report.PrintError()
frankf 2013/01/10 02:22:31 Still needs to be removed
Isaac (away) 2013/01/10 02:54:24 Sorry about that, I got distracted. Removed now.
258 return 1 242 return 1
259 243
260 # Reset the test port allocation. It's important to do it before starting 244 # Reset the test port allocation. It's important to do it before starting
261 # to dispatch any tests. 245 # to dispatch any tests.
262 if not ports.ResetTestServerPortAllocation(): 246 if not ports.ResetTestServerPortAllocation():
263 raise Exception('Failed to reset test server port.') 247 raise Exception('Failed to reset test server port.')
264 248
265 if options.gtest_filter: 249 if options.gtest_filter:
266 logging.warning('Sharding is not possible with these configurations.') 250 logging.warning('Sharding is not possible with these configurations.')
267 attached_devices = [attached_devices[0]] 251 attached_devices = [attached_devices[0]]
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 failures += _RunATestSuite(test_options) 300 failures += _RunATestSuite(test_options)
317 301
318 if options.use_xvfb: 302 if options.use_xvfb:
319 framebuffer.Stop() 303 framebuffer.Stop()
320 return failures 304 return failures
321 305
322 306
323 def ListTestSuites(): 307 def ListTestSuites():
324 """Display a list of available test suites.""" 308 """Display a list of available test suites."""
325 print 'Available test suites are:' 309 print 'Available test suites are:'
326 for test_suite in _TEST_SUITES: 310 for test_suite in gtest_config.STABLE_TEST_SUITES:
327 print test_suite 311 print test_suite
328 312
329 313
330 def main(argv): 314 def main(argv):
331 option_parser = optparse.OptionParser() 315 option_parser = optparse.OptionParser()
332 test_options_parser.AddGTestOptions(option_parser) 316 test_options_parser.AddGTestOptions(option_parser)
333 options, args = option_parser.parse_args(argv) 317 options, args = option_parser.parse_args(argv)
334 318
335 if len(args) > 1: 319 if len(args) > 1:
336 option_parser.error('Unknown argument: %s' % args[1:]) 320 option_parser.error('Unknown argument: %s' % args[1:])
(...skipping 15 matching lines...) Expand all
352 # the batch (this happens because the exit status is a sum of all failures 336 # the batch (this happens because the exit status is a sum of all failures
353 # from all suites, but the buildbot associates the exit status only with the 337 # from all suites, but the buildbot associates the exit status only with the
354 # most recent step). 338 # most recent step).
355 if options.exit_code: 339 if options.exit_code:
356 return failed_tests_count 340 return failed_tests_count
357 return 0 341 return 0
358 342
359 343
360 if __name__ == '__main__': 344 if __name__ == '__main__':
361 sys.exit(main(sys.argv)) 345 sys.exit(main(sys.argv))
OLDNEW
« build/android/buildbot/bb_tests.py ('K') | « build/android/pylib/gtest/gtest_config.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698