OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2008 the V8 project authors. All rights reserved. | 3 # Copyright 2008 the V8 project authors. All rights reserved. |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 INITIAL_SLEEP_TIME = 0.0001 | 455 INITIAL_SLEEP_TIME = 0.0001 |
456 SLEEP_TIME_FACTOR = 1.25 | 456 SLEEP_TIME_FACTOR = 1.25 |
457 | 457 |
458 SEM_INVALID_VALUE = -1 | 458 SEM_INVALID_VALUE = -1 |
459 SEM_NOGPFAULTERRORBOX = 0x0002 # Microsoft Platform SDK WinBase.h | 459 SEM_NOGPFAULTERRORBOX = 0x0002 # Microsoft Platform SDK WinBase.h |
460 | 460 |
461 def Win32SetErrorMode(mode): | 461 def Win32SetErrorMode(mode): |
462 prev_error_mode = SEM_INVALID_VALUE | 462 prev_error_mode = SEM_INVALID_VALUE |
463 try: | 463 try: |
464 import ctypes | 464 import ctypes |
465 prev_error_mode = ctypes.windll.kernel32.SetErrorMode(mode); | 465 prev_error_mode = ctypes.windll.kernel32.SetErrorMode(mode) |
466 except ImportError: | 466 except ImportError: |
467 pass | 467 pass |
468 return prev_error_mode | 468 return prev_error_mode |
469 | 469 |
470 def RunProcess(context, timeout, args, **rest): | 470 def RunProcess(context, timeout, args, **rest): |
471 if context.verbose: print "#", " ".join(args) | 471 if context.verbose: print "#", " ".join(args) |
472 popen_args = args | 472 popen_args = args |
473 prev_error_mode = SEM_INVALID_VALUE; | 473 prev_error_mode = SEM_INVALID_VALUE |
474 if utils.IsWindows(): | 474 if utils.IsWindows(): |
475 popen_args = '"' + subprocess.list2cmdline(args) + '"' | 475 popen_args = '"' + subprocess.list2cmdline(args) + '"' |
476 if context.suppress_dialogs: | 476 if context.suppress_dialogs: |
477 # Try to change the error mode to avoid dialogs on fatal errors. Don't | 477 # Try to change the error mode to avoid dialogs on fatal errors. Don't |
478 # touch any existing error mode flags by merging the existing error mode. | 478 # touch any existing error mode flags by merging the existing error mode. |
479 # See http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx. | 479 # See http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx. |
480 error_mode = SEM_NOGPFAULTERRORBOX; | 480 error_mode = SEM_NOGPFAULTERRORBOX |
481 prev_error_mode = Win32SetErrorMode(error_mode); | 481 prev_error_mode = Win32SetErrorMode(error_mode) |
482 Win32SetErrorMode(error_mode | prev_error_mode); | 482 Win32SetErrorMode(error_mode | prev_error_mode) |
483 process = subprocess.Popen( | 483 process = subprocess.Popen( |
484 shell = utils.IsWindows(), | 484 shell = utils.IsWindows(), |
485 args = popen_args, | 485 args = popen_args, |
486 **rest | 486 **rest |
487 ) | 487 ) |
488 if utils.IsWindows() and context.suppress_dialogs and prev_error_mode != SEM_I
NVALID_VALUE: | 488 if utils.IsWindows() and context.suppress_dialogs and prev_error_mode != SEM_I
NVALID_VALUE: |
489 Win32SetErrorMode(prev_error_mode) | 489 Win32SetErrorMode(prev_error_mode) |
490 # Compute the end time - if the process crosses this limit we | 490 # Compute the end time - if the process crosses this limit we |
491 # consider it timed out. | 491 # consider it timed out. |
492 if timeout is None: end_time = None | 492 if timeout is None: end_time = None |
(...skipping 27 matching lines...) Expand all Loading... |
520 # On Windows, when run with -jN in parallel processes, | 520 # On Windows, when run with -jN in parallel processes, |
521 # OS often fails to unlink the temp file. Not sure why. | 521 # OS often fails to unlink the temp file. Not sure why. |
522 # Need to retry. | 522 # Need to retry. |
523 # Idea from https://bugs.webkit.org/attachment.cgi?id=75982&action=prettypatch | 523 # Idea from https://bugs.webkit.org/attachment.cgi?id=75982&action=prettypatch |
524 retry_count = 0 | 524 retry_count = 0 |
525 while retry_count < 30: | 525 while retry_count < 30: |
526 try: | 526 try: |
527 os.unlink(name) | 527 os.unlink(name) |
528 return | 528 return |
529 except OSError, e: | 529 except OSError, e: |
530 retry_count += 1; | 530 retry_count += 1 |
531 time.sleep(retry_count * 0.1) | 531 time.sleep(retry_count * 0.1) |
532 PrintError("os.unlink() " + str(e)) | 532 PrintError("os.unlink() " + str(e)) |
533 | 533 |
534 def Execute(args, context, timeout=None): | 534 def Execute(args, context, timeout=None): |
535 (fd_out, outname) = tempfile.mkstemp() | 535 (fd_out, outname) = tempfile.mkstemp() |
536 (fd_err, errname) = tempfile.mkstemp() | 536 (fd_err, errname) = tempfile.mkstemp() |
537 (process, exit_code, timed_out) = RunProcess( | 537 (process, exit_code, timed_out) = RunProcess( |
538 context, | 538 context, |
539 timeout, | 539 timeout, |
540 args = args, | 540 args = args, |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 for entry in timed_tests[:20]: | 1497 for entry in timed_tests[:20]: |
1498 t = FormatTime(entry.duration) | 1498 t = FormatTime(entry.duration) |
1499 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel())) | 1499 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel())) |
1500 index += 1 | 1500 index += 1 |
1501 | 1501 |
1502 return result | 1502 return result |
1503 | 1503 |
1504 | 1504 |
1505 if __name__ == '__main__': | 1505 if __name__ == '__main__': |
1506 sys.exit(Main()) | 1506 sys.exit(Main()) |
OLD | NEW |