| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Collect debug info for a test.""" | 5 """Collect debug info for a test.""" |
| 6 | 6 |
| 7 import datetime | 7 import datetime |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| 11 import shutil | 11 import shutil |
| 12 import string | 12 import string |
| 13 import subprocess | 13 import subprocess |
| 14 import tempfile | 14 import tempfile |
| 15 | 15 |
| 16 import cmd_helper | 16 from pylib import cmd_helper |
| 17 | 17 |
| 18 | 18 |
| 19 TOMBSTONE_DIR = '/data/tombstones/' | 19 TOMBSTONE_DIR = '/data/tombstones/' |
| 20 | 20 |
| 21 | 21 |
| 22 class GTestDebugInfo(object): | 22 class GTestDebugInfo(object): |
| 23 """A helper class to collect related debug information for a gtest. | 23 """A helper class to collect related debug information for a gtest. |
| 24 | 24 |
| 25 Debug info is collected in two steps: | 25 Debug info is collected in two steps: |
| 26 - first, object(s) of this class (one per device), accumulate logs | 26 - first, object(s) of this class (one per device), accumulate logs |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 os.path.splitext(log_basename)[0] + '.zip') | 187 os.path.splitext(log_basename)[0] + '.zip') |
| 188 logging.info('Zipping debug dumps into %s ...', log_zip_file) | 188 logging.info('Zipping debug dumps into %s ...', log_zip_file) |
| 189 # Add new dumps into the zip file. The zip may exist already if previous | 189 # Add new dumps into the zip file. The zip may exist already if previous |
| 190 # gtest also dumps the debug information. It's OK since we clean up the old | 190 # gtest also dumps the debug information. It's OK since we clean up the old |
| 191 # dumps in each build step. | 191 # dumps in each build step. |
| 192 log_src_dir = os.path.join(tempfile.gettempdir(), 'gtest_debug_info') | 192 log_src_dir = os.path.join(tempfile.gettempdir(), 'gtest_debug_info') |
| 193 cmd_helper.RunCmd(['zip', '-q', '-r', log_zip_file, log_src_dir]) | 193 cmd_helper.RunCmd(['zip', '-q', '-r', log_zip_file, log_src_dir]) |
| 194 assert os.path.exists(log_zip_file) | 194 assert os.path.exists(log_zip_file) |
| 195 assert os.path.exists(log_src_dir) | 195 assert os.path.exists(log_src_dir) |
| 196 shutil.rmtree(log_src_dir) | 196 shutil.rmtree(log_src_dir) |
| OLD | NEW |