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