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

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

Issue 2821543003: In run-webkit-tests, start xvfb if necessary. (Closed)
Patch Set: Fix debug log 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
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 def __init__(self, host, port_name, **kwargs): 59 def __init__(self, host, port_name, **kwargs):
60 super(LinuxPort, self).__init__(host, port_name, **kwargs) 60 super(LinuxPort, self).__init__(host, port_name, **kwargs)
61 self._version = port_name[port_name.index('linux-') + len('linux-'):] 61 self._version = port_name[port_name.index('linux-') + len('linux-'):]
62 self._architecture = 'x86_64' 62 self._architecture = 'x86_64'
63 assert self._version in self.SUPPORTED_VERSIONS 63 assert self._version in self.SUPPORTED_VERSIONS
64 64
65 if not self.get_option('disable_breakpad'): 65 if not self.get_option('disable_breakpad'):
66 self._dump_reader = DumpReaderLinux(host, self._build_path()) 66 self._dump_reader = DumpReaderLinux(host, self._build_path())
67 self._original_home = None 67 self._original_home = None
68 self._xvfb_process = None
68 69
69 def additional_driver_flag(self): 70 def additional_driver_flag(self):
70 flags = super(LinuxPort, self).additional_driver_flag() 71 flags = super(LinuxPort, self).additional_driver_flag()
71 if not self.get_option('disable_breakpad'): 72 if not self.get_option('disable_breakpad'):
72 flags += ['--enable-crash-reporter', '--crash-dumps-dir=%s' % self._ dump_reader.crash_dumps_directory()] 73 flags += ['--enable-crash-reporter', '--crash-dumps-dir=%s' % self._ dump_reader.crash_dumps_directory()]
73 return flags 74 return flags
74 75
75 def check_build(self, needs_http, printer): 76 def check_build(self, needs_http, printer):
76 result = super(LinuxPort, self).check_build(needs_http, printer) 77 result = super(LinuxPort, self).check_build(needs_http, printer)
77 78
(...skipping 19 matching lines...) Expand all
97 # The Apache binary path can vary depending on OS and distribution 98 # The Apache binary path can vary depending on OS and distribution
98 # See http://wiki.apache.org/httpd/DistrosDefaultLayout 99 # See http://wiki.apache.org/httpd/DistrosDefaultLayout
99 for path in ['/usr/sbin/httpd', '/usr/sbin/apache2']: 100 for path in ['/usr/sbin/httpd', '/usr/sbin/apache2']:
100 if self._filesystem.exists(path): 101 if self._filesystem.exists(path):
101 return path 102 return path
102 _log.error('Could not find apache. Not installed or unknown path.') 103 _log.error('Could not find apache. Not installed or unknown path.')
103 return None 104 return None
104 105
105 def setup_test_run(self): 106 def setup_test_run(self):
106 super(LinuxPort, self).setup_test_run() 107 super(LinuxPort, self).setup_test_run()
108 self._start_xvfb()
107 self._setup_dummy_home_dir() 109 self._setup_dummy_home_dir()
108 110
109 def clean_up_test_run(self): 111 def clean_up_test_run(self):
110 super(LinuxPort, self).clean_up_test_run() 112 super(LinuxPort, self).clean_up_test_run()
113 self._stop_xvfb()
111 self._clean_up_dummy_home_dir() 114 self._clean_up_dummy_home_dir()
112 115
113 # 116 #
114 # PROTECTED METHODS 117 # PROTECTED METHODS
115 # 118 #
116 119
117 def _setup_dummy_home_dir(self): 120 def _setup_dummy_home_dir(self):
118 """Creates a dummy home directory for running the test. 121 """Creates a dummy home directory for running the test.
119 122
120 This is a workaround for crbug.com/595504; see crbug.com/612730. 123 This is a workaround for crbug.com/595504; see crbug.com/612730.
(...skipping 14 matching lines...) Expand all
135 continue 138 continue
136 fs.copyfile(original_path, fs.join(dummy_home, filename)) 139 fs.copyfile(original_path, fs.join(dummy_home, filename))
137 140
138 def _clean_up_dummy_home_dir(self): 141 def _clean_up_dummy_home_dir(self):
139 """Cleans up the dummy dir and resets the HOME environment variable.""" 142 """Cleans up the dummy dir and resets the HOME environment variable."""
140 dummy_home = self.host.environ['HOME'] 143 dummy_home = self.host.environ['HOME']
141 assert dummy_home != self._original_home 144 assert dummy_home != self._original_home
142 self._filesystem.rmtree(dummy_home) 145 self._filesystem.rmtree(dummy_home)
143 self.host.environ['HOME'] = self._original_home 146 self.host.environ['HOME'] = self._original_home
144 147
148 def _start_xvfb(self):
149 if self._has_x_server():
150 return
151 display = self.host.environ.get('DISPLAY') or ':20'
qyearsley 2017/04/14 18:25:40 This choice of :20 is arbitrary.
Dirk Pranke 2017/04/14 21:44:08 Don't use the existing DISPLAY value, that'll just
qyearsley 2017/04/18 01:02:39 There's one complication here: a collection of new
Dirk Pranke 2017/04/18 02:16:18 OK, good point. I guess go w/ setting the exsting
qyearsley 2017/04/18 17:58:35 Alright, will do this for now. Added comment about
152 self.host.environ['DISPLAY'] = display
153 _log.debug('Starting Xvfb with display location "%s".', display)
154 self._xvfb_process = self.host.executive.popen(
155 ['Xvfb', display, '-screen', '0', '1280x800x24', '-ac', '-dpi', '96' ],
qyearsley 2017/04/14 18:25:40 Not sure if all of these options are necessary.
Dirk Pranke 2017/04/18 02:16:18 You need -screen, because you don't want to confli
qyearsley 2017/04/18 17:58:35 Alright, will keep these arguments, later we could
156 stderr=self.host.executive.PIPE)
157
158 def _has_x_server(self):
159 display = self.host.environ.get('DISPLAY')
160 print display
161 _log.debug('Checking for X server on display location "%s".', display)
162 if not display:
163 return False
164 exit_code = self.host.executive.run_command(
165 ['xdpyinfo', '-display', display], return_exit_code=True)
166 return exit_code == 0
167
168 def _stop_xvfb(self):
169 if not self._xvfb_process:
170 return
171 _log.debug('Killing Xvfb process pid %d.', self._xvfb_process.pid)
172 self._xvfb_process.kill()
qyearsley 2017/04/14 18:25:40 Not sure whether it would be prudent to do anythin
Dirk Pranke 2017/04/18 02:16:18 I'd probably call self._xvfb_process.wait() just t
qyearsley 2017/04/18 17:58:35 Done.
173
145 def _path_to_driver(self, target=None): 174 def _path_to_driver(self, target=None):
146 binary_name = self.driver_name() 175 binary_name = self.driver_name()
147 return self._build_path_with_target(target, binary_name) 176 return self._build_path_with_target(target, binary_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698