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

Side by Side Diff: scripts/slave/runtest.py

Issue 10834044: Script to archive profiling data collected from (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/build/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « scripts/slave/chromium/archive_profiling_data.py ('k') | 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) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """A tool to run a chrome test executable, used by the buildbot slaves. 6 """A tool to run a chrome test executable, used by the buildbot slaves.
7 7
8 When this is run, the current directory (cwd) should be the outer build 8 When this is run, the current directory (cwd) should be the outer build
9 directory (e.g., chrome-release/build/). 9 directory (e.g., chrome-release/build/).
10 10
(...skipping 18 matching lines...) Expand all
29 # "chromium_config", python2.6 properly uses our path to find our "google.*" 29 # "chromium_config", python2.6 properly uses our path to find our "google.*"
30 # (even though it still automatically adds the system "google" module to 30 # (even though it still automatically adds the system "google" module to
31 # sys.modules, and probably should still be using that to resolve "google.*", 31 # sys.modules, and probably should still be using that to resolve "google.*",
32 # which I really don't understand). 32 # which I really don't understand).
33 sys.path.insert(0, os.path.abspath('src/tools/python')) 33 sys.path.insert(0, os.path.abspath('src/tools/python'))
34 34
35 # Because of this dependency on a chromium checkout, we need to disable some 35 # Because of this dependency on a chromium checkout, we need to disable some
36 # pylint checks. 36 # pylint checks.
37 # pylint: disable=E0611 37 # pylint: disable=E0611
38 # pylint: disable=E1101 38 # pylint: disable=E1101
39 from buildbot.process.properties import WithProperties
cmp 2012/07/31 23:52:04 please remove this line, we won't need it
ramant (doing other things) 2012/08/01 00:23:31 Done.
39 from buildbot.status import builder 40 from buildbot.status import builder
40 41
41 from common import chromium_utils 42 from common import chromium_utils
42 from common import gtest_utils 43 from common import gtest_utils
43 from slave import gtest_slave_utils 44 from slave import gtest_slave_utils
44 from slave import slave_utils 45 from slave import slave_utils
45 from slave import xvfb 46 from slave import xvfb
46 import config 47 import config
47 48
48 USAGE = '%s [options] test.exe [test args]' % os.path.basename(sys.argv[0]) 49 USAGE = '%s [options] test.exe [test args]' % os.path.basename(sys.argv[0])
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 print '@@@STEP_WARNINGS@@@' 297 print '@@@STEP_WARNINGS@@@'
297 get_text_result = builder.WARNING 298 get_text_result = builder.WARNING
298 else: 299 else:
299 print '@@@STEP_FAILURE@@@' 300 print '@@@STEP_FAILURE@@@'
300 get_text_result = builder.FAILURE 301 get_text_result = builder.FAILURE
301 302
302 for desc in getText(get_text_result, results_tracker, test_name): 303 for desc in getText(get_text_result, results_tracker, test_name):
303 print '@@@STEP_TEXT@%s@@@' % desc 304 print '@@@STEP_TEXT@%s@@@' % desc
304 305
305 306
307 def upload_profiling_data(options):
308 """Using the target build configuration, archive the profiling data to Google
309 Storage.
310 """
311 build_dir = os.path.normpath(os.path.abspath(options.build_dir))
312
313 # Profiling data is in /b/build/slave/SLAVE_NAME/build/src/chrome/test/data
314 profiling_data_dir = os.path.join(build_dir, 'src', 'chrome', 'test', 'data')
315 if not os.path.exists(profiling_data_dir):
316 return True
317
318 profiling_file = os.path.join(profiling_data_dir, 'task_profile.json')
319 if not os.path.exists(profiling_file):
320 return True
321
322 # Profiling tool is in
323 # /b/build/slave/SLAVE_NAME/build/src/build/scripts/slave/chromium
324 profiling_archive_tool = os.path.join(build_dir, 'src', 'build', 'scripts',
325 'slave', 'chromium',
326 'archive_profiling_data.py')
327
328 if sys.platform == 'win32':
329 python = 'python_slave'
330 else:
331 python = 'python'
332
333 cmd = [python,
334 profiling_archive_tool,
335 '--run-id', WithProperties('%(got_revision)s_%(buildername)s'),
cmp 2012/07/31 23:52:04 you can access these properties as: options.build_
ramant (doing other things) 2012/08/01 00:23:31 Done.
336 '--profiling-data-dir', profiling_data_dir]
337
338 return chromium_utils.RunCommand(cmd)
339
340
306 def main_mac(options, args): 341 def main_mac(options, args):
307 if len(args) < 1: 342 if len(args) < 1:
308 raise chromium_utils.MissingArgument('Usage: %s' % USAGE) 343 raise chromium_utils.MissingArgument('Usage: %s' % USAGE)
309 344
310 test_exe = args[0] 345 test_exe = args[0]
311 build_dir = os.path.normpath(os.path.abspath(options.build_dir)) 346 build_dir = os.path.normpath(os.path.abspath(options.build_dir))
312 test_exe_path = os.path.join(build_dir, options.target, test_exe) 347 test_exe_path = os.path.join(build_dir, options.target, test_exe)
313 if not os.path.exists(test_exe_path): 348 if not os.path.exists(test_exe_path):
314 pre = 'Unable to find %s\n' % test_exe_path 349 pre = 'Unable to find %s\n' % test_exe_path
315 350
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 if sys.platform.startswith('darwin'): 731 if sys.platform.startswith('darwin'):
697 result = main_mac(options, args) 732 result = main_mac(options, args)
698 elif sys.platform == 'win32': 733 elif sys.platform == 'win32':
699 result = main_win(options, args) 734 result = main_win(options, args)
700 elif sys.platform == 'linux2': 735 elif sys.platform == 'linux2':
701 result = main_linux(options, args) 736 result = main_linux(options, args)
702 else: 737 else:
703 sys.stderr.write('Unknown sys.platform value %s\n' % repr(sys.platform)) 738 sys.stderr.write('Unknown sys.platform value %s\n' % repr(sys.platform))
704 return 1 739 return 1
705 740
741 upload_profiling_data(options)
cmp 2012/07/31 23:52:04 this should be behind a conditional of some sort,
ramant (doing other things) 2012/08/01 00:23:31 Done.
742
706 new_temp_files = get_temp_count() 743 new_temp_files = get_temp_count()
707 if temp_files > new_temp_files: 744 if temp_files > new_temp_files:
708 print >> sys.stderr, ( 745 print >> sys.stderr, (
709 'Confused: %d files were deleted from %s during the test run') % ( 746 'Confused: %d files were deleted from %s during the test run') % (
710 (temp_files - new_temp_files), tempfile.gettempdir()) 747 (temp_files - new_temp_files), tempfile.gettempdir())
711 elif temp_files < new_temp_files: 748 elif temp_files < new_temp_files:
712 print >> sys.stderr, ( 749 print >> sys.stderr, (
713 '%d new files were left in %s: Fix the tests to clean up themselves.' 750 '%d new files were left in %s: Fix the tests to clean up themselves.'
714 ) % ((new_temp_files - temp_files), tempfile.gettempdir()) 751 ) % ((new_temp_files - temp_files), tempfile.gettempdir())
715 # TODO(maruel): Make it an error soon. Not yet since I want to iron out all 752 # TODO(maruel): Make it an error soon. Not yet since I want to iron out all
716 # the remaining cases before. 753 # the remaining cases before.
717 #result = 1 754 #result = 1
718 return result 755 return result
719 756
720 757
721 if '__main__' == __name__: 758 if '__main__' == __name__:
722 sys.exit(main()) 759 sys.exit(main())
OLDNEW
« no previous file with comments | « scripts/slave/chromium/archive_profiling_data.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698