OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2007-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2007-2008 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 26 matching lines...) Expand all Loading... |
37 build_dir = os.path.normpath(os.path.abspath(options.build_dir)) | 37 build_dir = os.path.normpath(os.path.abspath(options.build_dir)) |
38 test_exe_path = os.path.join(build_dir, options.target, test_exe) | 38 test_exe_path = os.path.join(build_dir, options.target, test_exe) |
39 if not os.path.exists(test_exe_path): | 39 if not os.path.exists(test_exe_path): |
40 pre = 'Unable to find %s\n' % test_exe_path | 40 pre = 'Unable to find %s\n' % test_exe_path |
41 build_dir = os.path.join(os.path.dirname(build_dir), 'xcodebuild') | 41 build_dir = os.path.join(os.path.dirname(build_dir), 'xcodebuild') |
42 test_exe_path = os.path.join(build_dir, options.target, test_exe) | 42 test_exe_path = os.path.join(build_dir, options.target, test_exe) |
43 if not os.path.exists(test_exe_path): | 43 if not os.path.exists(test_exe_path): |
44 msg = pre + 'Unable to find %s' % test_exe_path | 44 msg = pre + 'Unable to find %s' % test_exe_path |
45 raise chromium_utils.PathNotFound(msg) | 45 raise chromium_utils.PathNotFound(msg) |
46 | 46 |
| 47 http_server = None |
| 48 if options.document_root: |
| 49 platform_util = google.platform_utils.PlatformUtility(build_dir) |
| 50 |
| 51 # Name the output directory for the exe, without its path or suffix. |
| 52 # e.g., chrome-release/httpd_logs/unit_tests/ |
| 53 test_exe_name = os.path.splitext(os.path.basename(test_exe_path))[0] |
| 54 output_dir = os.path.join(slave_utils.SlaveBaseDir(build_dir), |
| 55 'httpd_logs', |
| 56 test_exe_name) |
| 57 |
| 58 apache_config_dir = google.httpd_utils.ApacheConfigDir(build_dir) |
| 59 httpd_conf_path = os.path.join(apache_config_dir, 'httpd2_mac.conf') |
| 60 mime_types_path = os.path.join(apache_config_dir, 'mime.types') |
| 61 document_root = os.path.abspath(options.document_root) |
| 62 |
| 63 start_cmd = platform_util.GetStartHttpdCommand(output_dir, |
| 64 httpd_conf_path, |
| 65 mime_types_path, |
| 66 document_root) |
| 67 stop_cmd = platform_util.GetStopHttpdCommand() |
| 68 http_server = google.httpd_utils.ApacheHttpd(start_cmd, stop_cmd, [8000]) |
| 69 try: |
| 70 http_server.StartServer() |
| 71 except google.httpd_utils.HttpdNotStarted, e: |
| 72 raise google.httpd_utils.HttpdNotStarted('%s. See log file in %s' % |
| 73 (e, output_dir)) |
| 74 |
47 command = [test_exe_path] | 75 command = [test_exe_path] |
48 command.extend(args[1:]) | 76 command.extend(args[1:]) |
49 result = chromium_utils.RunCommand(command) | 77 result = chromium_utils.RunCommand(command) |
50 | 78 |
| 79 if options.document_root: |
| 80 http_server.StopServer() |
| 81 |
51 return result | 82 return result |
52 | 83 |
53 def main_linux(options, args): | 84 def main_linux(options, args): |
54 if len(args) < 1: | 85 if len(args) < 1: |
55 raise chromium_utils.MissingArgument('Usage: %s' % USAGE) | 86 raise chromium_utils.MissingArgument('Usage: %s' % USAGE) |
56 | 87 |
57 build_dir = os.path.normpath(os.path.abspath(options.build_dir)) | 88 build_dir = os.path.normpath(os.path.abspath(options.build_dir)) |
58 slave_name = slave_utils.SlaveBuildName(build_dir) | 89 slave_name = slave_utils.SlaveBuildName(build_dir) |
59 slave_utils.StartVirtualX(slave_name) | 90 slave_utils.StartVirtualX(slave_name) |
60 | 91 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 help='Start a local httpd server using the given ' | 194 help='Start a local httpd server using the given ' |
164 'document root, relative to the current dir') | 195 'document root, relative to the current dir') |
165 option_parser.add_option('', '--total-shards', dest='total_shards', | 196 option_parser.add_option('', '--total-shards', dest='total_shards', |
166 default=None, type="int", | 197 default=None, type="int", |
167 help='Number of shards to split this test into.') | 198 help='Number of shards to split this test into.') |
168 option_parser.add_option('', '--shard-index', dest='shard_index', | 199 option_parser.add_option('', '--shard-index', dest='shard_index', |
169 default=None, type="int", | 200 default=None, type="int", |
170 help='Shard to run. Must be between 1 and ' | 201 help='Shard to run. Must be between 1 and ' |
171 'total-shards.') | 202 'total-shards.') |
172 options, args = option_parser.parse_args() | 203 options, args = option_parser.parse_args() |
173 | 204 |
174 # Set the number of shards environement variables. | 205 # Set the number of shards environement variables. |
175 if options.total_shards and options.shard_index: | 206 if options.total_shards and options.shard_index: |
176 os.environ['GTEST_TOTAL_SHARDS'] = str(options.total_shards) | 207 os.environ['GTEST_TOTAL_SHARDS'] = str(options.total_shards) |
177 os.environ['GTEST_SHARD_INDEX'] = str(options.shard_index - 1) | 208 os.environ['GTEST_SHARD_INDEX'] = str(options.shard_index - 1) |
178 | 209 |
179 if sys.platform.startswith('darwin'): | 210 if sys.platform.startswith('darwin'): |
180 sys.exit(main_mac(options, args)) | 211 sys.exit(main_mac(options, args)) |
181 elif sys.platform == 'win32': | 212 elif sys.platform == 'win32': |
182 sys.exit(main_win(options, args)) | 213 sys.exit(main_win(options, args)) |
183 elif sys.platform == 'linux2': | 214 elif sys.platform == 'linux2': |
184 sys.exit(main_linux(options, args)) | 215 sys.exit(main_linux(options, args)) |
185 else: | 216 else: |
186 sys.stderr.write('Unknown sys.platform value %s\n' % repr(sys.platform)) | 217 sys.stderr.write('Unknown sys.platform value %s\n' % repr(sys.platform)) |
187 sys.exit(1) | 218 sys.exit(1) |
OLD | NEW |