OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2012 The Swarming Authors. All rights reserved. | 2 # Copyright 2012 The Swarming Authors. All rights reserved. |
3 # Use of this source code is governed under the Apache License, Version 2.0 that | 3 # Use of this source code is governed under the Apache License, Version 2.0 that |
4 # can be found in the LICENSE file. | 4 # can be found in the LICENSE file. |
5 | 5 |
6 """Reads a .isolated, creates a tree of hardlinks and runs the test. | 6 """Reads a .isolated, creates a tree of hardlinks and runs the test. |
7 | 7 |
8 To improve performance, it keeps a local cache. The local cache can safely be | 8 To improve performance, it keeps a local cache. The local cache can safely be |
9 deleted. | 9 deleted. |
10 | 10 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 # hard_timed_out will be set but the process exit code will be | 188 # hard_timed_out will be set but the process exit code will be |
189 # script provided. | 189 # script provided. |
190 # - processed exited late, exit code will be -9 on posix. | 190 # - processed exited late, exit code will be -9 on posix. |
191 logging.warning('Grace exhausted; sending SIGKILL') | 191 logging.warning('Grace exhausted; sending SIGKILL') |
192 proc.kill() | 192 proc.kill() |
193 logging.info('Waiting for proces exit') | 193 logging.info('Waiting for proces exit') |
194 exit_code = proc.wait() | 194 exit_code = proc.wait() |
195 except OSError: | 195 except OSError: |
196 # This is not considered to be an internal error. The executable simply | 196 # This is not considered to be an internal error. The executable simply |
197 # does not exit. | 197 # does not exit. |
198 sys.stderr.write( | |
199 '<The executable does not exist or a dependent library is missing>\n' | |
tandrii(chromium)
2016/02/24 18:45:59
does this "<" have a special meaning?
M-A Ruel
2016/02/24 19:03:14
No, I just wanted the output to look special.
| |
200 '<Check for missing .so/.dll in the .isolate or GN file>\n' | |
201 '<Command: %s>\n' % command) | |
202 if os.environ.get('SWARMING_TASK_ID'): | |
203 # Give an additional hint when running as a swarming task. | |
204 sys.stderr.write( | |
205 '<See the task\'s page for commands to help diagnose this issue ' | |
206 'by reproducing the task locally>\n') | |
198 exit_code = 1 | 207 exit_code = 1 |
199 logging.info( | 208 logging.info( |
200 'Command finished with exit code %d (%s)', | 209 'Command finished with exit code %d (%s)', |
201 exit_code, hex(0xffffffff & exit_code)) | 210 exit_code, hex(0xffffffff & exit_code)) |
202 return exit_code, had_hard_timeout | 211 return exit_code, had_hard_timeout |
203 | 212 |
204 | 213 |
205 def delete_and_upload(storage, out_dir, leak_temp_dir): | 214 def delete_and_upload(storage, out_dir, leak_temp_dir): |
206 """Deletes the temporary run directory and uploads results back. | 215 """Deletes the temporary run directory and uploads results back. |
207 | 216 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 if not fs.isdir(root_dir): | 273 if not fs.isdir(root_dir): |
265 fs.makedirs(root_dir, 0700) | 274 fs.makedirs(root_dir, 0700) |
266 prefix = u'' | 275 prefix = u'' |
267 else: | 276 else: |
268 root_dir = os.path.dirname(cache.cache_dir) if cache.cache_dir else None | 277 root_dir = os.path.dirname(cache.cache_dir) if cache.cache_dir else None |
269 prefix = u'isolated_' | 278 prefix = u'isolated_' |
270 run_dir = make_temp_dir(prefix + u'run', root_dir) | 279 run_dir = make_temp_dir(prefix + u'run', root_dir) |
271 out_dir = make_temp_dir(prefix + u'out', root_dir) | 280 out_dir = make_temp_dir(prefix + u'out', root_dir) |
272 tmp_dir = make_temp_dir(prefix + u'tmp', root_dir) | 281 tmp_dir = make_temp_dir(prefix + u'tmp', root_dir) |
273 try: | 282 try: |
274 bundle = isolateserver.fetch_isolated( | 283 try: |
275 isolated_hash=isolated_hash, | 284 bundle = isolateserver.fetch_isolated( |
276 storage=storage, | 285 isolated_hash=isolated_hash, |
277 cache=cache, | 286 storage=storage, |
278 outdir=run_dir, | 287 cache=cache, |
279 require_command=True) | 288 outdir=run_dir, |
289 require_command=True) | |
290 except isolateserver.IsolatedErrorNoCommand: | |
291 # Handle this as a task failure, not an internal failure. | |
292 sys.stderr.write( | |
293 '<The .isolated doesn\'t declare any command to run!>\n' | |
294 '<Check your .isolate for missing \'command\' variable>\n') | |
295 if os.environ.get('SWARMING_TASK_ID'): | |
296 # Give an additional hint when running as a swarming task. | |
297 sys.stderr.write('<This occurs at the \'isolate\' step\n') | |
tandrii(chromium)
2016/02/24 18:45:59
missing '>' before \n
M-A Ruel
2016/02/24 19:03:14
Done.
| |
298 result['exit_code'] = 1 | |
299 return result | |
280 | 300 |
281 change_tree_read_only(run_dir, bundle.read_only) | 301 change_tree_read_only(run_dir, bundle.read_only) |
282 cwd = os.path.normpath(os.path.join(run_dir, bundle.relative_cwd)) | 302 cwd = os.path.normpath(os.path.join(run_dir, bundle.relative_cwd)) |
283 command = bundle.command + extra_args | 303 command = bundle.command + extra_args |
284 file_path.ensure_command_has_abs_path(command, cwd) | 304 file_path.ensure_command_has_abs_path(command, cwd) |
285 result['exit_code'], result['had_hard_timeout'] = run_command( | 305 result['exit_code'], result['had_hard_timeout'] = run_command( |
286 process_command(command, out_dir), cwd, tmp_dir, hard_timeout, | 306 process_command(command, out_dir), cwd, tmp_dir, hard_timeout, |
287 grace_period) | 307 grace_period) |
288 except Exception as e: | 308 except Exception as e: |
289 # An internal error occured. Report accordingly so the swarming task will be | 309 # An internal error occured. Report accordingly so the swarming task will be |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 assert storage.hash_algo == cache.hash_algo | 490 assert storage.hash_algo == cache.hash_algo |
471 return run_tha_test( | 491 return run_tha_test( |
472 options.isolated, storage, cache, options.leak_temp_dir, options.json, | 492 options.isolated, storage, cache, options.leak_temp_dir, options.json, |
473 options.root_dir, options.hard_timeout, options.grace_period, args) | 493 options.root_dir, options.hard_timeout, options.grace_period, args) |
474 | 494 |
475 | 495 |
476 if __name__ == '__main__': | 496 if __name__ == '__main__': |
477 # Ensure that we are always running with the correct encoding. | 497 # Ensure that we are always running with the correct encoding. |
478 fix_encoding.fix_encoding() | 498 fix_encoding.fix_encoding() |
479 sys.exit(main(sys.argv[1:])) | 499 sys.exit(main(sys.argv[1:])) |
OLD | NEW |