Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 (sandbox_stat.st_uid == 0)): | 78 (sandbox_stat.st_uid == 0)): |
| 79 return True | 79 return True |
| 80 return False | 80 return False |
| 81 | 81 |
| 82 | 82 |
| 83 def get_temp_count(): | 83 def get_temp_count(): |
| 84 """Returns the number of files and directories inside the temporary dir.""" | 84 """Returns the number of files and directories inside the temporary dir.""" |
| 85 return len(os.listdir(tempfile.gettempdir())) | 85 return len(os.listdir(tempfile.gettempdir())) |
| 86 | 86 |
| 87 | 87 |
| 88 def _DoDBusWorkaround(): | |
|
ghost stip (do not use)
2013/10/25 18:41:27
can we just call this LaunchDBus()?
Ken Russell (switch to Gerrit)
2013/10/25 19:07:12
Sure, done.
| |
| 89 """Works around a bug in GLib where it performs operations which | |
|
ghost stip (do not use)
2013/10/25 18:41:27
"""Launches DBus to work around bug in GLib.
Rest
Ken Russell (switch to Gerrit)
2013/10/25 19:07:12
Done.
| |
| 90 aren't async-signal-safe (in particular, memory allocations) between | |
| 91 fork and exec when it spawns subprocesses. This causes threads | |
| 92 inside Chrome's browser and utility processes to get stuck, and this | |
| 93 harness to hang waiting for those processes, which will never | |
| 94 terminate. This doesn't happen on users' machines, because they have | |
| 95 an active desktop session and the DBUS_SESSION_BUS_ADDRESS | |
| 96 environment variable set, but it does happen on the bots. See Issue | |
| 97 309093 for more details.""" | |
| 98 import platform | |
| 99 import subprocess | |
| 100 if (platform.uname()[0].lower() == 'linux' and | |
|
ghost stip (do not use)
2013/10/25 18:41:27
another option is to only call this in main_linux,
Ken Russell (switch to Gerrit)
2013/10/25 19:07:12
I like having this here because it should be done
| |
| 101 'DBUS_SESSION_BUS_ADDRESS' not in os.environ): | |
| 102 try: | |
| 103 dbus_output = subprocess.check_output(['dbus-launch']).split('\n') | |
|
ghost stip (do not use)
2013/10/25 18:41:27
put a message here: 'DBUS_SESSION_BUS_ADDRESS not
ghost stip (do not use)
2013/10/25 18:41:27
I'm assuming dbus-launch daemonizes here, otherwis
Ken Russell (switch to Gerrit)
2013/10/25 19:07:12
dbus-launch is synchronous. It runs and exits with
Ken Russell (switch to Gerrit)
2013/10/25 19:07:12
Done.
| |
| 104 for line in dbus_output: | |
| 105 m = re.match(r"([^=]+)\=(.+)", line) | |
| 106 if m: | |
| 107 os.environ[m.group(1)] = m.group(2) | |
|
ghost stip (do not use)
2013/10/25 18:41:27
output to stdout 'setting %s to %s' % (m.group(1),
Ken Russell (switch to Gerrit)
2013/10/25 19:07:12
Thanks, I had this before but took it out. Done.
| |
| 108 except: # pylint: disable=W0702 | |
| 109 pass | |
|
ghost stip (do not use)
2013/10/25 18:41:27
what exception are you expecting here? if it's tha
Ken Russell (switch to Gerrit)
2013/10/25 19:07:12
subprocess.check_output raises CalledProcessError
Ken Russell (switch to Gerrit)
2013/10/25 19:12:16
Sorry, I lied, and made this catch subprocess.Call
| |
| 110 | |
| 88 def _RunGTestCommand(command, results_tracker=None, pipes=None, | 111 def _RunGTestCommand(command, results_tracker=None, pipes=None, |
| 89 extra_env=None): | 112 extra_env=None): |
| 90 | 113 |
| 91 env = os.environ.copy() | 114 env = os.environ.copy() |
| 92 env.update(extra_env or {}) | 115 env.update(extra_env or {}) |
| 93 | 116 |
| 94 if results_tracker: | 117 if results_tracker: |
| 95 return chromium_utils.RunCommand( | 118 return chromium_utils.RunCommand( |
| 96 command, pipes=pipes, parser_func=results_tracker.ProcessLine, env=env) | 119 command, pipes=pipes, parser_func=results_tracker.ProcessLine, env=env) |
| 97 else: | 120 else: |
| (...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1210 default='supplemental_columns', | 1233 default='supplemental_columns', |
| 1211 help='A file containing a JSON blob with a dict ' | 1234 help='A file containing a JSON blob with a dict ' |
| 1212 'that will be uploaded to the results ' | 1235 'that will be uploaded to the results ' |
| 1213 'dashboard as supplemental columns.') | 1236 'dashboard as supplemental columns.') |
| 1214 option_parser.add_option('', '--enable-lsan', default=False, | 1237 option_parser.add_option('', '--enable-lsan', default=False, |
| 1215 help='Enable memory leak detection (LeakSanitizer). ' | 1238 help='Enable memory leak detection (LeakSanitizer). ' |
| 1216 'Also can be enabled with the factory ' | 1239 'Also can be enabled with the factory ' |
| 1217 'properties "lsan" and "lsan_run_all_tests".') | 1240 'properties "lsan" and "lsan_run_all_tests".') |
| 1218 option_parser.add_option('', '--extra-sharding-args', default='', | 1241 option_parser.add_option('', '--extra-sharding-args', default='', |
| 1219 help='Extra options for run_test_cases.py.') | 1242 help='Extra options for run_test_cases.py.') |
| 1243 option_parser.add_option('--do-dbus-workaround', action='store_true', | |
|
ghost stip (do not use)
2013/10/25 18:41:27
--spawn-dbus
| |
| 1244 default=False, | |
| 1245 help='Work around GLib DBus bug by ' | |
| 1246 'manually spawning dbus-launch') | |
| 1220 | 1247 |
| 1221 chromium_utils.AddPropertiesOptions(option_parser) | 1248 chromium_utils.AddPropertiesOptions(option_parser) |
| 1222 options, args = option_parser.parse_args() | 1249 options, args = option_parser.parse_args() |
| 1223 if not options.perf_dashboard_id: | 1250 if not options.perf_dashboard_id: |
| 1224 options.perf_dashboard_id = options.factory_properties.get('test_name') | 1251 options.perf_dashboard_id = options.factory_properties.get('test_name') |
| 1225 | 1252 |
| 1226 options.test_type = options.test_type or options.factory_properties.get( | 1253 options.test_type = options.test_type or options.factory_properties.get( |
| 1227 'step_name', '') | 1254 'step_name', '') |
| 1228 | 1255 |
| 1229 if options.run_shell_script and options.run_python_script: | 1256 if options.run_shell_script and options.run_python_script: |
| 1230 sys.stderr.write('Use either --run-shell-script OR --run-python-script, ' | 1257 sys.stderr.write('Use either --run-shell-script OR --run-python-script, ' |
| 1231 'not both.') | 1258 'not both.') |
| 1232 return 1 | 1259 return 1 |
| 1233 | 1260 |
| 1234 # Print out builder name for log_parser | 1261 # Print out builder name for log_parser |
| 1235 print '[Running on builder: "%s"]' % options.builder_name | 1262 print '[Running on builder: "%s"]' % options.builder_name |
| 1236 | 1263 |
| 1264 if options.do_dbus_workaround: | |
| 1265 _DoDBusWorkaround() | |
| 1266 | |
| 1237 # TODO(thakis): Simplify this once ConvertBuildDirToLegacy() ignores its | 1267 # TODO(thakis): Simplify this once ConvertBuildDirToLegacy() ignores its |
| 1238 # arguments. | 1268 # arguments. |
| 1239 use_out = False | 1269 use_out = False |
| 1240 if sys.platform == 'darwin': | 1270 if sys.platform == 'darwin': |
| 1241 use_out = (options.factory_properties.get('gclient_env', {}) | 1271 use_out = (options.factory_properties.get('gclient_env', {}) |
| 1242 .get('GYP_GENERATORS', '') in ('ninja', 'make')) | 1272 .get('GYP_GENERATORS', '') in ('ninja', 'make')) |
| 1243 elif sys.platform != 'win32': | 1273 elif sys.platform != 'win32': |
| 1244 use_out = os.path.exists( | 1274 use_out = os.path.exists( |
| 1245 os.path.join(os.path.dirname(options.build_dir), 'out')) | 1275 os.path.join(os.path.dirname(options.build_dir), 'out')) |
| 1246 options.build_dir, _ = build_directory.ConvertBuildDirToLegacy( | 1276 options.build_dir, _ = build_directory.ConvertBuildDirToLegacy( |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1386 '%d new files were left in %s: Fix the tests to clean up themselves.' | 1416 '%d new files were left in %s: Fix the tests to clean up themselves.' |
| 1387 ) % ((new_temp_files - temp_files), tempfile.gettempdir()) | 1417 ) % ((new_temp_files - temp_files), tempfile.gettempdir()) |
| 1388 # TODO(maruel): Make it an error soon. Not yet since I want to iron out all | 1418 # TODO(maruel): Make it an error soon. Not yet since I want to iron out all |
| 1389 # the remaining cases before. | 1419 # the remaining cases before. |
| 1390 #result = 1 | 1420 #result = 1 |
| 1391 return result | 1421 return result |
| 1392 | 1422 |
| 1393 | 1423 |
| 1394 if '__main__' == __name__: | 1424 if '__main__' == __name__: |
| 1395 sys.exit(main()) | 1425 sys.exit(main()) |
| OLD | NEW |