Chromium Code Reviews| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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.warn('Failed to find a free display to start Xvfb.') |
| 158 return | 158 return |
| 159 | 159 |
| 160 # Parts of Xvfb use a hard-coded "/tmp" for its temporary directory. | |
| 161 # This can cause a failure when those parts expect to hardlink against | |
| 162 # files that were created in "TEMPDIR" / "TMPDIR". | |
| 163 # | |
| 164 # Since altering this behavior requires an Xvfb patch or some deep | |
| 165 # surgery, we instead opt to use the system "TEMPDIR" for this specific | |
| 166 # process. | |
|
mithro
2017/05/03 01:58:34
Don't need this second paragraph.
dnj
2017/05/03 03:36:36
Done.
| |
| 167 # | |
| 168 # See: crbug.com/715848 | |
|
mithro
2017/05/03 01:58:34
https://crbug.com/XXXXX
dnj
2017/05/03 03:36:36
Done.
| |
| 169 env = self.host.environ.copy() | |
| 170 env['TEMPDIR'] = env['TMPDIR'] = '/tmp' | |
|
mithro
2017/05/03 01:58:34
Can you log a warning if 'TEMPDIR' is set in the e
iannucci
2017/05/03 02:06:36
Actually... Why set TEMPDIR? That's only used on w
dnj
2017/05/03 03:36:36
I can - however, this will generally not be set on
dnj
2017/05/03 03:36:36
I was overriding everything I saw in the log vars,
| |
| 171 | |
| 160 _log.info('Starting Xvfb with display "%s".', display) | 172 _log.info('Starting Xvfb with display "%s".', display) |
| 161 self._xvfb_stdout = tempfile.NamedTemporaryFile(delete=False) | 173 self._xvfb_stdout = tempfile.NamedTemporaryFile(delete=False) |
| 162 self._xvfb_stderr = tempfile.NamedTemporaryFile(delete=False) | 174 self._xvfb_stderr = tempfile.NamedTemporaryFile(delete=False) |
| 163 self._xvfb_process = self.host.executive.popen( | 175 self._xvfb_process = self.host.executive.popen( |
| 164 ['Xvfb', display, '-screen', '0', '1280x800x24', '-ac', '-dpi', '96' ], | 176 ['Xvfb', display, '-screen', '0', '1280x800x24', '-ac', '-dpi', '96' ], |
| 165 stdout=self._xvfb_stdout, stderr=self._xvfb_stderr) | 177 stdout=self._xvfb_stdout, stderr=self._xvfb_stderr, env=env) |
| 166 | 178 |
| 167 # By setting DISPLAY here, the individual worker processes will | 179 # By setting DISPLAY here, the individual worker processes will |
| 168 # get the right DISPLAY. Note, if this environment could be passed | 180 # get the right DISPLAY. Note, if this environment could be passed |
| 169 # when creating workers, then we wouldn't need to modify DISPLAY here. | 181 # when creating workers, then we wouldn't need to modify DISPLAY here. |
| 170 self._original_display = self.host.environ.get('DISPLAY') | 182 self._original_display = self.host.environ.get('DISPLAY') |
| 171 self.host.environ['DISPLAY'] = display | 183 self.host.environ['DISPLAY'] = display |
| 172 | 184 |
| 173 # The poll() method will return None if the process has not terminated: | 185 # The poll() method will return None if the process has not terminated: |
| 174 # https://docs.python.org/2/library/subprocess.html#subprocess.Popen.pol l | 186 # https://docs.python.org/2/library/subprocess.html#subprocess.Popen.pol l |
| 175 if self._xvfb_process.poll() is not None: | 187 if self._xvfb_process.poll() is not None: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 self.host.filesystem.remove(self._xvfb_stdout.name) | 230 self.host.filesystem.remove(self._xvfb_stdout.name) |
| 219 if self._xvfb_stderr and self.host.filesystem.exists(self._xvfb_stderr.n ame): | 231 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(): | 232 for line in self.host.filesystem.read_text_file(self._xvfb_stderr.na me).splitlines(): |
| 221 _log.warn('Xvfb stderr: %s', line) | 233 _log.warn('Xvfb stderr: %s', line) |
| 222 self.host.filesystem.remove(self._xvfb_stderr.name) | 234 self.host.filesystem.remove(self._xvfb_stderr.name) |
| 223 self._xvfb_stdout = self._xvfb_stderr = self._xvfb_process = None | 235 self._xvfb_stdout = self._xvfb_stderr = self._xvfb_process = None |
| 224 | 236 |
| 225 def _path_to_driver(self, target=None): | 237 def _path_to_driver(self, target=None): |
| 226 binary_name = self.driver_name() | 238 binary_name = self.driver_name() |
| 227 return self._build_path_with_target(target, binary_name) | 239 return self._build_path_with_target(target, binary_name) |
| OLD | NEW |