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 # See: https://crbug.com/715848 | |
165 env = self.host.environ.copy() | |
166 if env.get('TMPDIR') and env['TMPDIR'] != '/tmp': | |
167 _log.info('Overriding TMPDIR to "/tmp" for Xvfb, was: %s', env['TMPD IR']) | |
Dirk Pranke
2017/05/03 20:26:06
Nit: use _log.debug() here.
| |
168 env['TMPDIR'] = '/tmp' | |
169 | |
160 _log.info('Starting Xvfb with display "%s".', display) | 170 _log.info('Starting Xvfb with display "%s".', display) |
161 self._xvfb_stdout = tempfile.NamedTemporaryFile(delete=False) | 171 self._xvfb_stdout = tempfile.NamedTemporaryFile(delete=False) |
162 self._xvfb_stderr = tempfile.NamedTemporaryFile(delete=False) | 172 self._xvfb_stderr = tempfile.NamedTemporaryFile(delete=False) |
163 self._xvfb_process = self.host.executive.popen( | 173 self._xvfb_process = self.host.executive.popen( |
164 ['Xvfb', display, '-screen', '0', '1280x800x24', '-ac', '-dpi', '96' ], | 174 ['Xvfb', display, '-screen', '0', '1280x800x24', '-ac', '-dpi', '96' ], |
165 stdout=self._xvfb_stdout, stderr=self._xvfb_stderr) | 175 stdout=self._xvfb_stdout, stderr=self._xvfb_stderr, env=env) |
166 | 176 |
167 # By setting DISPLAY here, the individual worker processes will | 177 # By setting DISPLAY here, the individual worker processes will |
168 # get the right DISPLAY. Note, if this environment could be passed | 178 # get the right DISPLAY. Note, if this environment could be passed |
169 # when creating workers, then we wouldn't need to modify DISPLAY here. | 179 # when creating workers, then we wouldn't need to modify DISPLAY here. |
170 self._original_display = self.host.environ.get('DISPLAY') | 180 self._original_display = self.host.environ.get('DISPLAY') |
171 self.host.environ['DISPLAY'] = display | 181 self.host.environ['DISPLAY'] = display |
172 | 182 |
173 # The poll() method will return None if the process has not terminated: | 183 # 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 | 184 # https://docs.python.org/2/library/subprocess.html#subprocess.Popen.pol l |
175 if self._xvfb_process.poll() is not None: | 185 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) | 228 self.host.filesystem.remove(self._xvfb_stdout.name) |
219 if self._xvfb_stderr and self.host.filesystem.exists(self._xvfb_stderr.n ame): | 229 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(): | 230 for line in self.host.filesystem.read_text_file(self._xvfb_stderr.na me).splitlines(): |
221 _log.warn('Xvfb stderr: %s', line) | 231 _log.warn('Xvfb stderr: %s', line) |
222 self.host.filesystem.remove(self._xvfb_stderr.name) | 232 self.host.filesystem.remove(self._xvfb_stderr.name) |
223 self._xvfb_stdout = self._xvfb_stderr = self._xvfb_process = None | 233 self._xvfb_stdout = self._xvfb_stderr = self._xvfb_process = None |
224 | 234 |
225 def _path_to_driver(self, target=None): | 235 def _path_to_driver(self, target=None): |
226 binary_name = self.driver_name() | 236 binary_name = self.driver_name() |
227 return self._build_path_with_target(target, binary_name) | 237 return self._build_path_with_target(target, binary_name) |
OLD | NEW |