OLD | NEW |
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 # virtual flags for it's references, run it on the secondary driver so | 78 # virtual flags for it's references, run it on the secondary driver so |
79 # that the primary driver does not need to be restarted. | 79 # that the primary driver does not need to be restarted. |
80 if (secondary_driver and | 80 if (secondary_driver and |
81 self._port.is_virtual_test(self._test_name) and | 81 self._port.is_virtual_test(self._test_name) and |
82 not self._port.lookup_virtual_reference_args(self._test_name)): | 82 not self._port.lookup_virtual_reference_args(self._test_name)): |
83 self._reference_driver = secondary_driver | 83 self._reference_driver = secondary_driver |
84 | 84 |
85 if self._reference_files: | 85 if self._reference_files: |
86 # Detect and report a test which has a wrong combination of expectat
ion files. | 86 # Detect and report a test which has a wrong combination of expectat
ion files. |
87 # For example, if 'foo.html' has two expectation files, 'foo-expecte
d.html' and | 87 # For example, if 'foo.html' has two expectation files, 'foo-expecte
d.html' and |
88 # 'foo-expected.txt', we should warn users. One test file must be us
ed exclusively | 88 # 'foo-expected.png', we should warn users. One test file must be us
ed exclusively |
89 # in either layout tests or reftests, but not in both. | 89 # in either layout tests or reftests, but not in both. Text expectat
ion is an |
90 for suffix in ('.txt', '.png', '.wav'): | 90 # exception. |
| 91 for suffix in self._port.baseline_extensions(): |
| 92 if suffix == '.txt': |
| 93 continue |
91 expected_filename = self._port.expected_filename(self._test_name
, suffix) | 94 expected_filename = self._port.expected_filename(self._test_name
, suffix) |
92 if self._filesystem.exists(expected_filename): | 95 if self._filesystem.exists(expected_filename): |
93 _log.error('%s is a reftest, but has an unused expectation f
ile. Please remove %s.', | 96 _log.error('%s is a reftest, but has an unused expectation f
ile. Please remove %s.', |
94 self._test_name, expected_filename) | 97 self._test_name, expected_filename) |
95 | 98 |
96 def _expected_driver_output(self): | 99 def _expected_driver_output(self): |
97 return DriverOutput(self._port.expected_text(self._test_name), | 100 return DriverOutput(self._port.expected_text(self._test_name), |
98 self._port.expected_image(self._test_name), | 101 self._port.expected_image(self._test_name), |
99 self._port.expected_checksum(self._test_name), | 102 self._port.expected_checksum(self._test_name), |
100 self._port.expected_audio(self._test_name)) | 103 self._port.expected_audio(self._test_name)) |
(...skipping 20 matching lines...) Expand all Loading... |
121 test_name = test_base | 124 test_name = test_base |
122 args = self._port.lookup_virtual_test_args(self._test_name) | 125 args = self._port.lookup_virtual_test_args(self._test_name) |
123 else: | 126 else: |
124 test_name = self._test_name | 127 test_name = self._test_name |
125 args = self._port.lookup_physical_test_args(self._test_name) | 128 args = self._port.lookup_physical_test_args(self._test_name) |
126 return DriverInput(test_name, self._timeout, image_hash, self._should_ru
n_pixel_test, args) | 129 return DriverInput(test_name, self._timeout, image_hash, self._should_ru
n_pixel_test, args) |
127 | 130 |
128 def run(self): | 131 def run(self): |
129 if self._options.enable_sanitizer: | 132 if self._options.enable_sanitizer: |
130 return self._run_sanitized_test() | 133 return self._run_sanitized_test() |
| 134 if self._options.reset_results: |
| 135 if self._reference_files: |
| 136 expected_txt_filename = self._port.expected_filename(self._test_
name, '.txt') |
| 137 if not self._filesystem.exists(expected_txt_filename): |
| 138 reftest_type = set([reference_file[0] for reference_file in
self._reference_files]) |
| 139 result = TestResult(self._test_name, reftest_type=reftest_ty
pe) |
| 140 result.type = test_expectations.SKIP |
| 141 return result |
| 142 self._should_run_pixel_test = False |
| 143 return self._run_rebaseline() |
131 if self._reference_files: | 144 if self._reference_files: |
132 if self._options.reset_results: | |
133 reftest_type = set([reference_file[0] for reference_file in self
._reference_files]) | |
134 result = TestResult(self._test_name, reftest_type=reftest_type) | |
135 result.type = test_expectations.SKIP | |
136 return result | |
137 return self._run_reftest() | 145 return self._run_reftest() |
138 if self._options.reset_results: | |
139 return self._run_rebaseline() | |
140 return self._run_compare_test() | 146 return self._run_compare_test() |
141 | 147 |
142 def _run_sanitized_test(self): | 148 def _run_sanitized_test(self): |
143 # running a sanitized test means that we ignore the actual test output a
nd just look | 149 # running a sanitized test means that we ignore the actual test output a
nd just look |
144 # for timeouts and crashes (real or forced by the driver). Most crashes
should | 150 # for timeouts and crashes (real or forced by the driver). Most crashes
should |
145 # indicate problems found by a sanitizer (ASAN, LSAN, etc.), but we will
report | 151 # indicate problems found by a sanitizer (ASAN, LSAN, etc.), but we will
report |
146 # on other crashes and timeouts as well in order to detect at least *som
e* basic failures. | 152 # on other crashes and timeouts as well in order to detect at least *som
e* basic failures. |
147 driver_output = self._driver.run_test(self._driver_input(), self._stop_w
hen_done) | 153 driver_output = self._driver.run_test(self._driver_input(), self._stop_w
hen_done) |
148 expected_driver_output = self._expected_driver_output() | 154 expected_driver_output = self._expected_driver_output() |
149 failures = self._handle_error(driver_output) | 155 failures = self._handle_error(driver_output) |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 if driver_output.image_diff: | 362 if driver_output.image_diff: |
357 failures.append(test_failures.FailureImageHashMismatch()) | 363 failures.append(test_failures.FailureImageHashMismatch()) |
358 else: | 364 else: |
359 # See https://bugs.webkit.org/show_bug.cgi?id=69444 for why
this isn't a full failure. | 365 # See https://bugs.webkit.org/show_bug.cgi?id=69444 for why
this isn't a full failure. |
360 _log.warning(' %s -> pixel hash failed (but diff passed)' %
self._test_name) | 366 _log.warning(' %s -> pixel hash failed (but diff passed)' %
self._test_name) |
361 return failures | 367 return failures |
362 | 368 |
363 def _run_reftest(self): | 369 def _run_reftest(self): |
364 test_output = self._driver.run_test(self._driver_input(), self._stop_whe
n_done) | 370 test_output = self._driver.run_test(self._driver_input(), self._stop_whe
n_done) |
365 total_test_time = test_output.test_time | 371 total_test_time = test_output.test_time |
366 reference_output = None | 372 expected_output = None |
367 test_result = None | 373 test_result = None |
368 | 374 |
| 375 expected_text = self._port.expected_text(self._test_name) |
| 376 expected_text_output = DriverOutput(text=expected_text, image=None, imag
e_hash=None, audio=None) |
| 377 |
369 # If the test crashed, or timed out, there's no point in running the ref
erence at all. | 378 # If the test crashed, or timed out, there's no point in running the ref
erence at all. |
370 # This can save a lot of execution time if we have a lot of crashes or t
imeouts. | 379 # This can save a lot of execution time if we have a lot of crashes or t
imeouts. |
371 if test_output.crash or test_output.timeout: | 380 if test_output.crash or test_output.timeout: |
372 expected_driver_output = DriverOutput(text=None, image=None, image_h
ash=None, audio=None) | 381 test_result = self._compare_output(expected_text_output, test_output
) |
373 test_result = self._compare_output(expected_driver_output, test_outp
ut) | |
374 | 382 |
375 if test_output.crash: | 383 if test_output.crash: |
376 test_result_writer.write_test_result(self._filesystem, self._por
t, self._results_directory, | 384 test_result_writer.write_test_result(self._filesystem, self._por
t, self._results_directory, |
377 self._test_name, test_outpu
t, expected_driver_output, test_result.failures) | 385 self._test_name, test_outpu
t, expected_text_output, test_result.failures) |
378 return test_result | 386 return test_result |
379 | 387 |
380 # A reftest can have multiple match references and multiple mismatch ref
erences; | 388 # A reftest can have multiple match references and multiple mismatch ref
erences; |
381 # the test fails if any mismatch matches and all of the matches don't ma
tch. | 389 # the test fails if any mismatch matches and all of the matches don't ma
tch. |
382 # To minimize the number of references we have to check, we run all of t
he mismatches first, | 390 # To minimize the number of references we have to check, we run all of t
he mismatches first, |
383 # then the matches, and short-circuit out as soon as we can. | 391 # then the matches, and short-circuit out as soon as we can. |
384 # Note that sorting by the expectation sorts "!=" before "==" so this is
easy to do. | 392 # Note that sorting by the expectation sorts "!=" before "==" so this is
easy to do. |
385 | 393 |
386 putAllMismatchBeforeMatch = sorted | 394 putAllMismatchBeforeMatch = sorted |
387 reference_test_names = [] | 395 reference_test_names = [] |
388 for expectation, reference_filename in putAllMismatchBeforeMatch(self._r
eference_files): | 396 for expectation, reference_filename in putAllMismatchBeforeMatch(self._r
eference_files): |
389 if self._port.lookup_virtual_test_base(self._test_name): | 397 if self._port.lookup_virtual_test_base(self._test_name): |
390 args = self._port.lookup_virtual_reference_args(self._test_name) | 398 args = self._port.lookup_virtual_reference_args(self._test_name) |
391 else: | 399 else: |
392 args = self._port.lookup_physical_reference_args(self._test_name
) | 400 args = self._port.lookup_physical_reference_args(self._test_name
) |
393 reference_test_name = self._port.relative_test_filename(reference_fi
lename) | 401 reference_test_name = self._port.relative_test_filename(reference_fi
lename) |
394 reference_test_names.append(reference_test_name) | 402 reference_test_names.append(reference_test_name) |
395 driver_input = DriverInput(reference_test_name, self._timeout, | 403 driver_input = DriverInput(reference_test_name, self._timeout, |
396 image_hash=test_output.image_hash, should
_run_pixel_test=True, args=args) | 404 image_hash=test_output.image_hash, should
_run_pixel_test=True, args=args) |
397 reference_output = self._reference_driver.run_test(driver_input, sel
f._stop_when_done) | 405 expected_output = self._reference_driver.run_test(driver_input, self
._stop_when_done) |
398 total_test_time += reference_output.test_time | 406 total_test_time += expected_output.test_time |
399 test_result = self._compare_output_with_reference( | 407 test_result = self._compare_output_with_reference( |
400 reference_output, test_output, reference_filename, expectation =
= '!=') | 408 expected_output, test_output, reference_filename, expectation ==
'!=') |
401 | 409 |
402 if (expectation == '!=' and test_result.failures) or (expectation ==
'==' and not test_result.failures): | 410 if (expectation == '!=' and test_result.failures) or (expectation ==
'==' and not test_result.failures): |
403 break | 411 break |
404 | 412 |
405 assert(reference_output) | 413 assert(expected_output) |
| 414 |
| 415 if expected_text: |
| 416 text_output = DriverOutput(text=test_output.text, image=None, image_
hash=None, audio=None) |
| 417 test_result.failures.extend(self._compare_output(expected_text_outpu
t, text_output).failures) |
| 418 expected_output.text = expected_text_output.text |
| 419 |
406 test_result_writer.write_test_result(self._filesystem, self._port, self.
_results_directory, | 420 test_result_writer.write_test_result(self._filesystem, self._port, self.
_results_directory, |
407 self._test_name, test_output, refer
ence_output, test_result.failures) | 421 self._test_name, test_output, expec
ted_output, test_result.failures) |
408 | 422 |
409 # FIXME: We don't really deal with a mix of reftest types properly. We p
ass in a set() to reftest_type | 423 # FIXME: We don't really deal with a mix of reftest types properly. We p
ass in a set() to reftest_type |
410 # and only really handle the first of the references in the result. | 424 # and only really handle the first of the references in the result. |
411 reftest_type = list(set([reference_file[0] for reference_file in self._r
eference_files])) | 425 reftest_type = list(set([reference_file[0] for reference_file in self._r
eference_files])) |
412 return TestResult(self._test_name, test_result.failures, total_test_time
, | 426 return TestResult(self._test_name, test_result.failures, total_test_time
, |
413 test_result.has_stderr, reftest_type=reftest_type, pid
=test_result.pid, | 427 test_result.has_stderr, reftest_type=reftest_type, pid
=test_result.pid, |
414 references=reference_test_names) | 428 references=reference_test_names) |
415 | 429 |
416 # The returned TestResult always has 0 test_run_time. _run_reftest() calcula
tes total_run_time from test outputs. | 430 # The returned TestResult always has 0 test_run_time. _run_reftest() calcula
tes total_run_time from test outputs. |
417 def _compare_output_with_reference(self, reference_driver_output, actual_dri
ver_output, reference_filename, mismatch): | 431 def _compare_output_with_reference(self, reference_driver_output, actual_dri
ver_output, reference_filename, mismatch): |
(...skipping 15 matching lines...) Expand all Loading... |
433 elif reference_driver_output.image_hash != actual_driver_output.image_ha
sh: | 447 elif reference_driver_output.image_hash != actual_driver_output.image_ha
sh: |
434 diff, err_str = self._port.diff_image(reference_driver_output.image,
actual_driver_output.image) | 448 diff, err_str = self._port.diff_image(reference_driver_output.image,
actual_driver_output.image) |
435 if diff: | 449 if diff: |
436 failures.append(test_failures.FailureReftestMismatch(reference_f
ilename)) | 450 failures.append(test_failures.FailureReftestMismatch(reference_f
ilename)) |
437 elif err_str: | 451 elif err_str: |
438 _log.error(err_str) | 452 _log.error(err_str) |
439 else: | 453 else: |
440 _log.warning(" %s -> ref test hashes didn't match but diff pass
ed" % self._test_name) | 454 _log.warning(" %s -> ref test hashes didn't match but diff pass
ed" % self._test_name) |
441 | 455 |
442 return TestResult(self._test_name, failures, 0, has_stderr, pid=actual_d
river_output.pid) | 456 return TestResult(self._test_name, failures, 0, has_stderr, pid=actual_d
river_output.pid) |
OLD | NEW |