| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 # We don't explicitly set the display, as we want to check the | 181 # We don't explicitly set the display, as we want to check the |
| 182 # environment value. | 182 # environment value. |
| 183 exit_code = self.host.executive.run_command( | 183 exit_code = self.host.executive.run_command( |
| 184 ['xdpyinfo'], return_exit_code=True) | 184 ['xdpyinfo'], return_exit_code=True) |
| 185 if exit_code == 0: | 185 if exit_code == 0: |
| 186 _log.info('Successfully started Xvfb with display "%s".', displa
y) | 186 _log.info('Successfully started Xvfb with display "%s".', displa
y) |
| 187 return | 187 return |
| 188 _log.warn('xdpyinfo check failed with exit code %s while starting Xv
fb on "%s".', exit_code, display) | 188 _log.warn('xdpyinfo check failed with exit code %s while starting Xv
fb on "%s".', exit_code, display) |
| 189 self.host.sleep(0.1) | 189 self.host.sleep(0.1) |
| 190 _log.fatal('Failed to start Xvfb on display "%s" (xdpyinfo check failed)
.', display) | 190 _log.fatal('Failed to start Xvfb on display "%s" (xdpyinfo check failed)
.', display) |
| 191 self._stop_xvfb() |
| 191 | 192 |
| 192 def _find_display(self): | 193 def _find_display(self): |
| 193 """Tries to find a free X display, looping if necessary.""" | 194 """Tries to find a free X display, looping if necessary.""" |
| 194 # The "xvfb-run" command uses :99 by default. | 195 # The "xvfb-run" command uses :99 by default. |
| 195 for display_number in range(99, 120): | 196 for display_number in range(99, 120): |
| 196 display = ':%d' % display_number | 197 display = ':%d' % display_number |
| 197 exit_code = self.host.executive.run_command( | 198 exit_code = self.host.executive.run_command( |
| 198 ['xdpyinfo', '-display', display], return_exit_code=True) | 199 ['xdpyinfo', '-display', display], return_exit_code=True) |
| 199 if exit_code == 1: | 200 if exit_code == 1: |
| 200 return display | 201 return display |
| (...skipping 11 matching lines...) Expand all Loading... |
| 212 self._xvfb_process.kill() | 213 self._xvfb_process.kill() |
| 213 self._xvfb_process.wait() | 214 self._xvfb_process.wait() |
| 214 if self._xvfb_stdout and self.host.filesystem.exists(self._xvfb_stdout.n
ame): | 215 if self._xvfb_stdout and self.host.filesystem.exists(self._xvfb_stdout.n
ame): |
| 215 for line in self.host.filesystem.read_text_file(self._xvfb_stdout.na
me).splitlines(): | 216 for line in self.host.filesystem.read_text_file(self._xvfb_stdout.na
me).splitlines(): |
| 216 _log.warn('Xvfb stdout: %s', line) | 217 _log.warn('Xvfb stdout: %s', line) |
| 217 self.host.filesystem.remove(self._xvfb_stdout.name) | 218 self.host.filesystem.remove(self._xvfb_stdout.name) |
| 218 if self._xvfb_stderr and self.host.filesystem.exists(self._xvfb_stderr.n
ame): | 219 if self._xvfb_stderr and self.host.filesystem.exists(self._xvfb_stderr.n
ame): |
| 219 for line in self.host.filesystem.read_text_file(self._xvfb_stderr.na
me).splitlines(): | 220 for line in self.host.filesystem.read_text_file(self._xvfb_stderr.na
me).splitlines(): |
| 220 _log.warn('Xvfb stderr: %s', line) | 221 _log.warn('Xvfb stderr: %s', line) |
| 221 self.host.filesystem.remove(self._xvfb_stderr.name) | 222 self.host.filesystem.remove(self._xvfb_stderr.name) |
| 222 | 223 self._xvfb_stdout = self._xvfb_stderr = self._xvfb_process = None |
| 223 | |
| 224 | 224 |
| 225 def _path_to_driver(self, target=None): | 225 def _path_to_driver(self, target=None): |
| 226 binary_name = self.driver_name() | 226 binary_name = self.driver_name() |
| 227 return self._build_path_with_target(target, binary_name) | 227 return self._build_path_with_target(target, binary_name) |
| OLD | NEW |