Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: tools/telemetry/telemetry/internal/backends/chrome/desktop_browser_backend.py

Issue 1498633003: Added unit test for stack traces in telemetry crashes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Search for framework file Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 import datetime 5 import datetime
6 import glob 6 import glob
7 import heapq 7 import heapq
8 import logging 8 import logging
9 import os 9 import os
10 import os.path 10 import os.path
(...skipping 16 matching lines...) Expand all
27 27
28 28
29 def ParseCrashpadDateTime(date_time_str): 29 def ParseCrashpadDateTime(date_time_str):
30 # Python strptime does not support time zone parsing, strip it. 30 # Python strptime does not support time zone parsing, strip it.
31 date_time_parts = date_time_str.split() 31 date_time_parts = date_time_str.split()
32 if len(date_time_parts) >= 3: 32 if len(date_time_parts) >= 3:
33 date_time_str = ' '.join(date_time_parts[:2]) 33 date_time_str = ' '.join(date_time_parts[:2])
34 return datetime.datetime.strptime(date_time_str, '%Y-%m-%d %H:%M:%S') 34 return datetime.datetime.strptime(date_time_str, '%Y-%m-%d %H:%M:%S')
35 35
36 36
37 def GetSymbolBinary(executable, os_name):
38 # Returns binary file where symbols are located.
39 if os_name == 'mac':
40 version_dir = os.path.join(os.path.dirname(executable),
41 '..',
42 'Versions')
43 for version_num in os.listdir(version_dir):
44 framework_file = os.path.join(version_dir,
45 version_num,
46 'Chromium Framework.framework',
47 'Chromium Framework')
48 if os.path.isfile(framework_file):
49 return framework_file
50
51 return executable
52
53
37 class DesktopBrowserBackend(chrome_browser_backend.ChromeBrowserBackend): 54 class DesktopBrowserBackend(chrome_browser_backend.ChromeBrowserBackend):
38 """The backend for controlling a locally-executed browser instance, on Linux, 55 """The backend for controlling a locally-executed browser instance, on Linux,
39 Mac or Windows. 56 Mac or Windows.
40 """ 57 """
41 def __init__(self, desktop_platform_backend, browser_options, executable, 58 def __init__(self, desktop_platform_backend, browser_options, executable,
42 flash_path, is_content_shell, browser_directory, 59 flash_path, is_content_shell, browser_directory,
43 output_profile_path, extensions_to_load): 60 output_profile_path, extensions_to_load):
44 super(DesktopBrowserBackend, self).__init__( 61 super(DesktopBrowserBackend, self).__init__(
45 desktop_platform_backend, 62 desktop_platform_backend,
46 supports_tab_control=not is_content_shell, 63 supports_tab_control=not is_content_shell,
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 463
447 logging.info('Dumping breakpad symbols.') 464 logging.info('Dumping breakpad symbols.')
448 generate_breakpad_symbols_command = binary_manager.FetchPath( 465 generate_breakpad_symbols_command = binary_manager.FetchPath(
449 'generate_breakpad_symbols', arch_name, os_name) 466 'generate_breakpad_symbols', arch_name, os_name)
450 if generate_breakpad_symbols_command is None: 467 if generate_breakpad_symbols_command is None:
451 return 468 return
452 469
453 cmd = [ 470 cmd = [
454 sys.executable, 471 sys.executable,
455 generate_breakpad_symbols_command, 472 generate_breakpad_symbols_command,
456 '--binary=%s' % self._executable, 473 '--binary=%s' % GetSymbolBinary(self._executable,
474 self.browser.platform.GetOSName()),
457 '--symbols-dir=%s' % symbols_path, 475 '--symbols-dir=%s' % symbols_path,
458 '--build-dir=%s' % self._browser_directory, 476 '--build-dir=%s' % self._browser_directory,
459 ] 477 ]
460 478
461 try: 479 try:
462 subprocess.check_output(cmd, stderr=open(os.devnull, 'w')) 480 subprocess.check_output(cmd, stderr=open(os.devnull, 'w'))
463 except subprocess.CalledProcessError: 481 except subprocess.CalledProcessError:
464 logging.warning('Failed to execute "%s"' % ' '.join(cmd)) 482 logging.warning('Failed to execute "%s"' % ' '.join(cmd))
465 return 483 return
466 484
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 self._tmp_profile_dir) 561 self._tmp_profile_dir)
544 else: 562 else:
545 # If we don't need the profile after the run then cleanup. 563 # If we don't need the profile after the run then cleanup.
546 if self._tmp_profile_dir and os.path.exists(self._tmp_profile_dir): 564 if self._tmp_profile_dir and os.path.exists(self._tmp_profile_dir):
547 shutil.rmtree(self._tmp_profile_dir, ignore_errors=True) 565 shutil.rmtree(self._tmp_profile_dir, ignore_errors=True)
548 self._tmp_profile_dir = None 566 self._tmp_profile_dir = None
549 567
550 if self._tmp_output_file: 568 if self._tmp_output_file:
551 self._tmp_output_file.close() 569 self._tmp_output_file.close()
552 self._tmp_output_file = None 570 self._tmp_output_file = None
OLDNEW
« tools/perf/core/stacktrace_unittest.py ('K') | « tools/telemetry/telemetry/core/exceptions.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698