3 # Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
4 # Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
5 # Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com)
6 # Copyright (C) 2007 Eric Seidel <eric@webkit.org>
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
17 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
18 # its contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
21 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
22 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
25 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 # Script to run the Web Kit Open Source Project layout tests.
34 # Run all the tests passed in on the command line.
35 # If no tests are passed, find all the .html, .shtml, .xml, .xhtml, .pl, .php (and svg) files in the test directory.
38 # Compare against the existing file xxx-expected.txt.
39 # If there is a mismatch, generate xxx-actual.txt and xxx-diffs.txt.
42 # the number of tests that got the expected results
43 # the number of tests that ran, but did not get the expected results
44 # the number of tests that failed to run
45 # the number of tests that were run but had no expected results to compare against
56 use File::Spec::Functions;
61 use Time::HiRes qw(time);
63 use lib $FindBin::Bin;
69 sub dumpToolDidCrash();
71 sub countAndPrintLeaks($$$);
72 sub fileNameWithNumber($$);
74 sub openHTTPDIfNeeded();
76 sub processIgnoreTests($);
79 sub stripExtension($);
80 sub isTextOnlyTest($);
81 sub expectedDirectoryForTest($;$);
82 sub printFailureMessageForTest($$);
86 sub validateSkippedArg($$;$);
87 sub htmlForExpectedAndActualResults($);
88 sub deleteExpectedAndActualResults($);
89 sub recordActualResultsAndDiff($$);
90 sub buildPlatformHierarchy();
93 my $addPlatformExceptions = 0;
94 my $configuration = configuration();
97 my $httpdSSLPort = 8443;
103 my $repaintSweepHorizontally = '';
104 my $repaintTests = '';
105 my $report10Slowest = 0;
106 my $resetResults = 0;
107 my $shouldCheckLeaks = 0;
109 my $testsPerDumpTool = 1000;
112 my $testResultsDirectory = "/tmp/layout-test-results";
115 my $treatSkipped = "default";
118 my $strictTesting = 0;
119 my $generateNewResults = 1;
120 my $stripEditingCallbacks = isCygwin();
123 my $expectedTag = "expected";
124 my $actualTag = "actual";
125 my $diffsTag = "diffs";
126 my $errorTag = "stderr";
129 $platform = "mac-tiger";
130 } elsif (isLeopard()) {
131 $platform = "mac-leopard";
138 } elsif (isCygwin()) {
142 if (!defined($platform)) {
143 print "WARNING: Your platform is not recognized. Any platform-specific results will be generated in platform/undefined.\n";
144 $platform = "undefined";
147 my $programName = basename($0);
148 my $launchSafariDefault = $launchSafari ? "launch" : "do not launch";
149 my $httpDefault = $testHTTP ? "run" : "do not run";
151 # FIXME: "--strict" should be renamed to qt-mac-comparison, or something along those lines.
153 Usage: $programName [options] [testdir|testpath ...]
154 --add-platform-exceptions Put new results for non-platform-specific failing tests into the platform-specific results directory
155 -c|--configuration config Set DumpRenderTree build configuration
156 -g|--guard-malloc Enable malloc guard
157 --help Show this help message
158 -h|--horizontal-sweep Change repaint to sweep horizontally instead of vertically (implies --repaint-tests)
159 --[no-]http Run (or do not run) http tests (default: $httpDefault)
160 -i|--ignore-tests Comma-separated list of directories or tests to ignore
161 --[no-]launch-safari Launch (or do not launch) Safari to display test results (default: $launchSafariDefault)
162 -l|--leaks Enable leaks checking
163 --[no-]new-test-results Generate results for new tests
164 -p|--pixel-tests Enable pixel tests
165 --platform Override the detected platform to use for tests and results (default: $platform)
166 --port Web server port to use with http tests
167 -q|--quiet Less verbose output
168 -r|--repaint-tests Run repaint tests (implies --pixel-tests)
169 --reset-results Reset ALL results (including pixel tests if --pixel-tests is set)
170 -o|--results-directory Output results directory (default: $testResultsDirectory)
171 --root Path to root tools build
172 -1|--singly Isolate each test case run (implies --verbose)
173 --skipped=[default|ignore|only] Specifies how to treat the Skipped file
174 default: Tests/directories listed in the Skipped file are not tested
175 ignore: The Skipped file is ignored
176 only: Only those tests/directories listed in the Skipped file will be run
177 --slowest Report the 10 slowest tests
178 --strict Do a comparison with the output on Mac (Qt only)
179 --[no-]strip-editing-callbacks Remove editing callbacks from expected results
180 -t|--threaded Run a concurrent JavaScript thead with each test
181 --threshold t Ignore pixel value deviations less than or equal to t
182 --valgrind Run DumpRenderTree inside valgrind (Qt/Linux only)
183 -v|--verbose More verbose output (overrides --quiet)
186 my $getOptionsResult = GetOptions(
187 'c|configuration=s' => \$configuration,
188 'debug|devel' => sub { $configuration = "Debug" },
189 'guard-malloc|g' => \$guardMalloc,
190 'help' => \$showHelp,
191 'horizontal-sweep|h' => \$repaintSweepHorizontally,
192 'http!' => \$testHTTP,
193 'ignore-tests|i=s' => \$ignoreTests,
194 'launch-safari!' => \$launchSafari,
195 'leaks|l' => \$shouldCheckLeaks,
196 'pixel-tests|p' => \$pixelTests,
197 'platform=s' => \$platform,
198 'port=i' => \$httpdPort,
199 'quiet|q' => \$quiet,
200 'release|deploy' => sub { $configuration = "Release" },
201 'repaint-tests|r' => \$repaintTests,
202 'reset-results' => \$resetResults,
203 'new-test-results!' => \$generateNewResults,
204 'results-directory|o=s' => \$testResultsDirectory,
205 'singly|1' => sub { $testsPerDumpTool = 1; },
206 'nthly=i' => \$testsPerDumpTool,
207 'skipped=s' => \&validateSkippedArg,
208 'slowest' => \$report10Slowest,
209 'threaded|t' => \$threaded,
210 'threshold=i' => \$threshold,
211 'verbose|v' => \$verbose,
212 'valgrind' => \$useValgrind,
213 'strict' => \$strictTesting,
214 'strip-editing-callbacks!' => \$stripEditingCallbacks,
216 'add-platform-exceptions' => \$addPlatformExceptions,
219 if (!$getOptionsResult || $showHelp) {
224 my $ignoreSkipped = $treatSkipped eq "ignore";
225 my $skippedOnly = $treatSkipped eq "only";
227 !$skippedOnly || @ARGV == 0 or die "--skipped=only cannot be used when tests are specified on the command line.";
229 setConfiguration($configuration);
231 my $configurationOption = "--" . lc($configuration);
233 $repaintTests = 1 if $repaintSweepHorizontally;
235 $pixelTests = 1 if $repaintTests;
236 $pixelTests = 1 if $threshold > 0;
238 $verbose = 1 if $testsPerDumpTool == 1;
240 if ($shouldCheckLeaks && $testsPerDumpTool > 1000) {
241 print STDERR "\nWARNING: Running more than 1000 tests at a time with MallocStackLogging enabled may cause a crash.\n\n";
244 # Force --no-http for Qt/Linux, for now.
245 $testHTTP = 0 if isQt();
247 # Stack logging does not play well with QuickTime on Tiger (rdar://problem/5537157)
248 $testMedia = 0 if $shouldCheckLeaks && isTiger();
250 setConfigurationProductDir(Cwd::abs_path($root)) if (defined($root));
251 my $productDir = productDir();
252 $productDir .= "/bin" if (isQt());
257 # Push the parameters to build-dumprendertree as an array
259 push(@args, "--" . $configuration);
260 push(@args, "--qt") if isQt();
261 push(@args, "--gtk") if isGtk();
263 my $buildResult = system "WebKitTools/Scripts/build-dumprendertree", @args;
265 print STDERR "Compiling DumpRenderTree failed!\n";
266 exit exitStatus($buildResult);
270 my $dumpToolName = "DumpRenderTree";
271 $dumpToolName .= "_debug" if isCygwin() && $configuration ne "Release";
272 my $dumpTool = "$productDir/$dumpToolName";
273 die "can't find executable $dumpToolName (looked in $productDir)\n" unless -x $dumpTool;
275 my $imageDiffTool = "$productDir/ImageDiff";
276 die "can't find executable $imageDiffTool (looked in $productDir)\n" if $pixelTests && !-x $imageDiffTool;
278 checkFrameworks() unless isCygwin();
280 my $layoutTestsName = "LayoutTests";
281 my $testDirectory = File::Spec->rel2abs($layoutTestsName);
282 my $expectedDirectory = $testDirectory;
283 my $platformBaseDirectory = catdir($testDirectory, "platform");
284 my $platformTestDirectory = catdir($platformBaseDirectory, $platform);
285 my @platformHierarchy = buildPlatformHierarchy();
287 $expectedDirectory = $ENV{"WebKitExpectedTestResultsDirectory"} if $ENV{"WebKitExpectedTestResultsDirectory"};
289 my $testResults = catfile($testResultsDirectory, "results.html");
291 print "Running tests from $testDirectory\n";
296 system "ln", "-s", $testDirectory, "/tmp/LayoutTests" unless -x "/tmp/LayoutTests";
298 my %ignoredFiles = ();
299 my %ignoredDirectories = map { $_ => 1 } qw(platform);
300 my %ignoredLocalDirectories = map { $_ => 1 } qw(.svn _svn resources);
301 my %supportedFileExtensions = map { $_ => 1 } qw(html shtml xml xhtml pl php);
302 if (checkWebCoreSVGSupport(0)) {
303 $supportedFileExtensions{'svg'} = 1;
304 } elsif (isCygwin()) {
305 # FIXME: We should fix webkitdirs.pm:hasSVGSupport() to do the correct
306 # check for Windows instead of forcing this here.
307 $supportedFileExtensions{'svg'} = 1;
309 $ignoredLocalDirectories{'svg'} = 1;
312 $ignoredDirectories{'http'} = 1;
316 $ignoredDirectories{'media'} = 1;
320 processIgnoreTests($ignoreTests);
323 if (!$ignoreSkipped) {
324 foreach my $level (@platformHierarchy) {
325 if (open SKIPPED, "<", "$level/Skipped") {
326 if ($verbose && !$skippedOnly) {
327 my ($dir, $name) = splitpath($level);
328 print "Skipped tests in $name:\n";
334 $skipped =~ s/^[ \n\r]+//;
335 $skipped =~ s/[ \n\r]+$//;
336 if ($skipped && $skipped !~ /^#/) {
338 push(@ARGV, $skipped);
343 processIgnoreTests($skipped);
353 my $directoryFilter = sub {
354 return () if exists $ignoredLocalDirectories{basename($File::Find::dir)};
355 return () if exists $ignoredDirectories{File::Spec->abs2rel($File::Find::dir, $testDirectory)};
359 my $fileFilter = sub {
361 if ($filename =~ /\.([^.]+)$/) {
362 if (exists $supportedFileExtensions{$1}) {
363 my $path = File::Spec->abs2rel(catfile($File::Find::dir, $filename), $testDirectory);
364 push @tests, $path if !exists $ignoredFiles{$path};
369 for my $test (@ARGV) {
370 $test =~ s/^($layoutTestsName|$testDirectory)\///;
371 my $fullPath = catfile($testDirectory, $test);
372 if (file_name_is_absolute($test)) {
373 print "can't run test $test outside $testDirectory\n";
374 } elsif (-f $fullPath) {
375 my ($filename, $pathname, $fileExtension) = fileparse($test, qr{\.[^.]+$});
376 if (!exists $supportedFileExtensions{substr($fileExtension, 1)}) {
377 print "test $test does not have a supported extension\n";
378 } elsif ($testHTTP || $pathname !~ /^http\//) {
381 } elsif (-d $fullPath) {
382 find({ preprocess => $directoryFilter, wanted => $fileFilter }, $fullPath);
384 for my $level (@platformHierarchy) {
385 my $platformPath = catfile($level, $test);
386 find({ preprocess => $directoryFilter, wanted => $fileFilter }, $platformPath) if (-d $platformPath);
389 print "test $test not found\n";
393 find({ preprocess => $directoryFilter, wanted => $fileFilter }, $testDirectory);
395 for my $level (@platformHierarchy) {
396 find({ preprocess => $directoryFilter, wanted => $fileFilter }, $level);
400 die "no tests to run\n" if !@tests;
402 @tests = sort pathcmp @tests;
407 my %imageDifferences;
410 my $leaksOutputFileNumber = 1;
414 push @toolArgs, "--dump-all-pixels" if $pixelTests && $resetResults;
415 push @toolArgs, "--pixel-tests" if $pixelTests;
416 push @toolArgs, "--repaint" if $repaintTests;
417 push @toolArgs, "--horizontal-sweep" if $repaintSweepHorizontally;
418 push @toolArgs, "--threaded" if $threaded;
419 push @toolArgs, "--paint" if $shouldCheckLeaks; # Otherwise, DRT won't exercise painting leaks.
422 my @diffToolArgs = ();
423 push @diffToolArgs, "--threshold", $threshold;
427 my $imageDiffToolPID;
430 $ENV{MallocStackLogging} = 1 if $shouldCheckLeaks;
431 $imageDiffToolPID = open2(\*DIFFIN, \*DIFFOUT, $imageDiffTool, @diffToolArgs) or die "unable to open $imageDiffTool\n";
435 my $isDumpToolOpen = 0;
436 my $dumpToolCrashed = 0;
439 my $lastDirectory = "";
443 sub catch_pipe { $dumpToolCrashed = 1; }
444 $SIG{"PIPE"} = "catch_pipe";
446 print "Testing ", scalar @tests, " test cases.\n";
447 my $overallStartTime = time;
449 my %expectedResultDirectory;
451 for my $test (@tests) {
452 next if $test eq 'results.html';
456 my $base = stripExtension($test);
459 print "running $test -> ";
464 if ($dir ne $lastDirectory) {
465 print "\n" unless $atLineStart;
467 $lastDirectory = $dir;
475 my $startTime = time if $report10Slowest;
477 if ($test !~ /^http\//) {
478 my $testPath = "$testDirectory/$test";
480 $testPath = toWindowsPath($testPath);
482 $testPath = canonpath($testPath);
484 print OUT "$testPath\n";
487 if ($test !~ /^http\/tests\/local\// && $test !~ /^http\/tests\/ssl\//) {
488 my $path = canonpath($test);
489 $path =~ s/^http\/tests\///;
490 print OUT "http://127.0.0.1:$httpdPort/$path\n";
491 } elsif ($test =~ /^http\/tests\/ssl\//) {
492 my $path = canonpath($test);
493 $path =~ s/^http\/tests\///;
494 print OUT "https://127.0.0.1:$httpdSSLPort/$path\n";
496 my $testPath = "$testDirectory/$test";
498 $testPath = toWindowsPath($testPath);
500 $testPath = canonpath($testPath);
502 print OUT "$testPath\n";
511 $actual =~ s/\r//g if isCygwin();
513 my $isText = isTextOnlyTest($actual);
515 $durations{$test} = time - $startTime if $report10Slowest;
518 my $expectedDir = expectedDirectoryForTest($base, $isText);
519 $expectedResultDirectory{$base} = $expectedDir;
521 if (!$resetResults && open EXPECTED, "<", "$expectedDir/$base-$expectedTag.txt") {
524 next if $stripEditingCallbacks && $_ =~ /^EDITING DELEGATE:/;
530 if (!isOSX() && $strictTesting && !$isText) {
531 if (!$resetResults && open EXPECTED, "<", "$testDirectory/platform/mac/$base-$expectedTag.txt") {
540 if ($shouldCheckLeaks && $testsPerDumpTool == 1) {
546 my $diffPercentage = "";
547 my $diffResult = "passed";
551 my $expectedHash = "";
552 my $actualPNGSize = 0;
556 if (/ActualHash: ([a-f0-9]{32})/) {
558 } elsif (/BaselineHash: ([a-f0-9]{32})/) {
560 } elsif (/Content-length: (\d+)\s*/) {
562 read(IN, $actualPNG, $actualPNGSize);
566 if ($expectedHash ne $actualHash && -f "$expectedDir/$base-$expectedTag.png") {
567 my $expectedPNGSize = -s "$expectedDir/$base-$expectedTag.png";
568 my $expectedPNG = "";
569 open EXPECTEDPNG, "$expectedDir/$base-$expectedTag.png";
570 read(EXPECTEDPNG, $expectedPNG, $expectedPNGSize);
572 print DIFFOUT "Content-length: $actualPNGSize\n";
573 print DIFFOUT $actualPNG;
575 print DIFFOUT "Content-length: $expectedPNGSize\n";
576 print DIFFOUT $expectedPNG;
579 last if /^error/ || /^diff:/;
580 if (/Content-length: (\d+)\s*/) {
581 read(DIFFIN, $diffPNG, $1);
585 if (/^diff: (.+)% (passed|failed)/) {
586 $diffPercentage = $1;
587 $imageDifferences{$base} = $diffPercentage;
592 if ($actualPNGSize && ($resetResults || !-f "$expectedDir/$base-$expectedTag.png")) {
593 mkpath catfile($expectedDir, dirname($base)) if $testDirectory ne $expectedDir;
594 open EXPECTED, ">", "$expectedDir/$base-expected.png" or die "could not create $expectedDir/$base-expected.png\n";
595 print EXPECTED $actualPNG;
599 # update the expected hash if the image diff said that there was no difference
600 if ($actualHash ne "" && ($resetResults || !-f "$expectedDir/$base-$expectedTag.checksum")) {
601 open EXPECTED, ">", "$expectedDir/$base-$expectedTag.checksum" or die "could not create $expectedDir/$base-$expectedTag.checksum\n";
602 print EXPECTED $actualHash;
607 if (!isOSX() && $strictTesting && !$isText) {
608 if (defined $expectedMac) {
609 my $simplified_actual;
610 $simplified_actual = $actual;
611 $simplified_actual =~ s/at \(-?[0-9]+,-?[0-9]+\) *//g;
612 $simplified_actual =~ s/size -?[0-9]+x-?[0-9]+ *//g;
613 $simplified_actual =~ s/text run width -?[0-9]+: //g;
614 $simplified_actual =~ s/text run width -?[0-9]+ [a-zA-Z ]+: //g;
615 $simplified_actual =~ s/RenderButton {BUTTON} .*/RenderButton {BUTTON}/g;
616 $simplified_actual =~ s/RenderImage {INPUT} .*/RenderImage {INPUT}/g;
617 $simplified_actual =~ s/RenderBlock {INPUT} .*/RenderBlock {INPUT}/g;
618 $simplified_actual =~ s/RenderTextControl {INPUT} .*/RenderTextControl {INPUT}/g;
619 $simplified_actual =~ s/\([0-9]+px/px/g;
620 $simplified_actual =~ s/ *" *\n +" */ /g;
621 $simplified_actual =~ s/" +$/"/g;
623 $simplified_actual =~ s/- /-/g;
624 $simplified_actual =~ s/\n( *)"\s+/\n$1"/g;
625 $simplified_actual =~ s/\s+"\n/"\n/g;
627 $expectedMac =~ s/at \(-?[0-9]+,-?[0-9]+\) *//g;
628 $expectedMac =~ s/size -?[0-9]+x-?[0-9]+ *//g;
629 $expectedMac =~ s/text run width -?[0-9]+: //g;
630 $expectedMac =~ s/text run width -?[0-9]+ [a-zA-Z ]+: //g;
631 $expectedMac =~ s/RenderButton {BUTTON} .*/RenderButton {BUTTON}/g;
632 $expectedMac =~ s/RenderImage {INPUT} .*/RenderImage {INPUT}/g;
633 $expectedMac =~ s/RenderBlock {INPUT} .*/RenderBlock {INPUT}/g;
634 $expectedMac =~ s/RenderTextControl {INPUT} .*/RenderTextControl {INPUT}/g;
635 $expectedMac =~ s/\([0-9]+px/px/g;
636 $expectedMac =~ s/ *" *\n +" */ /g;
637 $expectedMac =~ s/" +$/"/g;
639 $expectedMac =~ s/- /-/g;
640 $expectedMac =~ s/\n( *)"\s+/\n$1"/g;
641 $expectedMac =~ s/\s+"\n/"\n/g;
643 if ($simplified_actual ne $expectedMac) {
644 open ACTUAL, ">", "/tmp/actual.txt" or die;
645 print ACTUAL $simplified_actual;
647 open ACTUAL, ">", "/tmp/expected.txt" or die;
648 print ACTUAL $expectedMac;
650 system "diff -u \"/tmp/expected.txt\" \"/tmp/actual.txt\" > \"/tmp/simplified.diff\"";
652 $diffResult = "failed";
655 system "cat /tmp/simplified.diff";
662 if (dumpToolDidCrash()) {
665 printFailureMessageForTest($test, "crashed");
667 my $dir = "$testResultsDirectory/$base";
668 $dir =~ s|/([^/]+)$|| or die "Failed to find test name from base\n";
671 deleteExpectedAndActualResults($base);
673 open CRASH, ">", "$testResultsDirectory/$base-$errorTag.txt" or die;
677 recordActualResultsAndDiff($base, $actual);
680 } elsif (!defined $expected) {
682 print "new " . ($resetResults ? "result" : "test") ."\n";
687 if ($generateNewResults || $resetResults) {
688 mkpath catfile($expectedDir, dirname($base)) if $testDirectory ne $expectedDir;
689 open EXPECTED, ">", "$expectedDir/$base-$expectedTag.txt" or die "could not create $expectedDir/$base-$expectedTag.txt\n";
690 print EXPECTED $actual;
693 deleteExpectedAndActualResults($base);
694 unless ($resetResults) {
695 # Always print the file name for new tests, as they will probably need some manual inspection.
696 # in verbose mode we already printed the test case, so no need to do it again.
698 print "\n" unless $atLineStart;
701 my $resultsDir = catdir($expectedDir, dirname($base));
702 print "new (results generated in $resultsDir)\n";
705 } elsif ($actual eq $expected && $diffResult eq "passed") {
711 deleteExpectedAndActualResults($base);
713 $result = "mismatch";
715 my $message = $actual eq $expected ? "pixel test failed" : "failed";
717 if ($actual ne $expected && $addPlatformExceptions) {
718 my $testBase = catfile($testDirectory, $base);
719 my $expectedBase = catfile($expectedDir, $base);
720 my $testIsMaximallyPlatformSpecific = $testBase =~ m|^\Q$platformTestDirectory\E/|;
721 my $expectedResultIsMaximallyPlatformSpecific = $expectedBase =~ m|^\Q$platformTestDirectory\E/|;
722 if (!$testIsMaximallyPlatformSpecific && !$expectedResultIsMaximallyPlatformSpecific) {
723 mkpath catfile($platformTestDirectory, dirname($base));
724 my $expectedFile = catfile($platformTestDirectory, "$base-$expectedTag.txt");
725 open EXPECTED, ">", $expectedFile or die "could not create $expectedFile\n";
726 print EXPECTED $actual;
728 $message .= " (results generated in $platformTestDirectory)";
732 printFailureMessageForTest($test, $message);
734 my $dir = "$testResultsDirectory/$base";
735 $dir =~ s|/([^/]+)$|| or die "Failed to find test name from base\n";
739 deleteExpectedAndActualResults($base);
740 recordActualResultsAndDiff($base, $actual);
742 if ($pixelTests && $diffPNG && $diffPNG ne "") {
743 $imagesPresent{$base} = 1;
745 open ACTUAL, ">", "$testResultsDirectory/$base-$actualTag.png" or die;
746 print ACTUAL $actualPNG;
749 open DIFF, ">", "$testResultsDirectory/$base-$diffsTag.png" or die;
753 copy("$expectedDir/$base-$expectedTag.png", "$testResultsDirectory/$base-$expectedTag.png");
755 open DIFFHTML, ">$testResultsDirectory/$base-$diffsTag.html" or die;
756 print DIFFHTML "<html>\n";
757 print DIFFHTML "<head>\n";
758 print DIFFHTML "<title>$base Image Compare</title>\n";
759 print DIFFHTML "<script language=\"Javascript\" type=\"text/javascript\">\n";
760 print DIFFHTML "var currentImage = 0;\n";
761 print DIFFHTML "var imageNames = new Array(\"Actual\", \"Expected\");\n";
762 print DIFFHTML "var imagePaths = new Array(\"$testName-$actualTag.png\", \"$testName-$expectedTag.png\");\n";
763 if (-f "$testDirectory/$base-w3c.png") {
764 copy("$testDirectory/$base-w3c.png", "$testResultsDirectory/$base-w3c.png");
765 print DIFFHTML "imageNames.push(\"W3C\");\n";
766 print DIFFHTML "imagePaths.push(\"$testName-w3c.png\");\n";
768 print DIFFHTML "function animateImage() {\n";
769 print DIFFHTML " var image = document.getElementById(\"animatedImage\");\n";
770 print DIFFHTML " var imageText = document.getElementById(\"imageText\");\n";
771 print DIFFHTML " image.src = imagePaths[currentImage];\n";
772 print DIFFHTML " imageText.innerHTML = imageNames[currentImage] + \" Image\";\n";
773 print DIFFHTML " currentImage = (currentImage + 1) % imageNames.length;\n";
774 print DIFFHTML " setTimeout('animateImage()',2000);\n";
775 print DIFFHTML "}\n";
776 print DIFFHTML "</script>\n";
777 print DIFFHTML "</head>\n";
778 print DIFFHTML "<body onLoad=\"animateImage();\">\n";
779 print DIFFHTML "<table>\n";
780 if ($diffPercentage) {
781 print DIFFHTML "<tr>\n";
782 print DIFFHTML "<td>Difference between images: <a href=\"$testName-$diffsTag.png\">$diffPercentage%</a></td>\n";
783 print DIFFHTML "</tr>\n";
785 print DIFFHTML "<tr>\n";
786 print DIFFHTML "<td><a href=\"" . toURL("$testDirectory/$test") . "\">test file</a></td>\n";
787 print DIFFHTML "</tr>\n";
788 print DIFFHTML "<tr>\n";
789 print DIFFHTML "<td id=\"imageText\" style=\"text-weight: bold;\">Actual Image</td>\n";
790 print DIFFHTML "</tr>\n";
791 print DIFFHTML "<tr>\n";
792 print DIFFHTML "<td><img src=\"$testName-$actualTag.png\" id=\"animatedImage\"></td>\n";
793 print DIFFHTML "</tr>\n";
794 print DIFFHTML "</table>\n";
795 print DIFFHTML "</body>\n";
796 print DIFFHTML "</html>\n";
800 if (($count + 1) % $testsPerDumpTool == 0 || $count == $#tests) {
801 if ($shouldCheckLeaks) {
803 if ($testsPerDumpTool == 1) {
804 $fileName = "$testResultsDirectory/$base-leaks.txt";
806 $fileName = "$testResultsDirectory/" . fileNameWithNumber($dumpToolName, $leaksOutputFileNumber) . "-leaks.txt";
808 my $leakCount = countAndPrintLeaks($dumpToolName, $dumpToolPID, $fileName);
809 $totalLeaks += $leakCount;
810 $leaksOutputFileNumber++ if ($leakCount);
818 push @{$tests{$result}}, $test;
819 $testType{$test} = $isText;
821 printf "\n%0.2fs total testing time\n", (time - $overallStartTime) . "";
823 !$isDumpToolOpen || die "Failed to close $dumpToolName.\n";
827 # Because multiple instances of this script are running concurrently we cannot
828 # safely delete this symlink.
829 # system "rm /tmp/LayoutTests";
831 # FIXME: Do we really want to check the image-comparison tool for leaks every time?
832 if ($shouldCheckLeaks && $pixelTests) {
833 $totalLeaks += countAndPrintLeaks("ImageDiff", $imageDiffToolPID, "$testResultsDirectory/ImageDiff-leaks.txt");
837 print "\nWARNING: $totalLeaks total leaks found!\n";
838 print "See above for individual leaks results.\n" if ($leaksOutputFileNumber > 2);
845 if ($report10Slowest) {
846 print "\n\nThe 10 slowest tests:\n\n";
848 for my $test (sort slowestcmp keys %durations) {
849 printf "%0.2f secs: %s\n", $durations{$test}, $test;
850 last if ++$count == 10;
856 if ($skippedOnly && $counts{"match"}) {
857 print "The following tests are in the Skipped file (" . File::Spec->abs2rel("$platformTestDirectory/Skipped", $testDirectory) . "), but succeeded:\n";
858 foreach my $test (@{$tests{"match"}}) {
863 if ($resetResults || ($counts{match} && $counts{match} == $count)) {
864 print "all $count test cases succeeded\n";
871 match => "succeeded",
872 mismatch => "had incorrect layout",
877 for my $type ("match", "mismatch", "new", "crash") {
878 my $c = $counts{$type};
880 my $t = $text{$type};
884 $message = sprintf "1 test case (%d%%) %s\n", 1 * 100 / $count, $t;
886 $message = sprintf "%d test cases (%d%%) %s\n", $c, $c * 100 / $count, $t;
888 $message =~ s-\(0%\)-(<1%)-;
893 mkpath $testResultsDirectory;
895 open HTML, ">", $testResults or die;
896 print HTML "<html>\n";
897 print HTML "<head>\n";
898 print HTML "<title>Layout Test Results</title>\n";
899 print HTML "</head>\n";
900 print HTML "<body>\n";
902 if ($counts{mismatch}) {
903 print HTML "<p>Tests where results did not match expected results:</p>\n";
904 print HTML "<table>\n";
905 for my $test (@{$tests{mismatch}}) {
906 my $base = stripExtension($test);
908 print HTML "<td><a href=\"" . toURL("$testDirectory/$test") . "\">$test</a></td>\n";
909 print HTML htmlForExpectedAndActualResults($base);
911 if ($imagesPresent{$base}) {
912 print HTML "<td><a href=\"" . toURL("$base-$expectedTag.png") . "\">expected image</a></td>\n";
913 print HTML "<td><a href=\"" . toURL("$base-$diffsTag.html") . "\">image diffs</a>\n";
914 print HTML "<a href=\"" . toURL("$base-$diffsTag.png") . "\">$imageDifferences{$base}%</a></td>\n";
916 print HTML "<td></td><td></td>\n";
919 print HTML "</tr>\n";
921 print HTML "</table>\n";
924 if ($counts{crash}) {
925 print HTML "<p>Tests that caused the DumpRenderTree tool to crash:</p>\n";
926 print HTML "<table>\n";
927 for my $test (@{$tests{crash}}) {
928 my $base = stripExtension($test);
929 my $expectedDir = $expectedResultDirectory{$base};
931 print HTML "<td><a href=\"" . toURL("$testDirectory/$test") . "\">$base</a></td>\n";
932 print HTML htmlForExpectedAndActualResults($base);
933 print HTML "<td><a href=\"$base-$errorTag.txt\">stderr</a></td>\n";
934 print HTML "</tr>\n";
936 print HTML "</table>\n";
940 print HTML "<p>Tests that had no expected results (probably new):</p>\n";
941 print HTML "<table>\n";
942 for my $test (@{$tests{new}}) {
943 my $base = stripExtension($test);
944 my $expectedDir = $expectedResultDirectory{$base};
946 print HTML "<td><a href=\"" . toURL("$testDirectory/$test") . "\">$base</a></td>\n";
947 print HTML "<td><a href=\"" . toURL("$expectedDir/$base-$expectedTag.txt") . "\">results</a></td>\n";
948 if ($pixelTests && -f "$expectedDir/$base-$expectedTag.png") {
949 print HTML "<td><a href=\"" . toURL("$expectedDir/$base-$expectedTag.png") . "\">image</a></td>\n";
951 print HTML "</tr>\n";
953 print HTML "</table>\n";
956 print HTML "</body>\n";
957 print HTML "</html>\n";
961 system "konqueror", $testResults if $launchSafari;
962 } elsif (isCygwin()) {
963 system "cygstart", $testResults if $launchSafari;
965 system "WebKitTools/Scripts/run-safari", $configurationOption, "-NSOpen", $testResults if $launchSafari;
968 closeCygpaths() if isCygwin();
972 sub countAndPrintLeaks($$$)
974 my ($dumpToolName, $dumpToolPID, $leaksFilePath) = @_;
976 print "\n" unless $atLineStart;
979 # We are excluding the following reported leaks so they don't get in our way when looking for WebKit leaks:
980 # This allows us ignore known leaks and only be alerted when new leaks occur. Some leaks are in the old
981 # versions of the system frameworks that are being used by the leaks bots. Even though a leak has been
982 # fixed, it will be listed here until the bot has been updated with the newer frameworks.
984 my @typesToExclude = (
987 my @callStacksToExclude = (
988 "Flash_EnforceLocalSecurity" # leaks in Flash plug-in code, rdar://problem/4449747
992 # Leak list for the version of Tiger used on the build bot.
993 push @callStacksToExclude, (
994 "CFRunLoopRunSpecific \\| malloc_zone_malloc", "CFRunLoopRunSpecific \\| CFAllocatorAllocate ", # leak in CFRunLoopRunSpecific, rdar://problem/4670839
995 "CGImageSourceGetPropertiesAtIndex", # leak in ImageIO, rdar://problem/4628809
996 "FOGetCoveredUnicodeChars", # leak in ATS, rdar://problem/3943604
997 "GetLineDirectionPreference", "InitUnicodeUtilities", # leaks tool falsely reporting leak in CFNotificationCenterAddObserver, rdar://problem/4964790
998 "ICCFPrefWrapper::GetPrefDictionary", # leaks in Internet Config. code, rdar://problem/4449794
999 "NSHTTPURLProtocol setResponseHeader:", # leak in multipart/mixed-replace handling in Foundation, no Radar, but fixed in Leopard
1000 "NSURLCache cachedResponseForRequest", # leak in CFURL cache, rdar://problem/4768430
1001 "PCFragPrepareClosureFromFile", # leak in Code Fragment Manager, rdar://problem/3426998
1002 "WebCore::Selection::toRange", # bug in 'leaks', rdar://problem/4967949
1003 "WebCore::SubresourceLoader::create", # bug in 'leaks', rdar://problem/4985806
1004 "_CFPreferencesDomainDeepCopyDictionary", # leak in CFPreferences, rdar://problem/4220786
1005 "_objc_msgForward", # leak in NSSpellChecker, rdar://problem/4965278
1006 "gldGetString", # leak in OpenGL, rdar://problem/5013699
1007 "_setDefaultUserInfoFromURL", #rdar://problem/5546453 REGRESSION: 3 leaks on Tiger under _setDefaultUserInfoFromURL
1008 "SSLHandshake" #rdar://problem/5546440 REGRESSION: 1 leak on Tiger under SSL
1010 push @typesToExclude, (
1011 "THRD", # bug in 'leaks', Radar 3387783
1012 "DRHT" # ditto (endian little hate i)
1017 # Leak list for the version of Leopard used on the build bot.
1018 push @callStacksToExclude, (
1019 "CFHTTPMessageAppendBytes", # rdar://problem/5435912
1020 "sendDidReceiveDataCallback", # rdar://problem/5441619
1021 "_CFHTTPReadStreamReadMark", # rdar://problem/5441468
1022 "httpProtocolStart", # rdar://problem/5468837
1023 "_CFURLConnectionSendCallbacks", # rdar://problem/5441600
1027 my $leaksTool = sourceDir() . "/WebKitTools/Scripts/run-leaks";
1028 my $excludeString = "--exclude-callstack '" . (join "' --exclude-callstack '", @callStacksToExclude) . "'";
1029 $excludeString .= " --exclude-type '" . (join "' --exclude-type '", @typesToExclude) . "'" if @typesToExclude;
1031 print " ? checking for leaks in $dumpToolName\n";
1032 my $leaksOutput = `$leaksTool $excludeString $dumpToolPID`;
1033 my ($count, $bytes) = $leaksOutput =~ /Process $dumpToolPID: (\d+) leaks? for (\d+) total/;
1034 my ($excluded) = $leaksOutput =~ /(\d+) leaks? excluded/;
1036 my $adjustedCount = $count;
1037 $adjustedCount -= $excluded if $excluded;
1039 if (!$adjustedCount) {
1040 print " - no leaks found\n";
1041 unlink $leaksFilePath;
1044 my $dir = $leaksFilePath;
1045 $dir =~ s|/[^/]+$|| or die;
1049 print " + $adjustedCount leaks ($bytes bytes including $excluded excluded leaks) were found, details in $leaksFilePath\n";
1051 print " + $count leaks ($bytes bytes) were found, details in $leaksFilePath\n";
1054 open LEAKS, ">", $leaksFilePath or die;
1055 print LEAKS $leaksOutput;
1059 return $adjustedCount;
1062 # Break up a path into the directory (with slash) and base name.
1067 my $pathSeparator = "/";
1068 my $dirname = dirname($path) . $pathSeparator;
1069 $dirname = "" if $dirname eq "." . $pathSeparator;
1071 return ($dirname, basename($path));
1074 # Sort first by directory, then by file, so all paths in one directory are grouped
1075 # rather than being interspersed with items from subdirectories.
1076 # Use numericcmp to sort directory and filenames to make order logical.
1079 my ($patha, $pathb) = @_;
1081 my ($dira, $namea) = splitpath($patha);
1082 my ($dirb, $nameb) = splitpath($pathb);
1084 return numericcmp($dira, $dirb) if $dira ne $dirb;
1085 return numericcmp($namea, $nameb);
1088 # Sort numeric parts of strings as numbers, other parts as strings.
1089 # Makes 1.33 come after 1.3, which is cool.
1094 my @a = split /(\d+)/, $aa;
1095 my @b = split /(\d+)/, $bb;
1097 # Compare one chunk at a time.
1098 # Each chunk is either all numeric digits, or all not numeric digits.
1103 # Use numeric comparison if chunks are non-equal numbers.
1104 return $a <=> $b if $a =~ /^\d/ && $b =~ /^\d/ && $a != $b;
1106 # Use string comparison if chunks are any other kind of non-equal string.
1107 return $a cmp $b if $a ne $b;
1110 # One of the two is now empty; compare lengths for result in this case.
1114 # Sort slowest tests first.
1117 my ($testa, $testb) = @_;
1119 my $dura = $durations{$testa};
1120 my $durb = $durations{$testb};
1121 return $durb <=> $dura if $dura != $durb;
1122 return pathcmp($testa, $testb);
1127 return if $isDumpToolOpen;
1129 # Save some requires variables for the linux environment...
1130 my $homeDir = $ENV{'HOME'};
1131 my $libraryPath = $ENV{'LD_LIBRARY_PATH'};
1132 my $dyldLibraryPath = $ENV{'DYLD_LIBRARY_PATH'};
1133 my $dbusAddress = $ENV{'DBUS_SESSION_BUS_ADDRESS'};
1134 my $display = $ENV{'DISPLAY'};
1135 my $testfonts = $ENV{'WEBKIT_TESTFONTS'};
1137 my $homeDrive = $ENV{'HOMEDRIVE'};
1138 my $homePath = $ENV{'HOMEPATH'};
1142 if (defined $display) {
1143 $ENV{DISPLAY} = $display;
1145 $ENV{DISPLAY} = ":1";
1147 $ENV{'WEBKIT_TESTFONTS'} = $testfonts;
1148 $ENV{HOME} = $homeDir;
1149 if (defined $libraryPath) {
1150 $ENV{LD_LIBRARY_PATH} = $libraryPath;
1152 if (defined $dyldLibraryPath) {
1153 $ENV{DYLD_LIBRARY_PATH} = $dyldLibraryPath;
1155 if (defined $dbusAddress) {
1156 $ENV{DBUS_SESSION_BUS_ADDRESS} = $dbusAddress;
1159 $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
1160 $ENV{XML_CATALOG_FILES} = ""; # work around missing /etc/catalog <rdar://problem/4292995>
1161 $ENV{MallocStackLogging} = 1 if $shouldCheckLeaks;
1162 $ENV{DYLD_INSERT_LIBRARIES} = "/usr/lib/libgmalloc.dylib" if $guardMalloc;
1165 $ENV{HOMEDRIVE} = $homeDrive;
1166 $ENV{HOMEPATH} = $homePath;
1167 $ENV{WEBKIT_TESTFONTS} = $testfonts;
1168 setPathForRunningWebKitApp(\%ENV) if isCygwin();
1173 push @args, $dumpTool;
1175 push @args, @toolArgs;
1177 $dumpTool = "valgrind";
1179 $dumpToolPID = open3(\*OUT, \*IN, \*ERROR, $dumpTool, @args) or die "Failed to start tool: $dumpTool\n";
1180 $isDumpToolOpen = 1;
1181 $dumpToolCrashed = 0;
1186 return if !$isDumpToolOpen;
1191 waitpid $dumpToolPID, 0;
1192 $isDumpToolOpen = 0;
1195 sub dumpToolDidCrash()
1197 return 1 if $dumpToolCrashed;
1198 return 0 unless $isDumpToolOpen;
1200 my $pid = waitpid(-1, WNOHANG);
1201 return $pid == $dumpToolPID;
1204 sub openHTTPDIfNeeded()
1206 return if $isHttpdOpen;
1208 mkdir "/tmp/WebKit";
1210 if (-f "/tmp/WebKit/httpd.pid") {
1211 my $oldPid = `cat /tmp/WebKit/httpd.pid`;
1213 if (0 != kill 0, $oldPid) {
1214 print "\nhttpd is already running: pid $oldPid, killing...\n";
1217 my $retryCount = 20;
1218 while ((0 != kill 0, $oldPid) && $retryCount) {
1223 die "Timed out waiting for httpd to quit" unless $retryCount;
1227 my $httpdPath = "/usr/sbin/httpd";
1230 my $windowsConfDirectory = "$testDirectory/http/conf/";
1231 unless (-x "/usr/lib/apache/libphp4.dll") {
1232 copy("$windowsConfDirectory/libphp4.dll", "/usr/lib/apache/libphp4.dll");
1233 chmod(0755, "/usr/lib/apache/libphp4.dll");
1235 $httpdConfig = "$windowsConfDirectory/cygwin-httpd.conf";
1237 $httpdConfig = "$testDirectory/http/conf/httpd.conf";
1238 $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
1240 my $documentRoot = "$testDirectory/http/tests";
1241 my $typesConfig = "$testDirectory/http/conf/mime.types";
1242 my $listen = "127.0.0.1:$httpdPort";
1243 my $absTestResultsDirectory = File::Spec->rel2abs(glob $testResultsDirectory);
1244 my $sslCertificate = "$testDirectory/http/conf/webkit-httpd.pem";
1246 mkpath $absTestResultsDirectory;
1249 "-f", "$httpdConfig",
1250 "-C", "DocumentRoot \"$documentRoot\"",
1251 "-C", "Listen $listen",
1252 "-c", "TypesConfig \"$typesConfig\"",
1253 "-c", "CustomLog \"$absTestResultsDirectory/access_log.txt\" common",
1254 "-c", "ErrorLog \"$absTestResultsDirectory/error_log.txt\"",
1255 # Apache wouldn't run CGIs with permissions==700 otherwise
1256 "-c", "User \"#$<\""
1259 # FIXME: Enable this on Windows once <rdar://problem/5345985> is fixed
1260 push(@args, "-c", "SSLCertificateFile \"$sslCertificate\"") unless isCygwin();
1262 open2(\*HTTPDIN, \*HTTPDOUT, $httpdPath, @args);
1264 my $retryCount = 20;
1265 while (system("/usr/bin/curl -q --silent --stderr - --output /dev/null $listen") && $retryCount) {
1270 die "Timed out waiting for httpd to start" unless $retryCount;
1277 return if !$isHttpdOpen;
1282 kill 15, `cat /tmp/WebKit/httpd.pid` if -f "/tmp/WebKit/httpd.pid";
1287 sub fileNameWithNumber($$)
1289 my ($base, $number) = @_;
1290 return "$base$number" if ($number > 1);
1294 sub processIgnoreTests($) {
1295 my @ignoreList = split(/\s*,\s*/, shift);
1296 my $addIgnoredDirectories = sub {
1297 return () if exists $ignoredLocalDirectories{basename($File::Find::dir)};
1298 $ignoredDirectories{File::Spec->abs2rel($File::Find::dir, $testDirectory)} = 1;
1301 foreach my $item (@ignoreList) {
1302 my $path = catfile($testDirectory, $item);
1304 $ignoredDirectories{$item} = 1;
1305 find({ preprocess => $addIgnoredDirectories, wanted => sub {} }, $path);
1308 $ignoredFiles{$item} = 1;
1311 print "ignoring '$item' on ignore-tests list\n";
1316 sub stripExtension($)
1320 $test =~ s/\.[a-zA-Z]+$//;
1324 sub isTextOnlyTest($)
1328 if ($actual =~ /^layer at/ms) {
1336 sub expectedDirectoryForTest($;$)
1338 my ($base, $isText) = @_;
1340 my @directories = @platformHierarchy;
1341 push @directories, map { catdir($platformBaseDirectory, $_) } qw(mac-leopard mac) if isCygwin();
1342 push @directories, $expectedDirectory;
1344 # If we already have expected results, just return their location.
1345 foreach my $directory (@directories) {
1346 return $directory if (-f "$directory/$base-$expectedTag.txt");
1349 # For platform-specific tests, the results should go right next to the test itself.
1350 # Note: The return value of this subroutine will be concatenated with $base
1351 # to determine the location of the new results, so returning $expectedDirectory
1352 # will put the results right next to the test.
1353 # FIXME: We want to allow platform/mac tests with platform/mac-leopard results,
1354 # so this needs to be enhanced.
1355 return $expectedDirectory if $base =~ /^platform/;
1357 # For cross-platform tests, text-only results should go in the cross-platform directory,
1358 # while render tree dumps should go in the least-specific platform directory.
1359 return $isText ? $expectedDirectory : $platformHierarchy[$#platformHierarchy];
1362 sub printFailureMessageForTest($$)
1364 my ($test, $description) = @_;
1367 print "\n" unless $atLineStart;
1370 print "$description\n";
1376 sub openCygpathIfNeeded($)
1380 return unless isCygwin();
1381 return $cygpaths{$options} if $cygpaths{$options} && $cygpaths{$options}->{"open"};
1383 local (*CYGPATHIN, *CYGPATHOUT);
1384 my $pid = open2(\*CYGPATHIN, \*CYGPATHOUT, "cygpath -f - $options");
1388 "out" => *CYGPATHOUT,
1392 $cygpaths{$options} = $cygpath;
1399 return unless isCygwin();
1401 foreach my $cygpath (values(%cygpaths)) {
1402 close $cygpath->{"in"};
1403 close $cygpath->{"out"};
1404 waitpid($cygpath->{"pid"}, 0);
1405 $cygpath->{"open"} = 0;
1410 sub convertPathUsingCygpath($$)
1412 my ($path, $options) = @_;
1414 my $cygpath = openCygpathIfNeeded($options);
1415 local *inFH = $cygpath->{"in"};
1416 local *outFH = $cygpath->{"out"};
1417 print outFH $path . "\n";
1418 chomp(my $convertedPath = <inFH>);
1419 return $convertedPath;
1422 sub toWindowsPath($)
1425 return unless isCygwin();
1427 return convertPathUsingCygpath($path, "-w");
1433 return $path unless isCygwin();
1435 return "file:///" . convertPathUsingCygpath($path, "-m");
1438 sub validateSkippedArg($$;$)
1440 my ($option, $value, $value2) = @_;
1441 my %validSkippedValues = map { $_ => 1 } qw(default ignore only);
1442 $value = lc($value);
1443 die "Invalid argument '" . $value . "' for option $option" unless $validSkippedValues{$value};
1444 $treatSkipped = $value;
1447 sub htmlForExpectedAndActualResults($)
1451 return "<td></td><td></td><td></td>\n" unless -s "$testResultsDirectory/$base-$diffsTag.txt";
1453 return "<td><a href=\"$base-$expectedTag.txt\">expected</a></td>\n"
1454 . "<td><a href=\"$base-$actualTag.txt\">actual</a></td>\n"
1455 . "<td><a href=\"$base-$diffsTag.txt\">diffs</a></td>\n";
1458 sub deleteExpectedAndActualResults($)
1462 unlink "$testResultsDirectory/$base-$actualTag.txt";
1463 unlink "$testResultsDirectory/$base-$diffsTag.txt";
1464 unlink "$testResultsDirectory/$base-$errorTag.txt";
1467 sub recordActualResultsAndDiff($$)
1469 my ($base, $actual) = @_;
1471 return unless length($actual);
1473 open ACTUAL, ">", "$testResultsDirectory/$base-$actualTag.txt" or die "Couldn't open actual results file for $base";
1474 print ACTUAL $actual;
1477 my $expectedDir = $expectedResultDirectory{$base};
1478 copy("$expectedDir/$base-$expectedTag.txt", "$testResultsDirectory/$base-$expectedTag.txt");
1480 system "diff -u \"$testResultsDirectory/$base-$expectedTag.txt\" \"$testResultsDirectory/$base-$actualTag.txt\" > \"$testResultsDirectory/$base-$diffsTag.txt\"";
1483 sub buildPlatformHierarchy()
1485 mkpath($platformTestDirectory) if ($platform eq "undefined" && !-d "$platformTestDirectory");
1487 my @platforms = split('-', $platform);
1489 for (my $i=0; $i < @platforms; $i++) {
1490 my $scoped = catdir($platformBaseDirectory, join('-', @platforms[0..($#platforms - $i)]));
1491 push(@hierarchy, $scoped) if (-d $scoped);