OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """A tool to run the crash handler executable, used by the buildbot slaves. |
| 7 |
| 8 When this is run, the current directory (cwd) should be the outer build |
| 9 directory (e.g., chrome-release/build/). |
| 10 |
| 11 This can only be run on Windows. |
| 12 |
| 13 For a list of command-line options, call this script with '--help'. |
| 14 """ |
| 15 |
| 16 import optparse |
| 17 import os |
| 18 import sys |
| 19 try: |
| 20 # pylint: disable=F0401 |
| 21 import win32process |
| 22 except ImportError: |
| 23 print >> sys.stderr, 'This script runs on Windows only.' |
| 24 sys.exit(1) |
| 25 |
| 26 from common import chromium_utils |
| 27 from slave import build_directory |
| 28 |
| 29 USAGE = '%s [options]' % os.path.basename(sys.argv[0]) |
| 30 |
| 31 |
| 32 def main(): |
| 33 """Using the target build configuration, run the crash_service.exe |
| 34 executable. |
| 35 """ |
| 36 option_parser = optparse.OptionParser(usage=USAGE) |
| 37 |
| 38 option_parser.add_option('--target', default='Release', |
| 39 help='build target (Debug or Release)') |
| 40 option_parser.add_option('--build-dir', help='ignored') |
| 41 options, args = option_parser.parse_args() |
| 42 options.build_dir = build_directory.GetBuildOutputDirectory() |
| 43 |
| 44 if args: |
| 45 option_parser.error('No args are supported') |
| 46 |
| 47 build_dir = os.path.abspath(options.build_dir) |
| 48 exe_path = os.path.join(build_dir, options.target, 'crash_service.exe') |
| 49 if not os.path.exists(exe_path): |
| 50 raise chromium_utils.PathNotFound('Unable to find %s' % exe_path) |
| 51 |
| 52 # crash_service's window can interfere with interactive ui tests. |
| 53 cmd = exe_path + ' --no-window' |
| 54 |
| 55 print '\n' + cmd + '\n', |
| 56 |
| 57 # We cannot use Popen or os.spawn here because buildbot will wait until |
| 58 # the process terminates before going to the next step. Since we want to |
| 59 # keep the process alive, we need to explicitly say that we want the |
| 60 # process to be detached and that we don't want to inherit handles from |
| 61 # the parent process. |
| 62 si = win32process.STARTUPINFO() |
| 63 details = win32process.CreateProcess(None, cmd, None, None, 0, |
| 64 win32process.DETACHED_PROCESS, None, |
| 65 None, si) |
| 66 print '\nCreated with process id %d\n' % details[2] |
| 67 return 0 |
| 68 |
| 69 |
| 70 if '__main__' == __name__: |
| 71 sys.exit(main()) |
OLD | NEW |