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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux.py

Issue 2848833002: webkitpy: Poll xvfb while checking with xdpyinfo. (Closed)
Patch Set: Created 3 years, 7 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 def _clean_up_dummy_home_dir(self): 147 def _clean_up_dummy_home_dir(self):
148 """Cleans up the dummy dir and resets the HOME environment variable.""" 148 """Cleans up the dummy dir and resets the HOME environment variable."""
149 dummy_home = self.host.environ['HOME'] 149 dummy_home = self.host.environ['HOME']
150 assert dummy_home != self._original_home 150 assert dummy_home != self._original_home
151 self._filesystem.rmtree(dummy_home) 151 self._filesystem.rmtree(dummy_home)
152 self.host.environ['HOME'] = self._original_home 152 self.host.environ['HOME'] = self._original_home
153 153
154 def _start_xvfb(self): 154 def _start_xvfb(self):
155 display = self._find_display() 155 display = self._find_display()
156 if not display: 156 if not display:
157 _log.warn('Failed to find a free display to start Xvfb.') 157 _log.critical('Failed to find a free display to start Xvfb.')
158 return 158 return
159 159
160 _log.info('Starting Xvfb with display "%s".', display) 160 _log.info('Starting Xvfb with display "%s".', display)
161 self._xvfb_stdout = tempfile.NamedTemporaryFile(delete=False) 161 self._xvfb_stdout = tempfile.NamedTemporaryFile(delete=False)
162 self._xvfb_stderr = tempfile.NamedTemporaryFile(delete=False) 162 self._xvfb_stderr = tempfile.NamedTemporaryFile(delete=False)
163 self._xvfb_process = self.host.executive.popen( 163 self._xvfb_process = self.host.executive.popen(
164 ['Xvfb', display, '-screen', '0', '1280x800x24', '-ac', '-dpi', '96' ], 164 ['Xvfb', display, '-screen', '0', '1280x800x24', '-ac', '-dpi', '96' ],
165 stdout=self._xvfb_stdout, stderr=self._xvfb_stderr) 165 stdout=self._xvfb_stdout, stderr=self._xvfb_stderr)
166 166
167 # By setting DISPLAY here, the individual worker processes will 167 # By setting DISPLAY here, the individual worker processes will
168 # get the right DISPLAY. Note, if this environment could be passed 168 # get the right DISPLAY. Note, if this environment could be passed
169 # when creating workers, then we wouldn't need to modify DISPLAY here. 169 # when creating workers, then we wouldn't need to modify DISPLAY here.
170 self._original_display = self.host.environ.get('DISPLAY') 170 self._original_display = self.host.environ.get('DISPLAY')
171 self.host.environ['DISPLAY'] = display 171 self.host.environ['DISPLAY'] = display
172 172
173 # The poll() method will return None if the process has not terminated: 173 # Check that xvfb has started correctly via probing using xdpyinfo.
174 # While xvfb is running, the poll() method will return None;
174 # https://docs.python.org/2/library/subprocess.html#subprocess.Popen.pol l 175 # https://docs.python.org/2/library/subprocess.html#subprocess.Popen.pol l
175 if self._xvfb_process.poll() is not None:
176 _log.warn('Failed to start Xvfb on display "%s."', display)
177 self._stop_xvfb()
178
179 start_time = self.host.time() 176 start_time = self.host.time()
180 while self.host.time() - start_time < self.XVFB_START_TIMEOUT: 177 while self.host.time() - start_time < self.XVFB_START_TIMEOUT or self._x vfb_process.poll() is not None:
181 # We don't explicitly set the display, as we want to check the 178 # We don't explicitly set the display, as we want to check the
182 # environment value. 179 # environment value.
183 exit_code = self.host.executive.run_command( 180 exit_code = self.host.executive.run_command(
184 ['xdpyinfo'], return_exit_code=True) 181 ['xdpyinfo'], return_exit_code=True)
185 if exit_code == 0: 182 if exit_code == 0:
186 _log.info('Successfully started Xvfb with display "%s".', displa y) 183 _log.info('Successfully started Xvfb with display "%s".', displa y)
187 return 184 return
188 _log.warn('xdpyinfo check failed with exit code %s while starting Xv fb on "%s".', exit_code, display) 185 _log.warn('xdpyinfo check failed with exit code %s while starting Xv fb on "%s".', exit_code, display)
189 self.host.sleep(0.1) 186 self.host.sleep(0.1)
190 _log.fatal('Failed to start Xvfb on display "%s" (xdpyinfo check failed) .', display) 187
188 retcode = self._xvfb_process.poll()
191 self._stop_xvfb() 189 self._stop_xvfb()
190 _log.critical('Failed to start Xvfb on display "%s" (xvfb retcode: %r).' , display, retcode)
192 191
193 def _find_display(self): 192 def _find_display(self):
194 """Tries to find a free X display, looping if necessary.""" 193 """Tries to find a free X display, looping if necessary."""
195 # The "xvfb-run" command uses :99 by default. 194 # The "xvfb-run" command uses :99 by default.
196 for display_number in range(99, 120): 195 for display_number in range(99, 120):
197 display = ':%d' % display_number 196 display = ':%d' % display_number
198 exit_code = self.host.executive.run_command( 197 exit_code = self.host.executive.run_command(
199 ['xdpyinfo', '-display', display], return_exit_code=True) 198 ['xdpyinfo', '-display', display], return_exit_code=True)
200 if exit_code == 1: 199 if exit_code == 1:
201 return display 200 return display
(...skipping 16 matching lines...) Expand all
218 self.host.filesystem.remove(self._xvfb_stdout.name) 217 self.host.filesystem.remove(self._xvfb_stdout.name)
219 if self._xvfb_stderr and self.host.filesystem.exists(self._xvfb_stderr.n ame): 218 if self._xvfb_stderr and self.host.filesystem.exists(self._xvfb_stderr.n ame):
220 for line in self.host.filesystem.read_text_file(self._xvfb_stderr.na me).splitlines(): 219 for line in self.host.filesystem.read_text_file(self._xvfb_stderr.na me).splitlines():
221 _log.warn('Xvfb stderr: %s', line) 220 _log.warn('Xvfb stderr: %s', line)
222 self.host.filesystem.remove(self._xvfb_stderr.name) 221 self.host.filesystem.remove(self._xvfb_stderr.name)
223 self._xvfb_stdout = self._xvfb_stderr = self._xvfb_process = None 222 self._xvfb_stdout = self._xvfb_stderr = self._xvfb_process = None
224 223
225 def _path_to_driver(self, target=None): 224 def _path_to_driver(self, target=None):
226 binary_name = self.driver_name() 225 binary_name = self.driver_name()
227 return self._build_path_with_target(target, binary_name) 226 return self._build_path_with_target(target, binary_name)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698