blob: 68922e849110d16864171ecd6b289daf67f1b5cb [file] [log] [blame]
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +00001# Copyright (C) 2010 Google Inc. All rights reserved.
2#
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are
5# met:
6#
7# * Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9# * Redistributions in binary form must reproduce the above
10# copyright notice, this list of conditions and the following disclaimer
11# in the documentation and/or other materials provided with the
12# distribution.
13# * Neither the Google name nor the names of its
14# contributors may be used to endorse or promote products derived from
15# this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
28
29import base64
Torne (Richard Coles)93ac45c2013-05-29 14:40:20 +010030import copy
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +000031import sys
32import time
33
34from webkitpy.layout_tests.port import Port, Driver, DriverOutput
35from webkitpy.layout_tests.port.base import VirtualTestSuite
36from webkitpy.layout_tests.models.test_configuration import TestConfiguration
37from webkitpy.common.system.filesystem_mock import MockFileSystem
38from webkitpy.common.system.crashlogs import CrashLogs
39
40
41# This sets basic expectations for a test. Each individual expectation
42# can be overridden by a keyword argument in TestList.add().
43class TestInstance(object):
44 def __init__(self, name):
45 self.name = name
46 self.base = name[(name.rfind("/") + 1):name.rfind(".")]
47 self.crash = False
48 self.web_process_crash = False
49 self.exception = False
50 self.hang = False
51 self.keyboard = False
52 self.error = ''
53 self.timeout = False
54 self.is_reftest = False
55
56 # The values of each field are treated as raw byte strings. They
57 # will be converted to unicode strings where appropriate using
58 # FileSystem.read_text_file().
59 self.actual_text = self.base + '-txt'
60 self.actual_checksum = self.base + '-checksum'
61
62 # We add the '\x8a' for the image file to prevent the value from
63 # being treated as UTF-8 (the character is invalid)
64 self.actual_image = self.base + '\x8a' + '-png' + 'tEXtchecksum\x00' + self.actual_checksum
65
66 self.expected_text = self.actual_text
67 self.expected_image = self.actual_image
68
69 self.actual_audio = None
70 self.expected_audio = None
71
72
73# This is an in-memory list of tests, what we want them to produce, and
74# what we want to claim are the expected results.
75class TestList(object):
76 def __init__(self):
77 self.tests = {}
78
79 def add(self, name, **kwargs):
80 test = TestInstance(name)
81 for key, value in kwargs.items():
82 test.__dict__[key] = value
83 self.tests[name] = test
84
85 def add_reftest(self, name, reference_name, same_image):
86 self.add(name, actual_checksum='xxx', actual_image='XXX', is_reftest=True)
87 if same_image:
88 self.add(reference_name, actual_checksum='xxx', actual_image='XXX', is_reftest=True)
89 else:
90 self.add(reference_name, actual_checksum='yyy', actual_image='YYY', is_reftest=True)
91
92 def keys(self):
93 return self.tests.keys()
94
95 def __contains__(self, item):
96 return item in self.tests
97
98 def __getitem__(self, item):
99 return self.tests[item]
100
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000101#
102# These numbers may need to be updated whenever we add or delete tests.
103#
Torne (Richard Coles)93ac45c2013-05-29 14:40:20 +0100104TOTAL_TESTS = 102
105TOTAL_SKIPS = 25
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000106TOTAL_RETRIES = 14
107
108UNEXPECTED_PASSES = 6
109UNEXPECTED_FAILURES = 17
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000110
111def unit_test_list():
112 tests = TestList()
113 tests.add('failures/expected/crash.html', crash=True)
114 tests.add('failures/expected/exception.html', exception=True)
115 tests.add('failures/expected/timeout.html', timeout=True)
116 tests.add('failures/expected/hang.html', hang=True)
117 tests.add('failures/expected/missing_text.html', expected_text=None)
118 tests.add('failures/expected/image.html',
119 actual_image='image_fail-pngtEXtchecksum\x00checksum_fail',
120 expected_image='image-pngtEXtchecksum\x00checksum-png')
121 tests.add('failures/expected/image_checksum.html',
122 actual_checksum='image_checksum_fail-checksum',
123 actual_image='image_checksum_fail-png')
124 tests.add('failures/expected/audio.html',
125 actual_audio=base64.b64encode('audio_fail-wav'), expected_audio='audio-wav',
126 actual_text=None, expected_text=None,
127 actual_image=None, expected_image=None,
128 actual_checksum=None)
129 tests.add('failures/expected/keyboard.html', keyboard=True)
130 tests.add('failures/expected/missing_check.html',
131 expected_image='missing_check-png')
132 tests.add('failures/expected/missing_image.html', expected_image=None)
133 tests.add('failures/expected/missing_audio.html', expected_audio=None,
134 actual_text=None, expected_text=None,
135 actual_image=None, expected_image=None,
136 actual_checksum=None)
137 tests.add('failures/expected/missing_text.html', expected_text=None)
138 tests.add('failures/expected/newlines_leading.html',
139 expected_text="\nfoo\n", actual_text="foo\n")
140 tests.add('failures/expected/newlines_trailing.html',
141 expected_text="foo\n\n", actual_text="foo\n")
142 tests.add('failures/expected/newlines_with_excess_CR.html',
143 expected_text="foo\r\r\r\n", actual_text="foo\n")
144 tests.add('failures/expected/text.html', actual_text='text_fail-png')
145 tests.add('failures/expected/skip_text.html', actual_text='text diff')
146 tests.add('failures/flaky/text.html')
147 tests.add('failures/unexpected/missing_text.html', expected_text=None)
148 tests.add('failures/unexpected/missing_check.html', expected_image='missing-check-png')
149 tests.add('failures/unexpected/missing_image.html', expected_image=None)
150 tests.add('failures/unexpected/missing_render_tree_dump.html', actual_text="""layer at (0,0) size 800x600
151 RenderView at (0,0) size 800x600
152layer at (0,0) size 800x34
153 RenderBlock {HTML} at (0,0) size 800x34
154 RenderBody {BODY} at (8,8) size 784x18
155 RenderText {#text} at (0,0) size 133x18
156 text run at (0,0) width 133: "This is an image test!"
157""", expected_text=None)
158 tests.add('failures/unexpected/crash.html', crash=True)
159 tests.add('failures/unexpected/crash-with-stderr.html', crash=True,
160 error="mock-std-error-output")
161 tests.add('failures/unexpected/web-process-crash-with-stderr.html', web_process_crash=True,
162 error="mock-std-error-output")
163 tests.add('failures/unexpected/pass.html')
164 tests.add('failures/unexpected/text-checksum.html',
165 actual_text='text-checksum_fail-txt',
166 actual_checksum='text-checksum_fail-checksum')
167 tests.add('failures/unexpected/text-image-checksum.html',
168 actual_text='text-image-checksum_fail-txt',
169 actual_image='text-image-checksum_fail-pngtEXtchecksum\x00checksum_fail',
170 actual_checksum='text-image-checksum_fail-checksum')
171 tests.add('failures/unexpected/checksum-with-matching-image.html',
172 actual_checksum='text-image-checksum_fail-checksum')
173 tests.add('failures/unexpected/skip_pass.html')
174 tests.add('failures/unexpected/text.html', actual_text='text_fail-txt')
175 tests.add('failures/unexpected/timeout.html', timeout=True)
176 tests.add('http/tests/passes/text.html')
177 tests.add('http/tests/passes/image.html')
178 tests.add('http/tests/ssl/text.html')
179 tests.add('passes/args.html')
180 tests.add('passes/error.html', error='stuff going to stderr')
181 tests.add('passes/image.html')
182 tests.add('passes/audio.html',
183 actual_audio=base64.b64encode('audio-wav'), expected_audio='audio-wav',
184 actual_text=None, expected_text=None,
185 actual_image=None, expected_image=None,
186 actual_checksum=None)
187 tests.add('passes/platform_image.html')
188 tests.add('passes/checksum_in_image.html',
189 expected_image='tEXtchecksum\x00checksum_in_image-checksum')
190 tests.add('passes/skipped/skip.html')
191
192 # Note that here the checksums don't match but the images do, so this test passes "unexpectedly".
193 # See https://bugs.webkit.org/show_bug.cgi?id=69444 .
194 tests.add('failures/unexpected/checksum.html', actual_checksum='checksum_fail-checksum')
195
196 # Text output files contain "\r\n" on Windows. This may be
197 # helpfully filtered to "\r\r\n" by our Python/Cygwin tooling.
198 tests.add('passes/text.html',
199 expected_text='\nfoo\n\n', actual_text='\nfoo\r\n\r\r\n')
200
201 # For reftests.
202 tests.add_reftest('passes/reftest.html', 'passes/reftest-expected.html', same_image=True)
203 tests.add_reftest('passes/mismatch.html', 'passes/mismatch-expected-mismatch.html', same_image=False)
204 tests.add_reftest('passes/svgreftest.svg', 'passes/svgreftest-expected.svg', same_image=True)
205 tests.add_reftest('passes/xhtreftest.xht', 'passes/xhtreftest-expected.html', same_image=True)
206 tests.add_reftest('passes/phpreftest.php', 'passes/phpreftest-expected-mismatch.svg', same_image=False)
207 tests.add_reftest('failures/expected/reftest.html', 'failures/expected/reftest-expected.html', same_image=False)
208 tests.add_reftest('failures/expected/mismatch.html', 'failures/expected/mismatch-expected-mismatch.html', same_image=True)
209 tests.add_reftest('failures/unexpected/reftest.html', 'failures/unexpected/reftest-expected.html', same_image=False)
210 tests.add_reftest('failures/unexpected/mismatch.html', 'failures/unexpected/mismatch-expected-mismatch.html', same_image=True)
211 tests.add('failures/unexpected/reftest-nopixel.html', actual_checksum=None, actual_image=None, is_reftest=True)
212 tests.add('failures/unexpected/reftest-nopixel-expected.html', actual_checksum=None, actual_image=None, is_reftest=True)
213 # FIXME: Add a reftest which crashes.
214 tests.add('reftests/foo/test.html')
215 tests.add('reftests/foo/test-ref.html')
216
217 tests.add('reftests/foo/multiple-match-success.html', actual_checksum='abc', actual_image='abc')
218 tests.add('reftests/foo/multiple-match-failure.html', actual_checksum='abc', actual_image='abc')
219 tests.add('reftests/foo/multiple-mismatch-success.html', actual_checksum='abc', actual_image='abc')
220 tests.add('reftests/foo/multiple-mismatch-failure.html', actual_checksum='abc', actual_image='abc')
221 tests.add('reftests/foo/multiple-both-success.html', actual_checksum='abc', actual_image='abc')
222 tests.add('reftests/foo/multiple-both-failure.html', actual_checksum='abc', actual_image='abc')
223
224 tests.add('reftests/foo/matching-ref.html', actual_checksum='abc', actual_image='abc')
225 tests.add('reftests/foo/mismatching-ref.html', actual_checksum='def', actual_image='def')
226 tests.add('reftests/foo/second-mismatching-ref.html', actual_checksum='ghi', actual_image='ghi')
227
228 # The following files shouldn't be treated as reftests
229 tests.add_reftest('reftests/foo/unlistedtest.html', 'reftests/foo/unlistedtest-expected.html', same_image=True)
230 tests.add('reftests/foo/reference/bar/common.html')
231 tests.add('reftests/foo/reftest/bar/shared.html')
232
233 tests.add('websocket/tests/passes/text.html')
234
Torne (Richard Coles)93ac45c2013-05-29 14:40:20 +0100235 # For testing that we don't run tests under platform/. Note that these don't contribute to TOTAL_TESTS.
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000236 tests.add('platform/test-mac-leopard/http/test.html')
237 tests.add('platform/test-win-win7/http/test.html')
238
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000239 # For testing if perf tests are running in a locked shard.
240 tests.add('perf/foo/test.html')
241 tests.add('perf/foo/test-ref.html')
242
243 # For testing --pixel-test-directories.
244 tests.add('failures/unexpected/pixeldir/image_in_pixeldir.html',
245 actual_image='image_in_pixeldir-pngtEXtchecksum\x00checksum_fail',
246 expected_image='image_in_pixeldir-pngtEXtchecksum\x00checksum-png')
247 tests.add('failures/unexpected/image_not_in_pixeldir.html',
248 actual_image='image_not_in_pixeldir-pngtEXtchecksum\x00checksum_fail',
249 expected_image='image_not_in_pixeldir-pngtEXtchecksum\x00checksum-png')
250
251 # For testing that virtual test suites don't expand names containing themselves
252 # See webkit.org/b/97925 and base_unittest.PortTest.test_tests().
253 tests.add('passes/test-virtual-passes.html')
254 tests.add('passes/passes/test-virtual-passes.html')
255
256 return tests
257
258
259# Here we use a non-standard location for the layout tests, to ensure that
260# this works. The path contains a '.' in the name because we've seen bugs
261# related to this before.
262
263LAYOUT_TEST_DIR = '/test.checkout/LayoutTests'
264PERF_TEST_DIR = '/test.checkout/PerformanceTests'
265
266
267# Here we synthesize an in-memory filesystem from the test list
268# in order to fully control the test output and to demonstrate that
269# we don't need a real filesystem to run the tests.
270def add_unit_tests_to_mock_filesystem(filesystem):
271 # Add the test_expectations file.
272 filesystem.maybe_make_directory(LAYOUT_TEST_DIR + '/platform/test')
273 if not filesystem.exists(LAYOUT_TEST_DIR + '/platform/test/TestExpectations'):
274 filesystem.write_text_file(LAYOUT_TEST_DIR + '/platform/test/TestExpectations', """
275Bug(test) failures/expected/crash.html [ Crash ]
276Bug(test) failures/expected/image.html [ ImageOnlyFailure ]
277Bug(test) failures/expected/audio.html [ Failure ]
278Bug(test) failures/expected/image_checksum.html [ ImageOnlyFailure ]
279Bug(test) failures/expected/mismatch.html [ ImageOnlyFailure ]
280Bug(test) failures/expected/missing_check.html [ Missing Pass ]
281Bug(test) failures/expected/missing_image.html [ Missing Pass ]
282Bug(test) failures/expected/missing_audio.html [ Missing Pass ]
283Bug(test) failures/expected/missing_text.html [ Missing Pass ]
284Bug(test) failures/expected/newlines_leading.html [ Failure ]
285Bug(test) failures/expected/newlines_trailing.html [ Failure ]
286Bug(test) failures/expected/newlines_with_excess_CR.html [ Failure ]
287Bug(test) failures/expected/reftest.html [ ImageOnlyFailure ]
288Bug(test) failures/expected/text.html [ Failure ]
289Bug(test) failures/expected/timeout.html [ Timeout ]
290Bug(test) failures/expected/hang.html [ WontFix ]
291Bug(test) failures/expected/keyboard.html [ WontFix ]
292Bug(test) failures/expected/exception.html [ WontFix ]
293Bug(test) failures/unexpected/pass.html [ Failure ]
294Bug(test) passes/skipped/skip.html [ Skip ]
Torne (Richard Coles)81a51572013-05-13 16:52:28 +0100295Bug(test) passes/text.html [ Pass ]
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000296""")
297
298 filesystem.maybe_make_directory(LAYOUT_TEST_DIR + '/reftests/foo')
299 filesystem.write_text_file(LAYOUT_TEST_DIR + '/reftests/foo/reftest.list', """
300== test.html test-ref.html
301
302== multiple-match-success.html mismatching-ref.html
303== multiple-match-success.html matching-ref.html
304== multiple-match-failure.html mismatching-ref.html
305== multiple-match-failure.html second-mismatching-ref.html
306!= multiple-mismatch-success.html mismatching-ref.html
307!= multiple-mismatch-success.html second-mismatching-ref.html
308!= multiple-mismatch-failure.html mismatching-ref.html
309!= multiple-mismatch-failure.html matching-ref.html
310== multiple-both-success.html matching-ref.html
311== multiple-both-success.html mismatching-ref.html
312!= multiple-both-success.html second-mismatching-ref.html
313== multiple-both-failure.html matching-ref.html
314!= multiple-both-failure.html second-mismatching-ref.html
315!= multiple-both-failure.html matching-ref.html
316""")
317
318 # FIXME: This test was only being ignored because of missing a leading '/'.
319 # Fixing the typo causes several tests to assert, so disabling the test entirely.
320 # Add in a file should be ignored by port.find_test_files().
321 #files[LAYOUT_TEST_DIR + '/userscripts/resources/iframe.html'] = 'iframe'
322
323 def add_file(test, suffix, contents):
324 dirname = filesystem.join(LAYOUT_TEST_DIR, test.name[0:test.name.rfind('/')])
325 base = test.base
326 filesystem.maybe_make_directory(dirname)
327 filesystem.write_binary_file(filesystem.join(dirname, base + suffix), contents)
328
329 # Add each test and the expected output, if any.
330 test_list = unit_test_list()
331 for test in test_list.tests.values():
332 add_file(test, test.name[test.name.rfind('.'):], '')
333 if test.is_reftest:
334 continue
335 if test.actual_audio:
336 add_file(test, '-expected.wav', test.expected_audio)
337 continue
338 add_file(test, '-expected.txt', test.expected_text)
339 add_file(test, '-expected.png', test.expected_image)
340
341 filesystem.write_text_file(filesystem.join(LAYOUT_TEST_DIR, 'virtual', 'passes', 'args-expected.txt'), 'args-txt --virtual-arg')
342 # Clear the list of written files so that we can watch what happens during testing.
343 filesystem.clear_written_files()
344
345
346class TestPort(Port):
347 port_name = 'test'
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000348 default_port_name = 'test-mac-leopard'
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000349
350 """Test implementation of the Port interface."""
351 ALL_BASELINE_VARIANTS = (
352 'test-linux-x86_64',
353 'test-mac-snowleopard', 'test-mac-leopard',
Torne (Richard Coles)521d96e2013-06-19 11:58:24 +0100354 'test-win-win7', 'test-win-xp',
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000355 )
356
357 @classmethod
358 def determine_full_port_name(cls, host, options, port_name):
359 if port_name == 'test':
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000360 return TestPort.default_port_name
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000361 return port_name
362
363 def __init__(self, host, port_name=None, **kwargs):
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000364 Port.__init__(self, host, port_name or TestPort.default_port_name, **kwargs)
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000365 self._tests = unit_test_list()
366 self._flakes = set()
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100367 self._generic_expectations_path = LAYOUT_TEST_DIR + '/TestExpectations'
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000368 self._results_directory = None
369
370 self._operating_system = 'mac'
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000371 if self._name.startswith('test-win'):
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000372 self._operating_system = 'win'
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000373 elif self._name.startswith('test-linux'):
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000374 self._operating_system = 'linux'
375
376 version_map = {
377 'test-win-xp': 'xp',
378 'test-win-win7': 'win7',
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000379 'test-mac-leopard': 'leopard',
380 'test-mac-snowleopard': 'snowleopard',
381 'test-linux-x86_64': 'lucid',
382 }
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000383 self._version = version_map[self._name]
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000384
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100385 def buildbot_archives_baselines(self):
386 return self._name != 'test-win-xp'
387
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000388 def default_pixel_tests(self):
389 return True
390
391 def _path_to_driver(self):
392 # This routine shouldn't normally be called, but it is called by
393 # the mock_drt Driver. We return something, but make sure it's useless.
394 return 'MOCK _path_to_driver'
395
396 def baseline_search_path(self):
397 search_paths = {
398 'test-mac-snowleopard': ['test-mac-snowleopard'],
399 'test-mac-leopard': ['test-mac-leopard', 'test-mac-snowleopard'],
400 'test-win-win7': ['test-win-win7'],
Torne (Richard Coles)521d96e2013-06-19 11:58:24 +0100401 'test-win-xp': ['test-win-xp', 'test-win-win7'],
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100402 'test-linux-x86_64': ['test-linux-x86_64', 'test-win-win7'],
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000403 }
404 return [self._webkit_baseline_path(d) for d in search_paths[self.name()]]
405
406 def default_child_processes(self):
407 return 1
408
409 def worker_startup_delay_secs(self):
410 return 0
411
412 def check_build(self, needs_http):
413 return True
414
415 def check_sys_deps(self, needs_http):
416 return True
417
418 def default_configuration(self):
419 return 'Release'
420
421 def diff_image(self, expected_contents, actual_contents, tolerance=None):
422 diffed = actual_contents != expected_contents
423 if not actual_contents and not expected_contents:
424 return (None, 0, None)
425 if not actual_contents or not expected_contents:
426 return (True, 0, None)
427 if 'ref' in expected_contents:
428 assert tolerance == 0
429 if diffed:
430 return ("< %s\n---\n> %s\n" % (expected_contents, actual_contents), 1, None)
431 return (None, 0, None)
432
433 def layout_tests_dir(self):
434 return LAYOUT_TEST_DIR
435
436 def perf_tests_dir(self):
437 return PERF_TEST_DIR
438
439 def webkit_base(self):
440 return '/test.checkout'
441
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000442 def _skipped_tests_for_unsupported_features(self, test_list):
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000443 return set(['failures/expected/skip_text.html',
444 'failures/unexpected/skip_pass.html',
445 'virtual/skipped'])
446
447 def name(self):
448 return self._name
449
450 def operating_system(self):
451 return self._operating_system
452
453 def _path_to_wdiff(self):
454 return None
455
456 def default_results_directory(self):
457 return '/tmp/layout-test-results'
458
459 def setup_test_run(self):
460 pass
461
462 def _driver_class(self):
463 return TestDriver
464
465 def start_http_server(self, additional_dirs=None, number_of_servers=None):
466 pass
467
468 def start_websocket_server(self):
469 pass
470
471 def acquire_http_lock(self):
472 pass
473
474 def stop_http_server(self):
475 pass
476
477 def stop_websocket_server(self):
478 pass
479
480 def release_http_lock(self):
481 pass
482
483 def _path_to_lighttpd(self):
484 return "/usr/sbin/lighttpd"
485
486 def _path_to_lighttpd_modules(self):
487 return "/usr/lib/lighttpd"
488
489 def _path_to_lighttpd_php(self):
490 return "/usr/bin/php-cgi"
491
492 def _path_to_apache(self):
493 return "/usr/sbin/httpd"
494
495 def _path_to_apache_config_file(self):
496 return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'httpd.conf')
497
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100498 def path_to_generic_test_expectations_file(self):
499 return self._generic_expectations_path
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000500
501 def all_test_configurations(self):
502 """Returns a sequence of the TestConfigurations the port supports."""
503 # By default, we assume we want to test every graphics type in
504 # every configuration on every system.
505 test_configurations = []
506 for version, architecture in self._all_systems():
507 for build_type in self._all_build_types():
508 test_configurations.append(TestConfiguration(
509 version=version,
510 architecture=architecture,
511 build_type=build_type))
512 return test_configurations
513
514 def _all_systems(self):
515 return (('leopard', 'x86'),
516 ('snowleopard', 'x86'),
517 ('xp', 'x86'),
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000518 ('win7', 'x86'),
519 ('lucid', 'x86'),
520 ('lucid', 'x86_64'))
521
522 def _all_build_types(self):
523 return ('debug', 'release')
524
525 def configuration_specifier_macros(self):
526 """To avoid surprises when introducing new macros, these are intentionally fixed in time."""
Torne (Richard Coles)521d96e2013-06-19 11:58:24 +0100527 return {'mac': ['leopard', 'snowleopard'], 'win': ['xp', 'win7'], 'linux': ['lucid']}
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000528
529 def all_baseline_variants(self):
530 return self.ALL_BASELINE_VARIANTS
531
532 def virtual_test_suites(self):
533 return [
534 VirtualTestSuite('virtual/passes', 'passes', ['--virtual-arg']),
535 VirtualTestSuite('virtual/skipped', 'failures/expected', ['--virtual-arg2']),
536 ]
537
538
539class TestDriver(Driver):
540 """Test/Dummy implementation of the DumpRenderTree interface."""
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000541 next_pid = 1
542
543 def __init__(self, *args, **kwargs):
544 super(TestDriver, self).__init__(*args, **kwargs)
545 self.started = False
546 self.pid = 0
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000547
548 def cmd_line(self, pixel_tests, per_test_args):
549 pixel_tests_flag = '-p' if pixel_tests else ''
550 return [self._port._path_to_driver()] + [pixel_tests_flag] + self._port.get_option('additional_drt_flag', []) + per_test_args
551
Torne (Richard Coles)93ac45c2013-05-29 14:40:20 +0100552 def run_test(self, driver_input, stop_when_done):
553 base = self._port.lookup_virtual_test_base(driver_input.test_name)
554 if base:
555 virtual_driver_input = copy.copy(driver_input)
556 virtual_driver_input.test_name = base
557 virtual_driver_input.args = self._port.lookup_virtual_test_args(driver_input.test_name)
558 return self.run_test(virtual_driver_input, stop_when_done)
559
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000560 if not self.started:
561 self.started = True
562 self.pid = TestDriver.next_pid
563 TestDriver.next_pid += 1
564
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000565 start_time = time.time()
Torne (Richard Coles)93ac45c2013-05-29 14:40:20 +0100566 test_name = driver_input.test_name
567 test_args = driver_input.args or []
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000568 test = self._port._tests[test_name]
569 if test.keyboard:
570 raise KeyboardInterrupt
571 if test.exception:
572 raise ValueError('exception from ' + test_name)
573 if test.hang:
Torne (Richard Coles)93ac45c2013-05-29 14:40:20 +0100574 time.sleep((float(driver_input.timeout) * 4) / 1000.0 + 1.0) # The 1.0 comes from thread_padding_sec in layout_test_runnery.
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000575
576 audio = None
577 actual_text = test.actual_text
578
579 if 'flaky' in test_name and not test_name in self._port._flakes:
580 self._port._flakes.add(test_name)
581 actual_text = 'flaky text failure'
582
583 if actual_text and test_args and test_name == 'passes/args.html':
584 actual_text = actual_text + ' ' + ' '.join(test_args)
585
586 if test.actual_audio:
587 audio = base64.b64decode(test.actual_audio)
588 crashed_process_name = None
589 crashed_pid = None
590 if test.crash:
591 crashed_process_name = self._port.driver_name()
592 crashed_pid = 1
593 elif test.web_process_crash:
594 crashed_process_name = 'WebProcess'
595 crashed_pid = 2
596
597 crash_log = ''
598 if crashed_process_name:
599 crash_logs = CrashLogs(self._port.host)
600 crash_log = crash_logs.find_newest_log(crashed_process_name, None) or ''
601
602 if stop_when_done:
603 self.stop()
604
Torne (Richard Coles)93ac45c2013-05-29 14:40:20 +0100605 if test.actual_checksum == driver_input.image_hash:
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000606 image = None
607 else:
608 image = test.actual_image
609 return DriverOutput(actual_text, image, test.actual_checksum, audio,
610 crash=test.crash or test.web_process_crash, crashed_process_name=crashed_process_name,
611 crashed_pid=crashed_pid, crash_log=crash_log,
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000612 test_time=time.time() - start_time, timeout=test.timeout, error=test.error, pid=self.pid)
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000613
614 def stop(self):
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000615 self.started = False