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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.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 | « third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux.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) 2011 Google Inc. All rights reserved. 1 # Copyright (C) 2011 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 self.assertNotEqual(temp_home_dir, '/home/user') 109 self.assertNotEqual(temp_home_dir, '/home/user')
110 self.assertTrue(port.host.filesystem.isdir(temp_home_dir)) 110 self.assertTrue(port.host.filesystem.isdir(temp_home_dir))
111 self.assertTrue(port.host.filesystem.isfile(port.host.filesystem.join(te mp_home_dir, '.Xauthority'))) 111 self.assertTrue(port.host.filesystem.isfile(port.host.filesystem.join(te mp_home_dir, '.Xauthority')))
112 112
113 # Clean up; HOME should be reset and the temp dir should be cleaned up. 113 # Clean up; HOME should be reset and the temp dir should be cleaned up.
114 port.clean_up_test_run() 114 port.clean_up_test_run()
115 self.assertEqual(port.host.environ['HOME'], '/home/user') 115 self.assertEqual(port.host.environ['HOME'], '/home/user')
116 self.assertFalse(port.host.filesystem.exists(temp_home_dir)) 116 self.assertFalse(port.host.filesystem.exists(temp_home_dir))
117 117
118 def test_setup_test_run_starts_xvfb(self): 118 def test_setup_test_run_starts_xvfb(self):
119 def run_command_fake(args):
120 if args[0] == 'xdpyinfo':
121 if '-display' in args:
122 return 1
123 return 0
124
119 port = self.make_port() 125 port = self.make_port()
120 port.host.executive = MockExecutive(exit_code=1) 126 port.host.executive = MockExecutive(
127 run_command_fn=run_command_fake)
121 port.setup_test_run() 128 port.setup_test_run()
122 self.assertEqual( 129 self.assertEqual(
123 port.host.executive.calls, 130 port.host.executive.calls,
124 [ 131 [
125 ['xdpyinfo', '-display', ':99'], 132 ['xdpyinfo', '-display', ':99'],
126 ['Xvfb', ':99', '-screen', '0', '1280x800x24', '-ac', '-dpi', '9 6'], 133 ['Xvfb', ':99', '-screen', '0', '1280x800x24', '-ac', '-dpi', '9 6'],
134 ['xdpyinfo'],
127 ]) 135 ])
128 env = port.setup_environ_for_server() 136 env = port.setup_environ_for_server()
129 self.assertEqual(env['DISPLAY'], ':99') 137 self.assertEqual(env['DISPLAY'], ':99')
130 138
131 def test_setup_test_runs_finds_free_display(self): 139 def test_setup_test_runs_finds_free_display(self):
140 def run_command_fake(args):
141 if args[0] == 'xdpyinfo':
142 if '-display' in args:
143 if ':102' in args:
144 return 1
145 return 0
146
132 port = self.make_port() 147 port = self.make_port()
133 port.host.executive = MockExecutive( 148 port.host.executive = MockExecutive(
134 run_command_fn=lambda args: 1 if ':102' in args else 0) 149 run_command_fn=run_command_fake)
135 port.setup_test_run() 150 port.setup_test_run()
136 self.assertEqual( 151 self.assertEqual(
137 port.host.executive.calls, 152 port.host.executive.calls,
138 [ 153 [
139 ['xdpyinfo', '-display', ':99'], 154 ['xdpyinfo', '-display', ':99'],
140 ['xdpyinfo', '-display', ':100'], 155 ['xdpyinfo', '-display', ':100'],
141 ['xdpyinfo', '-display', ':101'], 156 ['xdpyinfo', '-display', ':101'],
142 ['xdpyinfo', '-display', ':102'], 157 ['xdpyinfo', '-display', ':102'],
143 ['Xvfb', ':102', '-screen', '0', '1280x800x24', '-ac', '-dpi', ' 96'], 158 ['Xvfb', ':102', '-screen', '0', '1280x800x24', '-ac', '-dpi', ' 96'],
159 ['xdpyinfo'],
144 ]) 160 ])
145 env = port.setup_environ_for_server() 161 env = port.setup_environ_for_server()
146 self.assertEqual(env['DISPLAY'], ':102') 162 self.assertEqual(env['DISPLAY'], ':102')
163
164 def test_setup_test_runs_multiple_checks_when_slow_to_start(self):
165 count = [0]
166
167 def run_command_fake(args):
168 if args[0] == 'xdpyinfo':
169 if '-display' in args:
170 return 1
171 if count[0] < 3:
172 count[0] += 1
173 return 1
174 return 0
175
176 port = self.make_port()
177 port.host.executive = MockExecutive(
178 run_command_fn=run_command_fake)
179 port.setup_test_run()
180 self.assertEqual(
181 port.host.executive.calls,
182 [
183 ['xdpyinfo', '-display', ':99'],
184 ['Xvfb', ':99', '-screen', '0', '1280x800x24', '-ac', '-dpi', '9 6'],
185 ['xdpyinfo'],
186 ['xdpyinfo'],
187 ['xdpyinfo'],
188 ['xdpyinfo'],
189 ])
190 env = port.setup_environ_for_server()
191 self.assertEqual(env['DISPLAY'], ':99')
192
193 def test_setup_test_runs_eventually_failes_on_failure(self):
194 def run_command_fake(args):
195 if args[0] == 'xdpyinfo':
196 return 1
197 return 0
198
199 host = MockSystemHost(os_name=self.os_name, os_version=self.os_version)
200 port = self.make_port(host=host)
201 port.host.executive = MockExecutive(
202 run_command_fn=run_command_fake)
203 port.setup_test_run()
204 self.assertEqual(
205 port.host.executive.calls,
206 [
207 ['xdpyinfo', '-display', ':99'],
208 ['Xvfb', ':99', '-screen', '0', '1280x800x24', '-ac', '-dpi', '9 6'],
209 ] + [['xdpyinfo']] * 51)
210 env = port.setup_environ_for_server()
211 self.assertEqual(env['DISPLAY'], ':99')
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698