blob: b7f633c9f7325e449bc20bb905461805c2f0d669 [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
30import sys
31import time
32
33from webkitpy.layout_tests.port import Port, Driver, DriverOutput
34from webkitpy.layout_tests.port.base import VirtualTestSuite
35from webkitpy.layout_tests.models.test_configuration import TestConfiguration
36from webkitpy.common.system.filesystem_mock import MockFileSystem
37from webkitpy.common.system.crashlogs import CrashLogs
38
39
40# This sets basic expectations for a test. Each individual expectation
41# can be overridden by a keyword argument in TestList.add().
42class TestInstance(object):
43 def __init__(self, name):
44 self.name = name
45 self.base = name[(name.rfind("/") + 1):name.rfind(".")]
46 self.crash = False
47 self.web_process_crash = False
48 self.exception = False
49 self.hang = False
50 self.keyboard = False
51 self.error = ''
52 self.timeout = False
53 self.is_reftest = False
54
55 # The values of each field are treated as raw byte strings. They
56 # will be converted to unicode strings where appropriate using
57 # FileSystem.read_text_file().
58 self.actual_text = self.base + '-txt'
59 self.actual_checksum = self.base + '-checksum'
60
61 # We add the '\x8a' for the image file to prevent the value from
62 # being treated as UTF-8 (the character is invalid)
63 self.actual_image = self.base + '\x8a' + '-png' + 'tEXtchecksum\x00' + self.actual_checksum
64
65 self.expected_text = self.actual_text
66 self.expected_image = self.actual_image
67
68 self.actual_audio = None
69 self.expected_audio = None
70
71
72# This is an in-memory list of tests, what we want them to produce, and
73# what we want to claim are the expected results.
74class TestList(object):
75 def __init__(self):
76 self.tests = {}
77
78 def add(self, name, **kwargs):
79 test = TestInstance(name)
80 for key, value in kwargs.items():
81 test.__dict__[key] = value
82 self.tests[name] = test
83
84 def add_reftest(self, name, reference_name, same_image):
85 self.add(name, actual_checksum='xxx', actual_image='XXX', is_reftest=True)
86 if same_image:
87 self.add(reference_name, actual_checksum='xxx', actual_image='XXX', is_reftest=True)
88 else:
89 self.add(reference_name, actual_checksum='yyy', actual_image='YYY', is_reftest=True)
90
91 def keys(self):
92 return self.tests.keys()
93
94 def __contains__(self, item):
95 return item in self.tests
96
97 def __getitem__(self, item):
98 return self.tests[item]
99
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000100#
101# These numbers may need to be updated whenever we add or delete tests.
102#
103TOTAL_TESTS = 104
104TOTAL_SKIPS = 28
105TOTAL_RETRIES = 14
106
107UNEXPECTED_PASSES = 6
108UNEXPECTED_FAILURES = 17
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000109
110def unit_test_list():
111 tests = TestList()
112 tests.add('failures/expected/crash.html', crash=True)
113 tests.add('failures/expected/exception.html', exception=True)
114 tests.add('failures/expected/timeout.html', timeout=True)
115 tests.add('failures/expected/hang.html', hang=True)
116 tests.add('failures/expected/missing_text.html', expected_text=None)
117 tests.add('failures/expected/image.html',
118 actual_image='image_fail-pngtEXtchecksum\x00checksum_fail',
119 expected_image='image-pngtEXtchecksum\x00checksum-png')
120 tests.add('failures/expected/image_checksum.html',
121 actual_checksum='image_checksum_fail-checksum',
122 actual_image='image_checksum_fail-png')
123 tests.add('failures/expected/audio.html',
124 actual_audio=base64.b64encode('audio_fail-wav'), expected_audio='audio-wav',
125 actual_text=None, expected_text=None,
126 actual_image=None, expected_image=None,
127 actual_checksum=None)
128 tests.add('failures/expected/keyboard.html', keyboard=True)
129 tests.add('failures/expected/missing_check.html',
130 expected_image='missing_check-png')
131 tests.add('failures/expected/missing_image.html', expected_image=None)
132 tests.add('failures/expected/missing_audio.html', expected_audio=None,
133 actual_text=None, expected_text=None,
134 actual_image=None, expected_image=None,
135 actual_checksum=None)
136 tests.add('failures/expected/missing_text.html', expected_text=None)
137 tests.add('failures/expected/newlines_leading.html',
138 expected_text="\nfoo\n", actual_text="foo\n")
139 tests.add('failures/expected/newlines_trailing.html',
140 expected_text="foo\n\n", actual_text="foo\n")
141 tests.add('failures/expected/newlines_with_excess_CR.html',
142 expected_text="foo\r\r\r\n", actual_text="foo\n")
143 tests.add('failures/expected/text.html', actual_text='text_fail-png')
144 tests.add('failures/expected/skip_text.html', actual_text='text diff')
145 tests.add('failures/flaky/text.html')
146 tests.add('failures/unexpected/missing_text.html', expected_text=None)
147 tests.add('failures/unexpected/missing_check.html', expected_image='missing-check-png')
148 tests.add('failures/unexpected/missing_image.html', expected_image=None)
149 tests.add('failures/unexpected/missing_render_tree_dump.html', actual_text="""layer at (0,0) size 800x600
150 RenderView at (0,0) size 800x600
151layer at (0,0) size 800x34
152 RenderBlock {HTML} at (0,0) size 800x34
153 RenderBody {BODY} at (8,8) size 784x18
154 RenderText {#text} at (0,0) size 133x18
155 text run at (0,0) width 133: "This is an image test!"
156""", expected_text=None)
157 tests.add('failures/unexpected/crash.html', crash=True)
158 tests.add('failures/unexpected/crash-with-stderr.html', crash=True,
159 error="mock-std-error-output")
160 tests.add('failures/unexpected/web-process-crash-with-stderr.html', web_process_crash=True,
161 error="mock-std-error-output")
162 tests.add('failures/unexpected/pass.html')
163 tests.add('failures/unexpected/text-checksum.html',
164 actual_text='text-checksum_fail-txt',
165 actual_checksum='text-checksum_fail-checksum')
166 tests.add('failures/unexpected/text-image-checksum.html',
167 actual_text='text-image-checksum_fail-txt',
168 actual_image='text-image-checksum_fail-pngtEXtchecksum\x00checksum_fail',
169 actual_checksum='text-image-checksum_fail-checksum')
170 tests.add('failures/unexpected/checksum-with-matching-image.html',
171 actual_checksum='text-image-checksum_fail-checksum')
172 tests.add('failures/unexpected/skip_pass.html')
173 tests.add('failures/unexpected/text.html', actual_text='text_fail-txt')
174 tests.add('failures/unexpected/timeout.html', timeout=True)
175 tests.add('http/tests/passes/text.html')
176 tests.add('http/tests/passes/image.html')
177 tests.add('http/tests/ssl/text.html')
178 tests.add('passes/args.html')
179 tests.add('passes/error.html', error='stuff going to stderr')
180 tests.add('passes/image.html')
181 tests.add('passes/audio.html',
182 actual_audio=base64.b64encode('audio-wav'), expected_audio='audio-wav',
183 actual_text=None, expected_text=None,
184 actual_image=None, expected_image=None,
185 actual_checksum=None)
186 tests.add('passes/platform_image.html')
187 tests.add('passes/checksum_in_image.html',
188 expected_image='tEXtchecksum\x00checksum_in_image-checksum')
189 tests.add('passes/skipped/skip.html')
190
191 # Note that here the checksums don't match but the images do, so this test passes "unexpectedly".
192 # See https://bugs.webkit.org/show_bug.cgi?id=69444 .
193 tests.add('failures/unexpected/checksum.html', actual_checksum='checksum_fail-checksum')
194
195 # Text output files contain "\r\n" on Windows. This may be
196 # helpfully filtered to "\r\r\n" by our Python/Cygwin tooling.
197 tests.add('passes/text.html',
198 expected_text='\nfoo\n\n', actual_text='\nfoo\r\n\r\r\n')
199
200 # For reftests.
201 tests.add_reftest('passes/reftest.html', 'passes/reftest-expected.html', same_image=True)
202 tests.add_reftest('passes/mismatch.html', 'passes/mismatch-expected-mismatch.html', same_image=False)
203 tests.add_reftest('passes/svgreftest.svg', 'passes/svgreftest-expected.svg', same_image=True)
204 tests.add_reftest('passes/xhtreftest.xht', 'passes/xhtreftest-expected.html', same_image=True)
205 tests.add_reftest('passes/phpreftest.php', 'passes/phpreftest-expected-mismatch.svg', same_image=False)
206 tests.add_reftest('failures/expected/reftest.html', 'failures/expected/reftest-expected.html', same_image=False)
207 tests.add_reftest('failures/expected/mismatch.html', 'failures/expected/mismatch-expected-mismatch.html', same_image=True)
208 tests.add_reftest('failures/unexpected/reftest.html', 'failures/unexpected/reftest-expected.html', same_image=False)
209 tests.add_reftest('failures/unexpected/mismatch.html', 'failures/unexpected/mismatch-expected-mismatch.html', same_image=True)
210 tests.add('failures/unexpected/reftest-nopixel.html', actual_checksum=None, actual_image=None, is_reftest=True)
211 tests.add('failures/unexpected/reftest-nopixel-expected.html', actual_checksum=None, actual_image=None, is_reftest=True)
212 # FIXME: Add a reftest which crashes.
213 tests.add('reftests/foo/test.html')
214 tests.add('reftests/foo/test-ref.html')
215
216 tests.add('reftests/foo/multiple-match-success.html', actual_checksum='abc', actual_image='abc')
217 tests.add('reftests/foo/multiple-match-failure.html', actual_checksum='abc', actual_image='abc')
218 tests.add('reftests/foo/multiple-mismatch-success.html', actual_checksum='abc', actual_image='abc')
219 tests.add('reftests/foo/multiple-mismatch-failure.html', actual_checksum='abc', actual_image='abc')
220 tests.add('reftests/foo/multiple-both-success.html', actual_checksum='abc', actual_image='abc')
221 tests.add('reftests/foo/multiple-both-failure.html', actual_checksum='abc', actual_image='abc')
222
223 tests.add('reftests/foo/matching-ref.html', actual_checksum='abc', actual_image='abc')
224 tests.add('reftests/foo/mismatching-ref.html', actual_checksum='def', actual_image='def')
225 tests.add('reftests/foo/second-mismatching-ref.html', actual_checksum='ghi', actual_image='ghi')
226
227 # The following files shouldn't be treated as reftests
228 tests.add_reftest('reftests/foo/unlistedtest.html', 'reftests/foo/unlistedtest-expected.html', same_image=True)
229 tests.add('reftests/foo/reference/bar/common.html')
230 tests.add('reftests/foo/reftest/bar/shared.html')
231
232 tests.add('websocket/tests/passes/text.html')
233
234 # For testing test are properly included from platform directories.
235 tests.add('platform/test-mac-leopard/http/test.html')
236 tests.add('platform/test-win-win7/http/test.html')
237
238 # For --no-http tests, test that platform specific HTTP tests are properly skipped.
239 tests.add('platform/test-snow-leopard/http/test.html')
240 tests.add('platform/test-snow-leopard/websocket/test.html')
241
242 # For testing if perf tests are running in a locked shard.
243 tests.add('perf/foo/test.html')
244 tests.add('perf/foo/test-ref.html')
245
246 # For testing --pixel-test-directories.
247 tests.add('failures/unexpected/pixeldir/image_in_pixeldir.html',
248 actual_image='image_in_pixeldir-pngtEXtchecksum\x00checksum_fail',
249 expected_image='image_in_pixeldir-pngtEXtchecksum\x00checksum-png')
250 tests.add('failures/unexpected/image_not_in_pixeldir.html',
251 actual_image='image_not_in_pixeldir-pngtEXtchecksum\x00checksum_fail',
252 expected_image='image_not_in_pixeldir-pngtEXtchecksum\x00checksum-png')
253
254 # For testing that virtual test suites don't expand names containing themselves
255 # See webkit.org/b/97925 and base_unittest.PortTest.test_tests().
256 tests.add('passes/test-virtual-passes.html')
257 tests.add('passes/passes/test-virtual-passes.html')
258
259 return tests
260
261
262# Here we use a non-standard location for the layout tests, to ensure that
263# this works. The path contains a '.' in the name because we've seen bugs
264# related to this before.
265
266LAYOUT_TEST_DIR = '/test.checkout/LayoutTests'
267PERF_TEST_DIR = '/test.checkout/PerformanceTests'
268
269
270# Here we synthesize an in-memory filesystem from the test list
271# in order to fully control the test output and to demonstrate that
272# we don't need a real filesystem to run the tests.
273def add_unit_tests_to_mock_filesystem(filesystem):
274 # Add the test_expectations file.
275 filesystem.maybe_make_directory(LAYOUT_TEST_DIR + '/platform/test')
276 if not filesystem.exists(LAYOUT_TEST_DIR + '/platform/test/TestExpectations'):
277 filesystem.write_text_file(LAYOUT_TEST_DIR + '/platform/test/TestExpectations', """
278Bug(test) failures/expected/crash.html [ Crash ]
279Bug(test) failures/expected/image.html [ ImageOnlyFailure ]
280Bug(test) failures/expected/audio.html [ Failure ]
281Bug(test) failures/expected/image_checksum.html [ ImageOnlyFailure ]
282Bug(test) failures/expected/mismatch.html [ ImageOnlyFailure ]
283Bug(test) failures/expected/missing_check.html [ Missing Pass ]
284Bug(test) failures/expected/missing_image.html [ Missing Pass ]
285Bug(test) failures/expected/missing_audio.html [ Missing Pass ]
286Bug(test) failures/expected/missing_text.html [ Missing Pass ]
287Bug(test) failures/expected/newlines_leading.html [ Failure ]
288Bug(test) failures/expected/newlines_trailing.html [ Failure ]
289Bug(test) failures/expected/newlines_with_excess_CR.html [ Failure ]
290Bug(test) failures/expected/reftest.html [ ImageOnlyFailure ]
291Bug(test) failures/expected/text.html [ Failure ]
292Bug(test) failures/expected/timeout.html [ Timeout ]
293Bug(test) failures/expected/hang.html [ WontFix ]
294Bug(test) failures/expected/keyboard.html [ WontFix ]
295Bug(test) failures/expected/exception.html [ WontFix ]
296Bug(test) failures/unexpected/pass.html [ Failure ]
297Bug(test) passes/skipped/skip.html [ Skip ]
298""")
299
300 filesystem.maybe_make_directory(LAYOUT_TEST_DIR + '/reftests/foo')
301 filesystem.write_text_file(LAYOUT_TEST_DIR + '/reftests/foo/reftest.list', """
302== test.html test-ref.html
303
304== multiple-match-success.html mismatching-ref.html
305== multiple-match-success.html matching-ref.html
306== multiple-match-failure.html mismatching-ref.html
307== multiple-match-failure.html second-mismatching-ref.html
308!= multiple-mismatch-success.html mismatching-ref.html
309!= multiple-mismatch-success.html second-mismatching-ref.html
310!= multiple-mismatch-failure.html mismatching-ref.html
311!= multiple-mismatch-failure.html matching-ref.html
312== multiple-both-success.html matching-ref.html
313== multiple-both-success.html mismatching-ref.html
314!= multiple-both-success.html second-mismatching-ref.html
315== multiple-both-failure.html matching-ref.html
316!= multiple-both-failure.html second-mismatching-ref.html
317!= multiple-both-failure.html matching-ref.html
318""")
319
320 # FIXME: This test was only being ignored because of missing a leading '/'.
321 # Fixing the typo causes several tests to assert, so disabling the test entirely.
322 # Add in a file should be ignored by port.find_test_files().
323 #files[LAYOUT_TEST_DIR + '/userscripts/resources/iframe.html'] = 'iframe'
324
325 def add_file(test, suffix, contents):
326 dirname = filesystem.join(LAYOUT_TEST_DIR, test.name[0:test.name.rfind('/')])
327 base = test.base
328 filesystem.maybe_make_directory(dirname)
329 filesystem.write_binary_file(filesystem.join(dirname, base + suffix), contents)
330
331 # Add each test and the expected output, if any.
332 test_list = unit_test_list()
333 for test in test_list.tests.values():
334 add_file(test, test.name[test.name.rfind('.'):], '')
335 if test.is_reftest:
336 continue
337 if test.actual_audio:
338 add_file(test, '-expected.wav', test.expected_audio)
339 continue
340 add_file(test, '-expected.txt', test.expected_text)
341 add_file(test, '-expected.png', test.expected_image)
342
343 filesystem.write_text_file(filesystem.join(LAYOUT_TEST_DIR, 'virtual', 'passes', 'args-expected.txt'), 'args-txt --virtual-arg')
344 # Clear the list of written files so that we can watch what happens during testing.
345 filesystem.clear_written_files()
346
347
348class TestPort(Port):
349 port_name = 'test'
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000350 default_port_name = 'test-mac-leopard'
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000351
352 """Test implementation of the Port interface."""
353 ALL_BASELINE_VARIANTS = (
354 'test-linux-x86_64',
355 'test-mac-snowleopard', 'test-mac-leopard',
356 'test-win-vista', 'test-win-win7', 'test-win-xp',
357 )
358
359 @classmethod
360 def determine_full_port_name(cls, host, options, port_name):
361 if port_name == 'test':
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000362 return TestPort.default_port_name
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000363 return port_name
364
365 def __init__(self, host, port_name=None, **kwargs):
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000366 Port.__init__(self, host, port_name or TestPort.default_port_name, **kwargs)
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000367 self._tests = unit_test_list()
368 self._flakes = set()
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100369 self._generic_expectations_path = LAYOUT_TEST_DIR + '/TestExpectations'
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000370 self._results_directory = None
371
372 self._operating_system = 'mac'
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000373 if self._name.startswith('test-win'):
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000374 self._operating_system = 'win'
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000375 elif self._name.startswith('test-linux'):
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000376 self._operating_system = 'linux'
377
378 version_map = {
379 'test-win-xp': 'xp',
380 'test-win-win7': 'win7',
381 'test-win-vista': 'vista',
382 'test-mac-leopard': 'leopard',
383 'test-mac-snowleopard': 'snowleopard',
384 'test-linux-x86_64': 'lucid',
385 }
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000386 self._version = version_map[self._name]
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000387
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100388 def buildbot_archives_baselines(self):
389 return self._name != 'test-win-xp'
390
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000391 def default_pixel_tests(self):
392 return True
393
394 def _path_to_driver(self):
395 # This routine shouldn't normally be called, but it is called by
396 # the mock_drt Driver. We return something, but make sure it's useless.
397 return 'MOCK _path_to_driver'
398
399 def baseline_search_path(self):
400 search_paths = {
401 'test-mac-snowleopard': ['test-mac-snowleopard'],
402 'test-mac-leopard': ['test-mac-leopard', 'test-mac-snowleopard'],
403 'test-win-win7': ['test-win-win7'],
404 'test-win-vista': ['test-win-vista', 'test-win-win7'],
405 'test-win-xp': ['test-win-xp', 'test-win-vista', 'test-win-win7'],
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100406 'test-linux-x86_64': ['test-linux-x86_64', 'test-win-win7'],
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000407 }
408 return [self._webkit_baseline_path(d) for d in search_paths[self.name()]]
409
410 def default_child_processes(self):
411 return 1
412
413 def worker_startup_delay_secs(self):
414 return 0
415
416 def check_build(self, needs_http):
417 return True
418
419 def check_sys_deps(self, needs_http):
420 return True
421
422 def default_configuration(self):
423 return 'Release'
424
425 def diff_image(self, expected_contents, actual_contents, tolerance=None):
426 diffed = actual_contents != expected_contents
427 if not actual_contents and not expected_contents:
428 return (None, 0, None)
429 if not actual_contents or not expected_contents:
430 return (True, 0, None)
431 if 'ref' in expected_contents:
432 assert tolerance == 0
433 if diffed:
434 return ("< %s\n---\n> %s\n" % (expected_contents, actual_contents), 1, None)
435 return (None, 0, None)
436
437 def layout_tests_dir(self):
438 return LAYOUT_TEST_DIR
439
440 def perf_tests_dir(self):
441 return PERF_TEST_DIR
442
443 def webkit_base(self):
444 return '/test.checkout'
445
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000446 def _skipped_tests_for_unsupported_features(self, test_list):
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000447 return set(['failures/expected/skip_text.html',
448 'failures/unexpected/skip_pass.html',
449 'virtual/skipped'])
450
451 def name(self):
452 return self._name
453
454 def operating_system(self):
455 return self._operating_system
456
457 def _path_to_wdiff(self):
458 return None
459
460 def default_results_directory(self):
461 return '/tmp/layout-test-results'
462
463 def setup_test_run(self):
464 pass
465
466 def _driver_class(self):
467 return TestDriver
468
469 def start_http_server(self, additional_dirs=None, number_of_servers=None):
470 pass
471
472 def start_websocket_server(self):
473 pass
474
475 def acquire_http_lock(self):
476 pass
477
478 def stop_http_server(self):
479 pass
480
481 def stop_websocket_server(self):
482 pass
483
484 def release_http_lock(self):
485 pass
486
487 def _path_to_lighttpd(self):
488 return "/usr/sbin/lighttpd"
489
490 def _path_to_lighttpd_modules(self):
491 return "/usr/lib/lighttpd"
492
493 def _path_to_lighttpd_php(self):
494 return "/usr/bin/php-cgi"
495
496 def _path_to_apache(self):
497 return "/usr/sbin/httpd"
498
499 def _path_to_apache_config_file(self):
500 return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'httpd.conf')
501
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +0100502 def path_to_generic_test_expectations_file(self):
503 return self._generic_expectations_path
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000504
505 def all_test_configurations(self):
506 """Returns a sequence of the TestConfigurations the port supports."""
507 # By default, we assume we want to test every graphics type in
508 # every configuration on every system.
509 test_configurations = []
510 for version, architecture in self._all_systems():
511 for build_type in self._all_build_types():
512 test_configurations.append(TestConfiguration(
513 version=version,
514 architecture=architecture,
515 build_type=build_type))
516 return test_configurations
517
518 def _all_systems(self):
519 return (('leopard', 'x86'),
520 ('snowleopard', 'x86'),
521 ('xp', 'x86'),
522 ('vista', 'x86'),
523 ('win7', 'x86'),
524 ('lucid', 'x86'),
525 ('lucid', 'x86_64'))
526
527 def _all_build_types(self):
528 return ('debug', 'release')
529
530 def configuration_specifier_macros(self):
531 """To avoid surprises when introducing new macros, these are intentionally fixed in time."""
532 return {'mac': ['leopard', 'snowleopard'], 'win': ['xp', 'vista', 'win7'], 'linux': ['lucid']}
533
534 def all_baseline_variants(self):
535 return self.ALL_BASELINE_VARIANTS
536
537 def virtual_test_suites(self):
538 return [
539 VirtualTestSuite('virtual/passes', 'passes', ['--virtual-arg']),
540 VirtualTestSuite('virtual/skipped', 'failures/expected', ['--virtual-arg2']),
541 ]
542
543
544class TestDriver(Driver):
545 """Test/Dummy implementation of the DumpRenderTree interface."""
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000546 next_pid = 1
547
548 def __init__(self, *args, **kwargs):
549 super(TestDriver, self).__init__(*args, **kwargs)
550 self.started = False
551 self.pid = 0
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000552
553 def cmd_line(self, pixel_tests, per_test_args):
554 pixel_tests_flag = '-p' if pixel_tests else ''
555 return [self._port._path_to_driver()] + [pixel_tests_flag] + self._port.get_option('additional_drt_flag', []) + per_test_args
556
557 def run_test(self, test_input, stop_when_done):
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000558 if not self.started:
559 self.started = True
560 self.pid = TestDriver.next_pid
561 TestDriver.next_pid += 1
562
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000563 start_time = time.time()
564 test_name = test_input.test_name
565 test_args = test_input.args or []
566 test = self._port._tests[test_name]
567 if test.keyboard:
568 raise KeyboardInterrupt
569 if test.exception:
570 raise ValueError('exception from ' + test_name)
571 if test.hang:
572 time.sleep((float(test_input.timeout) * 4) / 1000.0 + 1.0) # The 1.0 comes from thread_padding_sec in layout_test_runnery.
573
574 audio = None
575 actual_text = test.actual_text
576
577 if 'flaky' in test_name and not test_name in self._port._flakes:
578 self._port._flakes.add(test_name)
579 actual_text = 'flaky text failure'
580
581 if actual_text and test_args and test_name == 'passes/args.html':
582 actual_text = actual_text + ' ' + ' '.join(test_args)
583
584 if test.actual_audio:
585 audio = base64.b64decode(test.actual_audio)
586 crashed_process_name = None
587 crashed_pid = None
588 if test.crash:
589 crashed_process_name = self._port.driver_name()
590 crashed_pid = 1
591 elif test.web_process_crash:
592 crashed_process_name = 'WebProcess'
593 crashed_pid = 2
594
595 crash_log = ''
596 if crashed_process_name:
597 crash_logs = CrashLogs(self._port.host)
598 crash_log = crash_logs.find_newest_log(crashed_process_name, None) or ''
599
600 if stop_when_done:
601 self.stop()
602
603 if test.actual_checksum == test_input.image_hash:
604 image = None
605 else:
606 image = test.actual_image
607 return DriverOutput(actual_text, image, test.actual_checksum, audio,
608 crash=test.crash or test.web_process_crash, crashed_process_name=crashed_process_name,
609 crashed_pid=crashed_pid, crash_log=crash_log,
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000610 test_time=time.time() - start_time, timeout=test.timeout, error=test.error, pid=self.pid)
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +0000611
612 def stop(self):
Torne (Richard Coles)926b0012013-03-28 15:32:48 +0000613 self.started = False