| OLD | NEW |
| 1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 def __init__(self, host, port_name, **kwargs): | 59 def __init__(self, host, port_name, **kwargs): |
| 60 super(LinuxPort, self).__init__(host, port_name, **kwargs) | 60 super(LinuxPort, self).__init__(host, port_name, **kwargs) |
| 61 self._version = port_name[port_name.index('linux-') + len('linux-'):] | 61 self._version = port_name[port_name.index('linux-') + len('linux-'):] |
| 62 self._architecture = 'x86_64' | 62 self._architecture = 'x86_64' |
| 63 assert self._version in self.SUPPORTED_VERSIONS | 63 assert self._version in self.SUPPORTED_VERSIONS |
| 64 | 64 |
| 65 if not self.get_option('disable_breakpad'): | 65 if not self.get_option('disable_breakpad'): |
| 66 self._dump_reader = DumpReaderLinux(host, self._build_path()) | 66 self._dump_reader = DumpReaderLinux(host, self._build_path()) |
| 67 self._original_home = None | 67 self._original_home = None |
| 68 self._original_display = None |
| 68 self._xvfb_process = None | 69 self._xvfb_process = None |
| 69 | 70 |
| 70 def additional_driver_flag(self): | 71 def additional_driver_flag(self): |
| 71 flags = super(LinuxPort, self).additional_driver_flag() | 72 flags = super(LinuxPort, self).additional_driver_flag() |
| 72 if not self.get_option('disable_breakpad'): | 73 if not self.get_option('disable_breakpad'): |
| 73 flags += ['--enable-crash-reporter', '--crash-dumps-dir=%s' % self._
dump_reader.crash_dumps_directory()] | 74 flags += ['--enable-crash-reporter', '--crash-dumps-dir=%s' % self._
dump_reader.crash_dumps_directory()] |
| 74 return flags | 75 return flags |
| 75 | 76 |
| 76 def check_build(self, needs_http, printer): | 77 def check_build(self, needs_http, printer): |
| 77 result = super(LinuxPort, self).check_build(needs_http, printer) | 78 result = super(LinuxPort, self).check_build(needs_http, printer) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return | 153 return |
| 153 | 154 |
| 154 _log.info('Starting Xvfb with display "%s".', display) | 155 _log.info('Starting Xvfb with display "%s".', display) |
| 155 self._xvfb_process = self.host.executive.popen( | 156 self._xvfb_process = self.host.executive.popen( |
| 156 ['Xvfb', display, '-screen', '0', '1280x800x24', '-ac', '-dpi', '96'
], | 157 ['Xvfb', display, '-screen', '0', '1280x800x24', '-ac', '-dpi', '96'
], |
| 157 stderr=self.host.executive.DEVNULL) | 158 stderr=self.host.executive.DEVNULL) |
| 158 | 159 |
| 159 # By setting DISPLAY here, the individual worker processes will | 160 # By setting DISPLAY here, the individual worker processes will |
| 160 # get the right DISPLAY. Note, if this environment could be passed | 161 # get the right DISPLAY. Note, if this environment could be passed |
| 161 # when creating workers, then we wouldn't need to modify DISPLAY here. | 162 # when creating workers, then we wouldn't need to modify DISPLAY here. |
| 163 self._original_display = self.host.environ.get('DISPLAY') |
| 162 self.host.environ['DISPLAY'] = display | 164 self.host.environ['DISPLAY'] = display |
| 163 | 165 |
| 164 # The poll() method will return None if the process has not terminated: | 166 # The poll() method will return None if the process has not terminated: |
| 165 # https://docs.python.org/2/library/subprocess.html#subprocess.Popen.pol
l | 167 # https://docs.python.org/2/library/subprocess.html#subprocess.Popen.pol
l |
| 166 if self._xvfb_process.poll() is not None: | 168 if self._xvfb_process.poll() is not None: |
| 167 _log.warn('Failed to start Xvfb on display "%s."', display) | 169 _log.warn('Failed to start Xvfb on display "%s."', display) |
| 168 | 170 |
| 169 def _find_display(self): | 171 def _find_display(self): |
| 170 """Tries to find a free X display, looping if necessary.""" | 172 """Tries to find a free X display, looping if necessary.""" |
| 171 # The "xvfb-run" command uses :99 by default. | 173 # The "xvfb-run" command uses :99 by default. |
| 172 for display_number in range(99, 120): | 174 for display_number in range(99, 120): |
| 173 display = ':%d' % display_number | 175 display = ':%d' % display_number |
| 174 exit_code = self.host.executive.run_command( | 176 exit_code = self.host.executive.run_command( |
| 175 ['xdpyinfo', '-display', display], return_exit_code=True) | 177 ['xdpyinfo', '-display', display], return_exit_code=True) |
| 176 if exit_code == 1: | 178 if exit_code == 1: |
| 177 return display | 179 return display |
| 178 return None | 180 return None |
| 179 | 181 |
| 180 def _stop_xvfb(self): | 182 def _stop_xvfb(self): |
| 183 if self._original_display: |
| 184 self.host.environ['DISPLAY'] = self._original_display |
| 181 if not self._xvfb_process: | 185 if not self._xvfb_process: |
| 182 return | 186 return |
| 183 _log.debug('Killing Xvfb process pid %d.', self._xvfb_process.pid) | 187 _log.debug('Killing Xvfb process pid %d.', self._xvfb_process.pid) |
| 184 self._xvfb_process.kill() | 188 self._xvfb_process.kill() |
| 185 self._xvfb_process.wait() | 189 self._xvfb_process.wait() |
| 186 | 190 |
| 191 |
| 187 def _path_to_driver(self, target=None): | 192 def _path_to_driver(self, target=None): |
| 188 binary_name = self.driver_name() | 193 binary_name = self.driver_name() |
| 189 return self._build_path_with_target(target, binary_name) | 194 return self._build_path_with_target(target, binary_name) |
| OLD | NEW |