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

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

Issue 2836403003: Add Xvfb debugging code to run-webkit-tests. (Closed)
Patch Set: tweak output Created 3 years, 8 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 | « third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py ('k') | 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
11 # in the documentation and/or other materials provided with the 11 # in the documentation and/or other materials provided with the
12 # distribution. 12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its 13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from 14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission. 15 # this software without specific prior written permission.
16 # 16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 import logging 29 import logging
30 import tempfile
30 31
31 from webkitpy.layout_tests.breakpad.dump_reader_multipart import DumpReaderLinux 32 from webkitpy.layout_tests.breakpad.dump_reader_multipart import DumpReaderLinux
32 from webkitpy.layout_tests.port import base 33 from webkitpy.layout_tests.port import base
33 from webkitpy.layout_tests.port import win 34 from webkitpy.layout_tests.port import win
34 35
35 36
36 _log = logging.getLogger(__name__) 37 _log = logging.getLogger(__name__)
37 38
38 39
39 class LinuxPort(base.Port): 40 class LinuxPort(base.Port):
(...skipping 20 matching lines...) Expand all
60 super(LinuxPort, self).__init__(host, port_name, **kwargs) 61 super(LinuxPort, self).__init__(host, port_name, **kwargs)
61 self._version = port_name[port_name.index('linux-') + len('linux-'):] 62 self._version = port_name[port_name.index('linux-') + len('linux-'):]
62 self._architecture = 'x86_64' 63 self._architecture = 'x86_64'
63 assert self._version in self.SUPPORTED_VERSIONS 64 assert self._version in self.SUPPORTED_VERSIONS
64 65
65 if not self.get_option('disable_breakpad'): 66 if not self.get_option('disable_breakpad'):
66 self._dump_reader = DumpReaderLinux(host, self._build_path()) 67 self._dump_reader = DumpReaderLinux(host, self._build_path())
67 self._original_home = None 68 self._original_home = None
68 self._original_display = None 69 self._original_display = None
69 self._xvfb_process = None 70 self._xvfb_process = None
71 self._xvfb_stdout = None
72 self._xvfb_stderr = None
70 73
71 def additional_driver_flag(self): 74 def additional_driver_flag(self):
72 flags = super(LinuxPort, self).additional_driver_flag() 75 flags = super(LinuxPort, self).additional_driver_flag()
73 if not self.get_option('disable_breakpad'): 76 if not self.get_option('disable_breakpad'):
74 flags += ['--enable-crash-reporter', '--crash-dumps-dir=%s' % self._ dump_reader.crash_dumps_directory()] 77 flags += ['--enable-crash-reporter', '--crash-dumps-dir=%s' % self._ dump_reader.crash_dumps_directory()]
75 return flags 78 return flags
76 79
77 def check_build(self, needs_http, printer): 80 def check_build(self, needs_http, printer):
78 result = super(LinuxPort, self).check_build(needs_http, printer) 81 result = super(LinuxPort, self).check_build(needs_http, printer)
79 82
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 self._filesystem.rmtree(dummy_home) 149 self._filesystem.rmtree(dummy_home)
147 self.host.environ['HOME'] = self._original_home 150 self.host.environ['HOME'] = self._original_home
148 151
149 def _start_xvfb(self): 152 def _start_xvfb(self):
150 display = self._find_display() 153 display = self._find_display()
151 if not display: 154 if not display:
152 _log.warn('Failed to find a free display to start Xvfb.') 155 _log.warn('Failed to find a free display to start Xvfb.')
153 return 156 return
154 157
155 _log.info('Starting Xvfb with display "%s".', display) 158 _log.info('Starting Xvfb with display "%s".', display)
159 self._xvfb_stdout = tempfile.NamedTemporaryFile(delete=False)
160 self._xvfb_stderr = tempfile.NamedTemporaryFile(delete=False)
156 self._xvfb_process = self.host.executive.popen( 161 self._xvfb_process = self.host.executive.popen(
157 ['Xvfb', display, '-screen', '0', '1280x800x24', '-ac', '-dpi', '96' ], 162 ['Xvfb', display, '-screen', '0', '1280x800x24', '-ac', '-dpi', '96' ],
158 stderr=self.host.executive.DEVNULL) 163 stdout=self._xvfb_stdout, stderr=self._xvfb_stderr)
159 164
160 # By setting DISPLAY here, the individual worker processes will 165 # By setting DISPLAY here, the individual worker processes will
161 # get the right DISPLAY. Note, if this environment could be passed 166 # get the right DISPLAY. Note, if this environment could be passed
162 # when creating workers, then we wouldn't need to modify DISPLAY here. 167 # when creating workers, then we wouldn't need to modify DISPLAY here.
163 self._original_display = self.host.environ.get('DISPLAY') 168 self._original_display = self.host.environ.get('DISPLAY')
164 self.host.environ['DISPLAY'] = display 169 self.host.environ['DISPLAY'] = display
165 170
166 # The poll() method will return None if the process has not terminated: 171 # 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 172 # https://docs.python.org/2/library/subprocess.html#subprocess.Popen.pol l
168 if self._xvfb_process.poll() is not None: 173 if self._xvfb_process.poll() is not None:
169 _log.warn('Failed to start Xvfb on display "%s."', display) 174 _log.warn('Failed to start Xvfb on display "%s."', display)
175 self._stop_xvfb()
170 176
171 def _find_display(self): 177 def _find_display(self):
172 """Tries to find a free X display, looping if necessary.""" 178 """Tries to find a free X display, looping if necessary."""
173 # The "xvfb-run" command uses :99 by default. 179 # The "xvfb-run" command uses :99 by default.
174 for display_number in range(99, 120): 180 for display_number in range(99, 120):
175 display = ':%d' % display_number 181 display = ':%d' % display_number
176 exit_code = self.host.executive.run_command( 182 exit_code = self.host.executive.run_command(
177 ['xdpyinfo', '-display', display], return_exit_code=True) 183 ['xdpyinfo', '-display', display], return_exit_code=True)
178 if exit_code == 1: 184 if exit_code == 1:
179 return display 185 return display
180 return None 186 return None
181 187
182 def _stop_xvfb(self): 188 def _stop_xvfb(self):
183 if self._original_display: 189 if self._original_display:
184 self.host.environ['DISPLAY'] = self._original_display 190 self.host.environ['DISPLAY'] = self._original_display
185 if not self._xvfb_process: 191 if self._xvfb_stdout:
186 return 192 self._xvfb_stdout.close()
187 _log.debug('Killing Xvfb process pid %d.', self._xvfb_process.pid) 193 if self._xvfb_stderr:
188 self._xvfb_process.kill() 194 self._xvfb_stderr.close()
189 self._xvfb_process.wait() 195 if self._xvfb_process:
196 _log.debug('Killing Xvfb process pid %d.', self._xvfb_process.pid)
197 self._xvfb_process.kill()
198 self._xvfb_process.wait()
199 if self._xvfb_stdout and self.host.filesystem.exists(self._xvfb_stdout.n ame):
200 for line in self.host.filesystem.read_text_file(self._xvfb_stdout.na me).splitlines():
201 _log.warn('Xvfb stdout: %s', line)
202 self.host.filesystem.remove(self._xvfb_stdout.name)
203 if self._xvfb_stderr and self.host.filesystem.exists(self._xvfb_stderr.n ame):
204 for line in self.host.filesystem.read_text_file(self._xvfb_stderr.na me).splitlines():
205 _log.warn('Xvfb stderr: %s', line)
206 self.host.filesystem.remove(self._xvfb_stderr.name)
207
190 208
191 209
192 def _path_to_driver(self, target=None): 210 def _path_to_driver(self, target=None):
193 binary_name = self.driver_name() 211 binary_name = self.driver_name()
194 return self._build_path_with_target(target, binary_name) 212 return self._build_path_with_target(target, binary_name)
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698