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

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

Issue 2837773002: webkitpy: Check xvfb with xdpyinfo after starting. (Closed)
Patch Set: Fixing tests 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 | third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.py » ('j') | 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 30 matching lines...) Expand all
41 41
42 SUPPORTED_VERSIONS = ('trusty',) 42 SUPPORTED_VERSIONS = ('trusty',)
43 43
44 FALLBACK_PATHS = {} 44 FALLBACK_PATHS = {}
45 FALLBACK_PATHS['trusty'] = ['linux'] + win.WinPort.latest_platform_fallback_ path() 45 FALLBACK_PATHS['trusty'] = ['linux'] + win.WinPort.latest_platform_fallback_ path()
46 46
47 DEFAULT_BUILD_DIRECTORIES = ('out',) 47 DEFAULT_BUILD_DIRECTORIES = ('out',)
48 48
49 BUILD_REQUIREMENTS_URL = 'https://chromium.googlesource.com/chromium/src/+/m aster/docs/linux_build_instructions.md' 49 BUILD_REQUIREMENTS_URL = 'https://chromium.googlesource.com/chromium/src/+/m aster/docs/linux_build_instructions.md'
50 50
51 XVFB_START_TIMEOUT = 5.0 # Wait up to 5 seconds for Xvfb to start.
52
51 @classmethod 53 @classmethod
52 def determine_full_port_name(cls, host, options, port_name): 54 def determine_full_port_name(cls, host, options, port_name):
53 if port_name.endswith('linux'): 55 if port_name.endswith('linux'):
54 assert host.platform.is_linux() 56 assert host.platform.is_linux()
55 version = host.platform.os_version 57 version = host.platform.os_version
56 return port_name + '-' + version 58 return port_name + '-' + version
57 return port_name 59 return port_name
58 60
59 def __init__(self, host, port_name, **kwargs): 61 def __init__(self, host, port_name, **kwargs):
60 super(LinuxPort, self).__init__(host, port_name, **kwargs) 62 super(LinuxPort, self).__init__(host, port_name, **kwargs)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 # get the right DISPLAY. Note, if this environment could be passed 163 # get the right DISPLAY. Note, if this environment could be passed
162 # when creating workers, then we wouldn't need to modify DISPLAY here. 164 # when creating workers, then we wouldn't need to modify DISPLAY here.
163 self._original_display = self.host.environ.get('DISPLAY') 165 self._original_display = self.host.environ.get('DISPLAY')
164 self.host.environ['DISPLAY'] = display 166 self.host.environ['DISPLAY'] = display
165 167
166 # The poll() method will return None if the process has not terminated: 168 # The poll() method will return None if the process has not terminated:
167 # https://docs.python.org/2/library/subprocess.html#subprocess.Popen.pol l 169 # https://docs.python.org/2/library/subprocess.html#subprocess.Popen.pol l
168 if self._xvfb_process.poll() is not None: 170 if self._xvfb_process.poll() is not None:
169 _log.warn('Failed to start Xvfb on display "%s."', display) 171 _log.warn('Failed to start Xvfb on display "%s."', display)
170 172
173 start_time = self.host.time()
174 while self.host.time() - start_time < self.XVFB_START_TIMEOUT:
175 # We don't explicitly set the display, as we want to check the
176 # environment value.
177 exit_code = self.host.executive.run_command(
178 ['xdpyinfo'], return_exit_code=True)
179 if exit_code == 0:
180 _log.info('Successfully started Xvfb with display "%s".', displa y)
181 return
182 _log.warn('xdpyinfo check failed with exit code %s while starting Xv fb on "%s".', exit_code, display)
183 self.host.sleep(0.1)
184 _log.fatal('Failed to start Xvfb on display "%s" (xdpyinfo check failed) .', display)
185
171 def _find_display(self): 186 def _find_display(self):
172 """Tries to find a free X display, looping if necessary.""" 187 """Tries to find a free X display, looping if necessary."""
173 # The "xvfb-run" command uses :99 by default. 188 # The "xvfb-run" command uses :99 by default.
174 for display_number in range(99, 120): 189 for display_number in range(99, 120):
175 display = ':%d' % display_number 190 display = ':%d' % display_number
176 exit_code = self.host.executive.run_command( 191 exit_code = self.host.executive.run_command(
177 ['xdpyinfo', '-display', display], return_exit_code=True) 192 ['xdpyinfo', '-display', display], return_exit_code=True)
178 if exit_code == 1: 193 if exit_code == 1:
179 return display 194 return display
180 return None 195 return None
181 196
182 def _stop_xvfb(self): 197 def _stop_xvfb(self):
183 if self._original_display: 198 if self._original_display:
184 self.host.environ['DISPLAY'] = self._original_display 199 self.host.environ['DISPLAY'] = self._original_display
185 if not self._xvfb_process: 200 if not self._xvfb_process:
186 return 201 return
187 _log.debug('Killing Xvfb process pid %d.', self._xvfb_process.pid) 202 _log.debug('Killing Xvfb process pid %d.', self._xvfb_process.pid)
188 self._xvfb_process.kill() 203 self._xvfb_process.kill()
189 self._xvfb_process.wait() 204 self._xvfb_process.wait()
190 205
191 206
192 def _path_to_driver(self, target=None): 207 def _path_to_driver(self, target=None):
193 binary_name = self.driver_name() 208 binary_name = self.driver_name()
194 return self._build_path_with_target(target, binary_name) 209 return self._build_path_with_target(target, binary_name)
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698