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 _LaunchDBus(): |
| 89 """Launches DBus to work around a bug in GLib. |
| 90 |
| 91 Works around a bug in GLib where it performs operations which aren't |
| 92 async-signal-safe (in particular, memory allocations) between fork |
| 93 and exec when it spawns subprocesses. This causes threads inside |
| 94 Chrome's browser and utility processes to get stuck, and this |
| 95 harness to hang waiting for those processes, which will never |
| 96 terminate. This doesn't happen on users' machines, because they have |
| 97 an active desktop session and the DBUS_SESSION_BUS_ADDRESS |
| 98 environment variable set, but it does happen on the bots. See Issue |
| 99 309093 for more details.""" |
| 100 import platform |
| 101 import subprocess |
| 102 if (platform.uname()[0].lower() == 'linux' and |
| 103 'DBUS_SESSION_BUS_ADDRESS' not in os.environ): |
| 104 try: |
| 105 print 'DBUS_SESSION_BUS_ADDRESS env var not found, starting dbus-launch' |
| 106 dbus_output = subprocess.check_output(['dbus-launch']).split('\n') |
| 107 for line in dbus_output: |
| 108 m = re.match(r"([^=]+)\=(.+)", line) |
| 109 if m: |
| 110 os.environ[m.group(1)] = m.group(2) |
| 111 print ' setting %s to %s' % (m.group(1), m.group(2)) |
| 112 except subprocess.CalledProcessError, e: |
| 113 print 'Exception while running dbus_launch: %s' % e |
| 114 |
88 def _RunGTestCommand(command, results_tracker=None, pipes=None, | 115 def _RunGTestCommand(command, results_tracker=None, pipes=None, |
89 extra_env=None): | 116 extra_env=None): |
90 | 117 |
91 env = os.environ.copy() | 118 env = os.environ.copy() |
92 env.update(extra_env or {}) | 119 env.update(extra_env or {}) |
93 | 120 |
94 if results_tracker: | 121 if results_tracker: |
95 return chromium_utils.RunCommand( | 122 return chromium_utils.RunCommand( |
96 command, pipes=pipes, parser_func=results_tracker.ProcessLine, env=env) | 123 command, pipes=pipes, parser_func=results_tracker.ProcessLine, env=env) |
97 else: | 124 else: |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 default='supplemental_columns', | 1237 default='supplemental_columns', |
1211 help='A file containing a JSON blob with a dict ' | 1238 help='A file containing a JSON blob with a dict ' |
1212 'that will be uploaded to the results ' | 1239 'that will be uploaded to the results ' |
1213 'dashboard as supplemental columns.') | 1240 'dashboard as supplemental columns.') |
1214 option_parser.add_option('', '--enable-lsan', default=False, | 1241 option_parser.add_option('', '--enable-lsan', default=False, |
1215 help='Enable memory leak detection (LeakSanitizer). ' | 1242 help='Enable memory leak detection (LeakSanitizer). ' |
1216 'Also can be enabled with the factory ' | 1243 'Also can be enabled with the factory ' |
1217 'properties "lsan" and "lsan_run_all_tests".') | 1244 'properties "lsan" and "lsan_run_all_tests".') |
1218 option_parser.add_option('', '--extra-sharding-args', default='', | 1245 option_parser.add_option('', '--extra-sharding-args', default='', |
1219 help='Extra options for run_test_cases.py.') | 1246 help='Extra options for run_test_cases.py.') |
| 1247 option_parser.add_option('--spawn-dbus', action='store_true', |
| 1248 default=False, |
| 1249 help='Work around GLib DBus bug by ' |
| 1250 'manually spawning dbus-launch') |
1220 | 1251 |
1221 chromium_utils.AddPropertiesOptions(option_parser) | 1252 chromium_utils.AddPropertiesOptions(option_parser) |
1222 options, args = option_parser.parse_args() | 1253 options, args = option_parser.parse_args() |
1223 if not options.perf_dashboard_id: | 1254 if not options.perf_dashboard_id: |
1224 options.perf_dashboard_id = options.factory_properties.get('test_name') | 1255 options.perf_dashboard_id = options.factory_properties.get('test_name') |
1225 | 1256 |
1226 options.test_type = options.test_type or options.factory_properties.get( | 1257 options.test_type = options.test_type or options.factory_properties.get( |
1227 'step_name', '') | 1258 'step_name', '') |
1228 | 1259 |
1229 if options.run_shell_script and options.run_python_script: | 1260 if options.run_shell_script and options.run_python_script: |
1230 sys.stderr.write('Use either --run-shell-script OR --run-python-script, ' | 1261 sys.stderr.write('Use either --run-shell-script OR --run-python-script, ' |
1231 'not both.') | 1262 'not both.') |
1232 return 1 | 1263 return 1 |
1233 | 1264 |
1234 # Print out builder name for log_parser | 1265 # Print out builder name for log_parser |
1235 print '[Running on builder: "%s"]' % options.builder_name | 1266 print '[Running on builder: "%s"]' % options.builder_name |
1236 | 1267 |
| 1268 if options.spawn_dbus: |
| 1269 _LaunchDBus() |
| 1270 |
1237 # TODO(thakis): Simplify this once ConvertBuildDirToLegacy() ignores its | 1271 # TODO(thakis): Simplify this once ConvertBuildDirToLegacy() ignores its |
1238 # arguments. | 1272 # arguments. |
1239 use_out = False | 1273 use_out = False |
1240 if sys.platform == 'darwin': | 1274 if sys.platform == 'darwin': |
1241 use_out = (options.factory_properties.get('gclient_env', {}) | 1275 use_out = (options.factory_properties.get('gclient_env', {}) |
1242 .get('GYP_GENERATORS', '') in ('ninja', 'make')) | 1276 .get('GYP_GENERATORS', '') in ('ninja', 'make')) |
1243 elif sys.platform != 'win32': | 1277 elif sys.platform != 'win32': |
1244 use_out = os.path.exists( | 1278 use_out = os.path.exists( |
1245 os.path.join(os.path.dirname(options.build_dir), 'out')) | 1279 os.path.join(os.path.dirname(options.build_dir), 'out')) |
1246 options.build_dir, _ = build_directory.ConvertBuildDirToLegacy( | 1280 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.' | 1420 '%d new files were left in %s: Fix the tests to clean up themselves.' |
1387 ) % ((new_temp_files - temp_files), tempfile.gettempdir()) | 1421 ) % ((new_temp_files - temp_files), tempfile.gettempdir()) |
1388 # TODO(maruel): Make it an error soon. Not yet since I want to iron out all | 1422 # TODO(maruel): Make it an error soon. Not yet since I want to iron out all |
1389 # the remaining cases before. | 1423 # the remaining cases before. |
1390 #result = 1 | 1424 #result = 1 |
1391 return result | 1425 return result |
1392 | 1426 |
1393 | 1427 |
1394 if '__main__' == __name__: | 1428 if '__main__' == __name__: |
1395 sys.exit(main()) | 1429 sys.exit(main()) |
OLD | NEW |