def get_port(self, target=None, configuration=None, files=None): host = MockHost() wkf = WebKitFinder(host.filesystem) files = files or {} for path, contents in files.items(): host.filesystem.write_text_file(wkf.path_from_chromium_base(path), contents) options = optparse.Values({'target': target, 'configuration': configuration}) return factory.PortFactory(host).get(options=options)
def get_port(self, target=None, configuration=None, files=None): host = MockHost() wkf = WebKitFinder(host.filesystem) files = files or {} for path, contents in files.items(): host.filesystem.write_text_file(wkf.path_from_chromium_base(path), contents) options = MockOptions(target=target, configuration=configuration) return factory.PortFactory(host).get(options=options)
def get_port(self, target=None, configuration=None, files=None): host = MockSystemHost() wkf = WebKitFinder(host.filesystem) files = files or {} for path, contents in files.items(): host.filesystem.write_text_file(wkf.path_from_chromium_base(path), contents) options = MockOptions(target=target, configuration=configuration) return factory.PortFactory(host).get(options=options)
def run_pylint(self, path): wkf = WebKitFinder(FileSystem()) executive = Executive() env = os.environ.copy() env['PYTHONPATH'] = os.pathsep.join([ wkf.path_from_webkit_base('Tools', 'Scripts'), wkf.path_from_webkit_base('Source', 'build', 'scripts'), wkf.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'thirdparty'), wkf.path_from_webkit_base('Source', 'bindings', 'scripts'), wkf.path_from_chromium_base('build', 'android'), wkf.path_from_chromium_base('third_party', 'catapult', 'devil'), wkf.path_from_chromium_base('third_party', 'pymock'), ]) return executive.run_command([ sys.executable, wkf.path_from_depot_tools_base('pylint.py'), '--output-format=parseable', '--rcfile=' + wkf.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'pylintrc'), path, ], env=env, error_handler=executive.ignore_error)
class DumpReaderMultipart(DumpReader): """Base class for Linux and Android breakpad dump reader.""" def __init__(self, host, build_dir): super(DumpReaderMultipart, self).__init__(host, build_dir) self._webkit_finder = WebKitFinder(host.filesystem) self._breakpad_tools_available = None self._generated_symbols = False def check_is_functional(self): return self._check_breakpad_tools_available() def _get_pid_from_dump(self, dump_file): dump = self._read_dump(dump_file) if not dump: return None if 'pid' in dump: return dump['pid'][0] return None def _get_stack_from_dump(self, dump_file): dump = self._read_dump(dump_file) if not dump: return None if not 'upload_file_minidump' in dump: return None self._generate_breakpad_symbols_if_necessary() f, temp_name = self._host.filesystem.open_binary_tempfile('dmp') f.write("\r\n".join(dump['upload_file_minidump'])) f.close() cmd = [self._path_to_minidump_stackwalk(), temp_name, self._symbols_dir()] try: stack = self._host.executive.run_command(cmd, return_stderr=False) except: _log.warning('Failed to execute "%s"' % ' '.join(cmd)) stack = None finally: self._host.filesystem.remove(temp_name) return stack def _read_dump(self, dump_file): with self._host.filesystem.open_binary_file_for_reading(dump_file) as f: boundary = f.readline().strip()[2:] f.seek(0) try: data = cgi.parse_multipart(f, {'boundary': boundary}) return data except: pass return None def _check_breakpad_tools_available(self): if self._breakpad_tools_available != None: return self._breakpad_tools_available REQUIRED_BREAKPAD_TOOLS = [ 'dump_syms', 'minidump_stackwalk', ] result = True for binary in REQUIRED_BREAKPAD_TOOLS: full_path = self._host.filesystem.join(self._build_dir, binary) if not self._host.filesystem.exists(full_path): result = False _log.error('Unable to find %s' % binary) _log.error(' at %s' % full_path) if not result: _log.error(" Could not find breakpad tools, unexpected crashes won't be symbolized") _log.error(' Did you build the target blink_tests?') _log.error('') self._breakpad_tools_available = result return self._breakpad_tools_available def _path_to_minidump_stackwalk(self): return self._host.filesystem.join(self._build_dir, "minidump_stackwalk") def _path_to_generate_breakpad_symbols(self): return self._webkit_finder.path_from_chromium_base("components", "crash", "content", "tools", "generate_breakpad_symbols.py") def _symbols_dir(self): return self._host.filesystem.join(self._build_dir, 'content_shell.syms') def _generate_breakpad_symbols_if_necessary(self): if self._generated_symbols: return self._generated_symbols = True _log.debug("Generating breakpad symbols") queue = Queue.Queue() thread = threading.Thread(target=_symbolize_keepalive, args=(queue,)) thread.start() try: for binary in self._binaries_to_symbolize(): _log.debug(' Symbolizing %s' % binary) full_path = self._host.filesystem.join(self._build_dir, binary) cmd = [ self._path_to_generate_breakpad_symbols(), '--binary=%s' % full_path, '--symbols-dir=%s' % self._symbols_dir(), '--build-dir=%s' % self._build_dir, ] try: self._host.executive.run_command(cmd) except: _log.error('Failed to execute "%s"' % ' '.join(cmd)) finally: queue.put(None) thread.join() _log.debug("Done generating breakpad symbols") def _binaries_to_symbolize(self): """This routine must be implemented by subclasses. Returns an array of binaries that need to be symbolized.""" raise NotImplementedError()
class DumpReaderMultipart(DumpReader): """Base class for Linux and Android breakpad dump reader.""" def __init__(self, host, build_dir): super(DumpReaderMultipart, self).__init__(host, build_dir) self._webkit_finder = WebKitFinder(host.filesystem) self._breakpad_tools_available = None self._generated_symbols = False def check_is_functional(self): return self._check_breakpad_tools_available() def _get_pid_from_dump(self, dump_file): dump = self._read_dump(dump_file) if not dump: return None if 'pid' in dump: return dump['pid'][0] return None def _get_stack_from_dump(self, dump_file): dump = self._read_dump(dump_file) if not dump: return None if not 'upload_file_minidump' in dump: return None self._generate_breakpad_symbols_if_necessary() f, temp_name = self._host.filesystem.open_binary_tempfile('dmp') f.write("\r\n".join(dump['upload_file_minidump'])) f.close() cmd = [ self._path_to_minidump_stackwalk(), temp_name, self._symbols_dir() ] try: stack = self._host.executive.run_command(cmd, return_stderr=False) except: _log.warning('Failed to execute "%s"' % ' '.join(cmd)) stack = None finally: self._host.filesystem.remove(temp_name) return stack def _read_dump(self, dump_file): with self._host.filesystem.open_binary_file_for_reading( dump_file) as f: boundary = f.readline().strip()[2:] f.seek(0) try: data = cgi.parse_multipart(f, {'boundary': boundary}) return data except: pass return None def _check_breakpad_tools_available(self): if self._breakpad_tools_available != None: return self._breakpad_tools_available REQUIRED_BREAKPAD_TOOLS = [ 'dump_syms', 'minidump_stackwalk', ] result = True for binary in REQUIRED_BREAKPAD_TOOLS: full_path = self._host.filesystem.join(self._build_dir, binary) if not self._host.filesystem.exists(full_path): result = False _log.error('Unable to find %s' % binary) _log.error(' at %s' % full_path) if not result: _log.error( " Could not find breakpad tools, unexpected crashes won't be symbolized" ) _log.error(' Did you build the target blink_tests?') _log.error('') self._breakpad_tools_available = result return self._breakpad_tools_available def _path_to_minidump_stackwalk(self): return self._host.filesystem.join(self._build_dir, "minidump_stackwalk") def _path_to_generate_breakpad_symbols(self): return self._webkit_finder.path_from_chromium_base( "components", "crash", "tools", "generate_breakpad_symbols.py") def _symbols_dir(self): return self._host.filesystem.join(self._build_dir, 'content_shell.syms') def _generate_breakpad_symbols_if_necessary(self): if self._generated_symbols: return self._generated_symbols = True _log.debug("Generating breakpad symbols") queue = Queue.Queue() thread = threading.Thread(target=_symbolize_keepalive, args=(queue, )) thread.start() try: for binary in self._binaries_to_symbolize(): _log.debug(' Symbolizing %s' % binary) full_path = self._host.filesystem.join(self._build_dir, binary) cmd = [ self._path_to_generate_breakpad_symbols(), '--binary=%s' % full_path, '--symbols-dir=%s' % self._symbols_dir(), '--build-dir=%s' % self._build_dir, ] try: self._host.executive.run_command(cmd) except: _log.error('Failed to execute "%s"' % ' '.join(cmd)) finally: queue.put(None) thread.join() _log.debug("Done generating breakpad symbols") def _binaries_to_symbolize(self): """This routine must be implemented by subclasses. Returns an array of binaries that need to be symbolized.""" raise NotImplementedError()
def test_path_from_chromium_base(self): finder = WebKitFinder(MockFileSystem()) self.assertEqual( finder.path_from_chromium_base('foo', 'bar.baz'), '/mock-checkout/foo/bar.baz')
def test_path_from_chromium_base(self): finder = WebKitFinder(MockFileSystem()) self.assertEqual(finder.path_from_chromium_base('foo', 'bar.baz'), '/mock-checkout/foo/bar.baz')