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

Side by Side Diff: build/android/buildbot/bb_device_steps.py

Issue 21261006: Put cleanup steps in finally block so cleanup happens after halt on failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 7 years, 4 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
« no previous file with comments | « no previous file | 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 #!/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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 299
300 300
301 def GenerateTestReport(options): 301 def GenerateTestReport(options):
302 bb_annotations.PrintNamedStep('test_report') 302 bb_annotations.PrintNamedStep('test_report')
303 for report in glob.glob( 303 for report in glob.glob(
304 os.path.join(CHROME_SRC, 'out', options.target, 'test_logs', '*.log')): 304 os.path.join(CHROME_SRC, 'out', options.target, 'test_logs', '*.log')):
305 RunCmd(['cat', report]) 305 RunCmd(['cat', report])
306 os.remove(report) 306 os.remove(report)
307 307
308 308
309 def GetPostTestStepCmds(): 309 def MainTestWrapper(options):
310 return [ 310 try:
311 ('logcat_dump', LogcatDump), 311 # Spawn logcat monitor
312 ('test_report', GenerateTestReport) 312 SpawnLogcatMonitor()
313 ]
314 313
314 # Run all device setup steps
315 for _, cmd in GetDeviceSetupStepCmds():
316 cmd(options)
315 317
316 def MainTestWrapper(options): 318 if options.install:
317 # Spawn logcat monitor 319 test_obj = INSTRUMENTATION_TESTS[options.install]
318 SpawnLogcatMonitor() 320 InstallApk(options, test_obj, print_step=True)
319 321
320 # Run all device setup steps 322 if options.test_filter:
321 for _, cmd in GetDeviceSetupStepCmds(): 323 bb_utils.RunSteps(options.test_filter, GetTestStepCmds(), options)
322 cmd(options)
323 324
324 if options.install: 325 if options.experimental:
325 test_obj = INSTRUMENTATION_TESTS[options.install] 326 RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES)
326 InstallApk(options, test_obj, print_step=True)
327 327
328 if options.test_filter: 328 finally:
329 bb_utils.RunSteps(options.test_filter, GetTestStepCmds(), options) 329 # Run all post test steps
330 330 LogcatDump(options)
331 if options.experimental: 331 GenerateTestReport(options)
332 RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES) 332 # KillHostHeartbeat() has logic to check if heartbeat process is running,
333 333 # and kills only if it finds the process is running on the host.
334 # Run all post test steps 334 provision_devices.KillHostHeartbeat()
335 for _, cmd in GetPostTestStepCmds():
336 cmd(options)
337 335
338 336
339 def GetDeviceStepsOptParser(): 337 def GetDeviceStepsOptParser():
340 parser = bb_utils.GetParser() 338 parser = bb_utils.GetParser()
341 parser.add_option('--experimental', action='store_true', 339 parser.add_option('--experimental', action='store_true',
342 help='Run experiemental tests') 340 help='Run experiemental tests')
343 parser.add_option('-f', '--test-filter', metavar='<filter>', default=[], 341 parser.add_option('-f', '--test-filter', metavar='<filter>', default=[],
344 action='append', 342 action='append',
345 help=('Run a test suite. Test suites: "%s"' % 343 help=('Run a test suite. Test suites: "%s"' %
346 '", "'.join(VALID_TESTS))) 344 '", "'.join(VALID_TESTS)))
(...skipping 23 matching lines...) Expand all
370 if args: 368 if args:
371 return sys.exit('Unused args %s' % args) 369 return sys.exit('Unused args %s' % args)
372 370
373 unknown_tests = set(options.test_filter) - VALID_TESTS 371 unknown_tests = set(options.test_filter) - VALID_TESTS
374 if unknown_tests: 372 if unknown_tests:
375 return sys.exit('Unknown tests %s' % list(unknown_tests)) 373 return sys.exit('Unknown tests %s' % list(unknown_tests))
376 374
377 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) 375 setattr(options, 'target', options.factory_properties.get('target', 'Debug'))
378 376
379 MainTestWrapper(options) 377 MainTestWrapper(options)
380 provision_devices.KillHostHeartbeat()
381 378
382 379
383 if __name__ == '__main__': 380 if __name__ == '__main__':
384 sys.exit(main(sys.argv)) 381 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698