| OLD | NEW |
| 1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
| 3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 # This file contains a set of utilities functions used by other Python-based | 5 # This file contains a set of utilities functions used by other Python-based |
| 6 # scripts. | 6 # scripts. |
| 7 | 7 |
| 8 import commands | 8 import commands |
| 9 import contextlib | 9 import contextlib |
| 10 import datetime | 10 import datetime |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 | 695 |
| 696 class UnexpectedCrash(object): | 696 class UnexpectedCrash(object): |
| 697 def __init__(self, test, pid, binary): | 697 def __init__(self, test, pid, binary): |
| 698 self.test = test | 698 self.test = test |
| 699 self.pid = pid | 699 self.pid = pid |
| 700 self.binary = binary | 700 self.binary = binary |
| 701 | 701 |
| 702 def __str__(self): | 702 def __str__(self): |
| 703 return "%s: %s %s" % (self.test, self.binary, self.pid) | 703 return "%s: %s %s" % (self.test, self.binary, self.pid) |
| 704 | 704 |
| 705 class SiteConfigBotoFileDisabler(object): |
| 706 def __init__(self): |
| 707 self._old_aws = None |
| 708 self._old_boto = None |
| 709 |
| 710 def __enter__(self): |
| 711 self._old_aws = os.environ.get('AWS_CREDENTIAL_FILE', None) |
| 712 self._old_boto = os.environ.get('BOTO_CONFIG', None) |
| 713 |
| 714 if self._old_aws: |
| 715 del os.environ['AWS_CREDENTIAL_FILE'] |
| 716 if self._old_boto: |
| 717 del os.environ['BOTO_CONFIG'] |
| 718 |
| 719 def __exit__(self, *_): |
| 720 if self._old_aws: |
| 721 os.environ['AWS_CREDENTIAL_FILE'] = self._old_aws |
| 722 if self._old_boto: |
| 723 os.environ['BOTO_CONFIG'] = self._old_boto |
| 705 | 724 |
| 706 class PosixCoredumpEnabler(object): | 725 class PosixCoredumpEnabler(object): |
| 707 def __init__(self): | 726 def __init__(self): |
| 708 self._old_limits = None | 727 self._old_limits = None |
| 709 | 728 |
| 710 def __enter__(self): | 729 def __enter__(self): |
| 711 self._old_limits = resource.getrlimit(resource.RLIMIT_CORE) | 730 self._old_limits = resource.getrlimit(resource.RLIMIT_CORE) |
| 712 | 731 |
| 713 # Bump core limits to unlimited if core_pattern is correctly configured. | 732 # Bump core limits to unlimited if core_pattern is correctly configured. |
| 714 if CheckLinuxCoreDumpPattern(fatal=False): | 733 if CheckLinuxCoreDumpPattern(fatal=False): |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 try: | 844 try: |
| 826 crashes = self._find_unexpected_crashes() | 845 crashes = self._find_unexpected_crashes() |
| 827 if crashes: | 846 if crashes: |
| 828 # If we get a ton of crashes, only archive 10 dumps. | 847 # If we get a ton of crashes, only archive 10 dumps. |
| 829 archive_crashes = crashes[:10] | 848 archive_crashes = crashes[:10] |
| 830 print 'Archiving coredumps for crash (if possible):' | 849 print 'Archiving coredumps for crash (if possible):' |
| 831 for crash in archive_crashes: | 850 for crash in archive_crashes: |
| 832 print '----> %s' % crash | 851 print '----> %s' % crash |
| 833 | 852 |
| 834 sys.stdout.flush() | 853 sys.stdout.flush() |
| 835 self._archive(archive_crashes) | |
| 836 | 854 |
| 855 # We disable usage of the boto file installed on the bots due to an |
| 856 # issue introduced by |
| 857 # https://chrome-internal-review.googlesource.com/c/331136 |
| 858 with SiteConfigBotoFileDisabler(): |
| 859 self._archive(archive_crashes) |
| 837 finally: | 860 finally: |
| 838 self._cleanup() | 861 self._cleanup() |
| 839 | 862 |
| 840 def _archive(self, crashes): | 863 def _archive(self, crashes): |
| 841 files = set() | 864 files = set() |
| 842 missing = [] | 865 missing = [] |
| 843 for crash in crashes: | 866 for crash in crashes: |
| 844 files.add(crash.binary) | 867 files.add(crash.binary) |
| 845 core = self._find_coredump_file(crash) | 868 core = self._find_coredump_file(crash) |
| 846 if core: | 869 if core: |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 return contextlib.nested(WindowsCoredumpEnabler(), | 986 return contextlib.nested(WindowsCoredumpEnabler(), |
| 964 WindowsCoreDumpArchiver()) | 987 WindowsCoreDumpArchiver()) |
| 965 else: | 988 else: |
| 966 # We don't have support for MacOS yet. | 989 # We don't have support for MacOS yet. |
| 967 assert osname == 'macos' | 990 assert osname == 'macos' |
| 968 return NooptCoreDumpArchiver() | 991 return NooptCoreDumpArchiver() |
| 969 | 992 |
| 970 if __name__ == "__main__": | 993 if __name__ == "__main__": |
| 971 import sys | 994 import sys |
| 972 Main() | 995 Main() |
| OLD | NEW |