OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import collections | 6 import collections |
7 import glob | 7 import glob |
8 import multiprocessing | 8 import multiprocessing |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 | 313 |
314 | 314 |
315 def GenerateTestReport(options): | 315 def GenerateTestReport(options): |
316 bb_annotations.PrintNamedStep('test_report') | 316 bb_annotations.PrintNamedStep('test_report') |
317 for report in glob.glob( | 317 for report in glob.glob( |
318 os.path.join(CHROME_SRC, 'out', options.target, 'test_logs', '*.log')): | 318 os.path.join(CHROME_SRC, 'out', options.target, 'test_logs', '*.log')): |
319 RunCmd(['cat', report]) | 319 RunCmd(['cat', report]) |
320 os.remove(report) | 320 os.remove(report) |
321 | 321 |
322 | 322 |
323 def KillHostHeartbeat(_): | |
324 # PostTestStepCmds take an option argument, but the provision script doesn't | |
325 # need options to kill the host heartbeat. | |
326 provision_devices.KillHostHeartbeat() | |
327 | |
328 | |
323 def GetPostTestStepCmds(): | 329 def GetPostTestStepCmds(): |
324 return [ | 330 return [ |
325 ('logcat_dump', LogcatDump), | 331 ('logcat_dump', LogcatDump), |
326 ('test_report', GenerateTestReport) | 332 ('test_report', GenerateTestReport), |
333 ('kill_host_heartbeat', KillHostHeartbeat) | |
327 ] | 334 ] |
328 | 335 |
329 | 336 |
330 def MainTestWrapper(options): | 337 def MainTestWrapper(options): |
331 # Spawn logcat monitor | 338 try: |
332 SpawnLogcatMonitor() | 339 # Spawn logcat monitor |
340 SpawnLogcatMonitor() | |
333 | 341 |
334 # Run all device setup steps | 342 # Run all device setup steps |
335 for _, cmd in GetDeviceSetupStepCmds(): | 343 for _, cmd in GetDeviceSetupStepCmds(): |
336 cmd(options) | 344 cmd(options) |
337 | 345 |
338 if options.install: | 346 if options.install: |
339 test_obj = INSTRUMENTATION_TESTS[options.install] | 347 test_obj = INSTRUMENTATION_TESTS[options.install] |
340 InstallApk(options, test_obj, print_step=True) | 348 InstallApk(options, test_obj, print_step=True) |
341 | 349 |
342 if options.test_filter: | 350 if options.test_filter: |
343 bb_utils.RunSteps(options.test_filter, GetTestStepCmds(), options) | 351 bb_utils.RunSteps(options.test_filter, GetTestStepCmds(), options) |
344 | 352 |
345 if options.experimental: | 353 if options.experimental: |
346 RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES) | 354 RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES) |
347 RunBrowserTestSuite(options) | 355 RunBrowserTestSuite(options) |
348 | 356 finally: |
Isaac (away)
2013/08/02 02:20:26
Could we just call the functions here and remove G
navabi
2013/08/02 16:26:43
Sure. That way we also don't need KillHostHeartbea
| |
349 # Run all post test steps | 357 # Run all post test steps |
350 for _, cmd in GetPostTestStepCmds(): | 358 for _, cmd in GetPostTestStepCmds(): |
351 cmd(options) | 359 cmd(options) |
352 | 360 |
353 | 361 |
354 def GetDeviceStepsOptParser(): | 362 def GetDeviceStepsOptParser(): |
355 parser = bb_utils.GetParser() | 363 parser = bb_utils.GetParser() |
356 parser.add_option('--experimental', action='store_true', | 364 parser.add_option('--experimental', action='store_true', |
357 help='Run experiemental tests') | 365 help='Run experiemental tests') |
358 parser.add_option('-f', '--test-filter', metavar='<filter>', default=[], | 366 parser.add_option('-f', '--test-filter', metavar='<filter>', default=[], |
359 action='append', | 367 action='append', |
360 help=('Run a test suite. Test suites: "%s"' % | 368 help=('Run a test suite. Test suites: "%s"' % |
361 '", "'.join(VALID_TESTS))) | 369 '", "'.join(VALID_TESTS))) |
(...skipping 23 matching lines...) Expand all Loading... | |
385 if args: | 393 if args: |
386 return sys.exit('Unused args %s' % args) | 394 return sys.exit('Unused args %s' % args) |
387 | 395 |
388 unknown_tests = set(options.test_filter) - VALID_TESTS | 396 unknown_tests = set(options.test_filter) - VALID_TESTS |
389 if unknown_tests: | 397 if unknown_tests: |
390 return sys.exit('Unknown tests %s' % list(unknown_tests)) | 398 return sys.exit('Unknown tests %s' % list(unknown_tests)) |
391 | 399 |
392 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) | 400 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) |
393 | 401 |
394 MainTestWrapper(options) | 402 MainTestWrapper(options) |
395 provision_devices.KillHostHeartbeat() | |
396 | 403 |
navabi
2013/08/02 00:29:32
This moved to GetPostTestStepCmds.
| |
397 | 404 |
398 if __name__ == '__main__': | 405 if __name__ == '__main__': |
399 sys.exit(main(sys.argv)) | 406 sys.exit(main(sys.argv)) |
OLD | NEW |