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;
111 my $testOnlySVGs = '';
112 my $testResultsDirectory = "/tmp/layout-test-results";
114 my $treatSkipped = "default";
117 my $strictTesting = 0;
118 my $generateNewResults = 1;
119 my $stripEditingCallbacks = isCygwin();
122 my $expectedTag = "expected";
123 my $actualTag = "actual";
124 my $diffsTag = "diffs";
125 my $errorTag = "stderr";
128 $platform = "mac-tiger";
129 } elsif (isLeopard()) {
130 $platform = "mac-leopard";
137 } elsif (isCygwin()) {
141 if (!defined($platform)) {
142 print "WARNING: Your platform is not recognized. Any platform-specific results will be generated in platform/undefined.\n";
143 $platform = "undefined";
146 my $programName = basename($0);
147 my $launchSafariDefault = $launchSafari ? "launch" : "do not launch";
148 my $httpDefault = $testHTTP ? "run" : "do not run";
150 # FIXME: "--strict" should be renamed to qt-mac-comparison, or something along those lines.
152 Usage: $programName [options] [testdir|testpath ...]
153 --add-platform-exceptions Put new results for non-platform-specific failing tests into the platform-specific results directory
154 -c|--configuration config Set DumpRenderTree build configuration
155 -g|--guard-malloc Enable malloc guard
156 --help Show this help message
157 -h|--horizontal-sweep Change repaint to sweep horizontally instead of vertically (implies --repaint-tests)
158 --[no-]http Run (or do not run) http tests (default: $httpDefault)
159 -i|--ignore-tests Comma-separated list of directories or tests to ignore
160 --[no-]launch-safari Launch (or do not launch) Safari to display test results (default: $launchSafariDefault)
161 -l|--leaks Enable leaks checking
162 --[no-]new-test-results Generate results for new tests
163 -p|--pixel-tests Enable pixel tests
164 --platform Override the detected platform to use for tests and results (default: $platform)
165 --port Web server port to use with http tests
166 -q|--quiet Less verbose output
167 -r|--repaint-tests Run repaint tests (implies --pixel-tests)
168 --reset-results Reset ALL results (including pixel tests if --pixel-tests is set)
169 -o|--results-directory Output results directory (default: $testResultsDirectory)
170 --root Path to root tools build
171 -1|--singly Isolate each test case run (implies --verbose)
172 --skipped=[default|ignore|only] Specifies how to treat the Skipped file
173 default: Tests/directories listed in the Skipped file are not tested
174 ignore: The Skipped file is ignored
175 only: Only those tests/directories listed in the Skipped file will be run
176 --slowest Report the 10 slowest tests
177 --strict Do a comparison with the output on Mac (Qt only)
178 --[no-]strip-editing-callbacks Remove editing callbacks from expected results
179 --svg Run only SVG tests (implies --pixel-tests)
180 -t|--threaded Run a concurrent JavaScript thead with each test
181 --valgrind Run DumpRenderTree inside valgrind (Qt/Linux only)
182 -v|--verbose More verbose output (overrides --quiet)
185 my $getOptionsResult = GetOptions(
186 'c|configuration=s' => \$configuration,
187 'debug|devel' => sub { $configuration = "Debug" },
188 'guard-malloc|g' => \$guardMalloc,
189 'help' => \$showHelp,
190 'horizontal-sweep|h' => \$repaintSweepHorizontally,
191 'http!' => \$testHTTP,
192 'ignore-tests|i=s' => \$ignoreTests,
193 'launch-safari!' => \$launchSafari,
194 'leaks|l' => \$shouldCheckLeaks,
195 'pixel-tests|p' => \$pixelTests,
196 'platform=s' => \$platform,
197 'port=i' => \$httpdPort,
198 'quiet|q' => \$quiet,
199 'release|deploy' => sub { $configuration = "Release" },
200 'repaint-tests|r' => \$repaintTests,
201 'reset-results' => \$resetResults,
202 'new-test-results!' => \$generateNewResults,
203 'results-directory|o=s' => \$testResultsDirectory,
204 'singly|1' => sub { $testsPerDumpTool = 1; },
205 'nthly=i' => \$testsPerDumpTool,
206 'skipped=s' => \&validateSkippedArg,
207 'slowest' => \$report10Slowest,
208 'svg' => \$testOnlySVGs,
209 'threaded|t' => \$threaded,
210 'verbose|v' => \$verbose,
211 'valgrind' => \$useValgrind,
212 'strict' => \$strictTesting,
213 'strip-editing-callbacks!' => \$stripEditingCallbacks,
215 'add-platform-exceptions' => \$addPlatformExceptions,
218 if (!$getOptionsResult || $showHelp) {
223 my $ignoreSkipped = $treatSkipped eq "ignore";
224 my $skippedOnly = $treatSkipped eq "only";
226 !$skippedOnly || @ARGV == 0 or die "--skipped=only cannot be used when tests are specified on the command line.";
228 setConfiguration($configuration);
230 my $configurationOption = "--" . lc($configuration);
232 $repaintTests = 1 if $repaintSweepHorizontally;
234 $pixelTests = 1 if $testOnlySVGs;
235 $pixelTests = 1 if $repaintTests;
237 $verbose = 1 if $testsPerDumpTool == 1;
239 if ($shouldCheckLeaks && $testsPerDumpTool > 1000) {
240 print STDERR "\nWARNING: Running more than 1000 tests at a time with MallocStackLogging enabled may cause a crash.\n\n";
243 # Force --no-http for Qt/Linux, for now.
244 $testHTTP = 0 if isQt();
246 setConfigurationProductDir(Cwd::abs_path($root)) if (defined($root));
247 my $productDir = productDir();
248 $productDir .= "/bin" if (isQt());
253 # Push the parameters to build-dumprendertree as an array
255 push(@args, "--" . $configuration);
256 push(@args, "--qt") if isQt();
257 push(@args, "--gtk") if isGtk();
259 my $buildResult = system "WebKitTools/Scripts/build-dumprendertree", @args;
261 print STDERR "Compiling DumpRenderTree failed!\n";
262 exit WEXITSTATUS($buildResult);
266 my $dumpToolName = "DumpRenderTree";
267 $dumpToolName .= "_debug" if isCygwin() && $configuration ne "Release";
268 my $dumpTool = "$productDir/$dumpToolName";
269 die "can't find executable $dumpToolName (looked in $productDir)\n" unless -x $dumpTool;
271 my $imageDiffTool = "$productDir/ImageDiff";
272 die "can't find executable $imageDiffTool (looked in $productDir)\n" if $pixelTests && !-x $imageDiffTool;
274 checkFrameworks() unless isCygwin();
276 my $layoutTestsName = "LayoutTests";
277 my $testDirectory = File::Spec->rel2abs($layoutTestsName);
278 my $expectedDirectory = $testDirectory;
279 my $platformBaseDirectory = catdir($testDirectory, "platform");
280 my $platformTestDirectory = catdir($platformBaseDirectory, $platform);
281 my @platformHierarchy = buildPlatformHierarchy();
283 $expectedDirectory = $ENV{"WebKitExpectedTestResultsDirectory"} if $ENV{"WebKitExpectedTestResultsDirectory"};
286 $testDirectory .= "/svg";
287 $expectedDirectory .= "/svg";
290 my $testResults = catfile($testResultsDirectory, "results.html");
292 print "Running tests from $testDirectory\n";
297 system "ln", "-s", $testDirectory, "/tmp/LayoutTests" unless -x "/tmp/LayoutTests";
299 my %ignoredFiles = ();
300 my %ignoredDirectories = map { $_ => 1 } qw(platform);
301 my %ignoredLocalDirectories = map { $_ => 1 } qw(.svn _svn resources);
302 my %supportedFileExtensions = map { $_ => 1 } qw(html shtml xml xhtml pl php);
304 %supportedFileExtensions = map { $_ => 1 } qw(svg xml);
305 } elsif (checkWebCoreSVGSupport($testOnlySVGs)) {
306 $supportedFileExtensions{'svg'} = 1;
307 } elsif (isCygwin()) {
308 # FIXME: We should fix webkitdirs.pm:hasSVGSupport() to do the correct
309 # check for Windows instead of forcing this here.
310 $supportedFileExtensions{'svg'} = 1;
312 $ignoredLocalDirectories{'svg'} = 1;
315 $ignoredDirectories{'http'} = 1;
319 processIgnoreTests($ignoreTests);
322 if (!$ignoreSkipped) {
323 foreach my $level (@platformHierarchy) {
324 if (open SKIPPED, "<", "$level/Skipped") {
325 if ($verbose && !$skippedOnly) {
326 my ($dir, $name) = splitpath($level);
327 print "Skipped tests in $name:\n";
333 $skipped =~ s/^[ \n\r]+//;
334 $skipped =~ s/[ \n\r]+$//;
335 if ($skipped && $skipped !~ /^#/) {
337 push(@ARGV, $skipped);
342 processIgnoreTests($skipped);
352 my $directoryFilter = sub {
353 return () if exists $ignoredLocalDirectories{basename($File::Find::dir)};
354 return () if exists $ignoredDirectories{File::Spec->abs2rel($File::Find::dir, $testDirectory)};
358 my $fileFilter = sub {
360 if ($filename =~ /\.([^.]+)$/) {
361 if (exists $supportedFileExtensions{$1}) {
362 my $path = File::Spec->abs2rel(catfile($File::Find::dir, $filename), $testDirectory);
363 push @tests, $path if !exists $ignoredFiles{$path};
368 for my $test (@ARGV) {
369 $test =~ s/^($layoutTestsName|$testDirectory)\///;
370 my $fullPath = catfile($testDirectory, $test);
371 if (file_name_is_absolute($test)) {
372 print "can't run test $test outside $testDirectory\n";
373 } elsif (-f $fullPath) {
374 my ($filename, $pathname, $fileExtension) = fileparse($test, qr{\.[^.]+$});
375 if (!exists $supportedFileExtensions{substr($fileExtension, 1)}) {
376 print "test $test does not have a supported extension\n";
377 } elsif ($testHTTP || $pathname !~ /^http\//) {
380 } elsif (-d $fullPath) {
381 find({ preprocess => $directoryFilter, wanted => $fileFilter }, $fullPath);
383 for my $level (@platformHierarchy) {
384 my $platformPath = catfile($level, $test);
385 find({ preprocess => $directoryFilter, wanted => $fileFilter }, $platformPath) if (-d $platformPath);
388 print "test $test not found\n";
392 find({ preprocess => $directoryFilter, wanted => $fileFilter }, $testDirectory);
394 for my $level (@platformHierarchy) {
395 find({ preprocess => $directoryFilter, wanted => $fileFilter }, $level);
399 die "no tests to run\n" if !@tests;
401 @tests = sort pathcmp @tests;
406 my %imageDifferences;
409 my $leaksOutputFileNumber = 1;
413 push @toolArgs, "--dump-all-pixels" if $pixelTests && $resetResults;
414 push @toolArgs, "--pixel-tests" if $pixelTests;
415 push @toolArgs, "--repaint" if $repaintTests;
416 push @toolArgs, "--horizontal-sweep" if $repaintSweepHorizontally;
417 push @toolArgs, "--threaded" if $threaded;
418 push @toolArgs, "--paint" if $shouldCheckLeaks; # Otherwise, DRT won't exercise painting leaks.
423 my $imageDiffToolPID;
426 $ENV{MallocStackLogging} = 1 if $shouldCheckLeaks;
427 $imageDiffToolPID = open2(\*DIFFIN, \*DIFFOUT, $imageDiffTool, "") or die "unable to open $imageDiffTool\n";
431 my $isDumpToolOpen = 0;
432 my $dumpToolCrashed = 0;
435 my $lastDirectory = "";
439 sub catch_pipe { $dumpToolCrashed = 1; }
440 $SIG{"PIPE"} = "catch_pipe";
442 print "Testing ", scalar @tests, " test cases.\n";
443 my $overallStartTime = time;
445 my %expectedResultDirectory;
447 for my $test (@tests) {
448 next if $test eq 'results.html';
452 my $base = stripExtension($test);
455 print "running $test -> ";
460 if ($dir ne $lastDirectory) {
461 print "\n" unless $atLineStart;
463 $lastDirectory = $dir;
471 my $startTime = time if $report10Slowest;
473 if ($test !~ /^http\//) {
474 my $testPath = "$testDirectory/$test";
476 $testPath = toWindowsPath($testPath);
478 $testPath = canonpath($testPath);
480 print OUT "$testPath\n";
483 if ($test !~ /^http\/tests\/local\// && $test !~ /^http\/tests\/ssl\//) {
484 my $path = canonpath($test);
485 $path =~ s/^http\/tests\///;
486 print OUT "http://127.0.0.1:$httpdPort/$path\n";
487 } elsif ($test =~ /^http\/tests\/ssl\//) {
488 my $path = canonpath($test);
489 $path =~ s/^http\/tests\///;
490 print OUT "https://127.0.0.1:$httpdSSLPort/$path\n";
492 my $testPath = "$testDirectory/$test";
494 $testPath = toWindowsPath($testPath);
496 $testPath = canonpath($testPath);
498 print OUT "$testPath\n";
507 $actual =~ s/\r//g if isCygwin();
509 my $isText = isTextOnlyTest($actual);
511 $durations{$test} = time - $startTime if $report10Slowest;
514 my $expectedDir = expectedDirectoryForTest($base, $isText);
515 $expectedResultDirectory{$base} = $expectedDir;
517 if (!$resetResults && open EXPECTED, "<", "$expectedDir/$base-$expectedTag.txt") {
520 next if $stripEditingCallbacks && $_ =~ /^EDITING DELEGATE:/;
526 if (!isOSX() && $strictTesting && !$isText) {
527 if (!$resetResults && open EXPECTED, "<", "$testDirectory/platform/mac/$base-$expectedTag.txt") {
536 if ($shouldCheckLeaks && $testsPerDumpTool == 1) {
542 my $diffPercentage = "";
543 my $diffResult = "passed";
547 my $expectedHash = "";
548 my $actualPNGSize = 0;
552 if (/ActualHash: ([a-f0-9]{32})/) {
554 } elsif (/BaselineHash: ([a-f0-9]{32})/) {
556 } elsif (/Content-length: (\d+)\s*/) {
558 read(IN, $actualPNG, $actualPNGSize);
562 if ($expectedHash ne $actualHash && -f "$expectedDir/$base-$expectedTag.png") {
563 my $expectedPNGSize = -s "$expectedDir/$base-$expectedTag.png";
564 my $expectedPNG = "";
565 open EXPECTEDPNG, "$expectedDir/$base-$expectedTag.png";
566 read(EXPECTEDPNG, $expectedPNG, $expectedPNGSize);
568 print DIFFOUT "Content-length: $actualPNGSize\n";
569 print DIFFOUT $actualPNG;
571 print DIFFOUT "Content-length: $expectedPNGSize\n";
572 print DIFFOUT $expectedPNG;
575 last if /^error/ || /^diff:/;
576 if (/Content-length: (\d+)\s*/) {
577 read(DIFFIN, $diffPNG, $1);
581 if (/^diff: (.+)% (passed|failed)/) {
582 $diffPercentage = $1;
583 $imageDifferences{$base} = $diffPercentage;
588 if ($actualPNGSize && ($resetResults || !-f "$expectedDir/$base-$expectedTag.png")) {
589 mkpath catfile($expectedDir, dirname($base)) if $testDirectory ne $expectedDir;
590 open EXPECTED, ">", "$expectedDir/$base-expected.png" or die "could not create $expectedDir/$base-expected.png\n";
591 print EXPECTED $actualPNG;
595 # update the expected hash if the image diff said that there was no difference
596 if ($actualHash ne "" && ($resetResults || !-f "$expectedDir/$base-$expectedTag.checksum")) {
597 open EXPECTED, ">", "$expectedDir/$base-$expectedTag.checksum" or die "could not create $expectedDir/$base-$expectedTag.checksum\n";
598 print EXPECTED $actualHash;
603 if (!isOSX() && $strictTesting && !$isText) {
604 if (defined $expectedMac) {
605 my $simplified_actual;
606 $simplified_actual = $actual;
607 $simplified_actual =~ s/at \(-?[0-9]+,-?[0-9]+\) *//g;
608 $simplified_actual =~ s/size -?[0-9]+x-?[0-9]+ *//g;
609 $simplified_actual =~ s/text run width -?[0-9]+: //g;
610 $simplified_actual =~ s/text run width -?[0-9]+ [a-zA-Z ]+: //g;
611 $simplified_actual =~ s/RenderButton {BUTTON} .*/RenderButton {BUTTON}/g;
612 $simplified_actual =~ s/RenderImage {INPUT} .*/RenderImage {INPUT}/g;
613 $simplified_actual =~ s/RenderBlock {INPUT} .*/RenderBlock {INPUT}/g;
614 $simplified_actual =~ s/RenderTextControl {INPUT} .*/RenderTextControl {INPUT}/g;
615 $simplified_actual =~ s/\([0-9]+px/px/g;
616 $simplified_actual =~ s/ *" *\n +" */ /g;
617 $simplified_actual =~ s/" +$/"/g;
619 $simplified_actual =~ s/- /-/g;
620 $simplified_actual =~ s/\n( *)"\s+/\n$1"/g;
621 $simplified_actual =~ s/\s+"\n/"\n/g;
623 $expectedMac =~ s/at \(-?[0-9]+,-?[0-9]+\) *//g;
624 $expectedMac =~ s/size -?[0-9]+x-?[0-9]+ *//g;
625 $expectedMac =~ s/text run width -?[0-9]+: //g;
626 $expectedMac =~ s/text run width -?[0-9]+ [a-zA-Z ]+: //g;
627 $expectedMac =~ s/RenderButton {BUTTON} .*/RenderButton {BUTTON}/g;
628 $expectedMac =~ s/RenderImage {INPUT} .*/RenderImage {INPUT}/g;
629 $expectedMac =~ s/RenderBlock {INPUT} .*/RenderBlock {INPUT}/g;
630 $expectedMac =~ s/RenderTextControl {INPUT} .*/RenderTextControl {INPUT}/g;
631 $expectedMac =~ s/\([0-9]+px/px/g;
632 $expectedMac =~ s/ *" *\n +" */ /g;
633 $expectedMac =~ s/" +$/"/g;
635 $expectedMac =~ s/- /-/g;
636 $expectedMac =~ s/\n( *)"\s+/\n$1"/g;
637 $expectedMac =~ s/\s+"\n/"\n/g;
639 if ($simplified_actual ne $expectedMac) {
640 open ACTUAL, ">", "/tmp/actual.txt" or die;
641 print ACTUAL $simplified_actual;
643 open ACTUAL, ">", "/tmp/expected.txt" or die;
644 print ACTUAL $expectedMac;
646 system "diff -u \"/tmp/expected.txt\" \"/tmp/actual.txt\" > \"/tmp/simplified.diff\"";
648 $diffResult = "failed";
651 system "cat /tmp/simplified.diff";
658 if (dumpToolDidCrash()) {
661 printFailureMessageForTest($test, "crashed");
663 my $dir = "$testResultsDirectory/$base";
664 $dir =~ s|/([^/]+)$|| or die "Failed to find test name from base\n";
667 deleteExpectedAndActualResults($base);
669 open CRASH, ">", "$testResultsDirectory/$base-$errorTag.txt" or die;
673 recordActualResultsAndDiff($base, $actual);
676 } elsif (!defined $expected) {
678 print "new " . ($resetResults ? "result" : "test") ."\n";
683 if ($generateNewResults || $resetResults) {
684 mkpath catfile($expectedDir, dirname($base)) if $testDirectory ne $expectedDir;
685 open EXPECTED, ">", "$expectedDir/$base-$expectedTag.txt" or die "could not create $expectedDir/$base-$expectedTag.txt\n";
686 print EXPECTED $actual;
689 deleteExpectedAndActualResults($base);
690 unless ($resetResults) {
691 # Always print the file name for new tests, as they will probably need some manual inspection.
692 # in verbose mode we already printed the test case, so no need to do it again.
694 print "\n" unless $atLineStart;
697 my $resultsDir = catdir($expectedDir, dirname($base));
698 print "new (results generated in $resultsDir)\n";
701 } elsif ($actual eq $expected && $diffResult eq "passed") {
707 deleteExpectedAndActualResults($base);
709 $result = "mismatch";
711 my $message = $actual eq $expected ? "pixel test failed" : "failed";
713 if ($actual ne $expected && $addPlatformExceptions) {
714 my $testBase = catfile($testDirectory, $base);
715 my $expectedBase = catfile($expectedDir, $base);
716 my $testIsMaximallyPlatformSpecific = $testBase =~ m|^\Q$platformTestDirectory\E/|;
717 my $expectedResultIsMaximallyPlatformSpecific = $expectedBase =~ m|^\Q$platformTestDirectory\E/|;
718 if (!$testIsMaximallyPlatformSpecific && !$expectedResultIsMaximallyPlatformSpecific) {
719 mkpath catfile($platformTestDirectory, dirname($base));
720 my $expectedFile = catfile($platformTestDirectory, "$base-$expectedTag.txt");
721 open EXPECTED, ">", $expectedFile or die "could not create $expectedFile\n";
722 print EXPECTED $actual;
724 $message .= " (results generated in $platformTestDirectory)";
728 printFailureMessageForTest($test, $message);
730 my $dir = "$testResultsDirectory/$base";
731 $dir =~ s|/([^/]+)$|| or die "Failed to find test name from base\n";
735 deleteExpectedAndActualResults($base);
736 recordActualResultsAndDiff($base, $actual);
738 if ($pixelTests && $diffPNG && $diffPNG ne "") {
739 $imagesPresent{$base} = 1;
741 open ACTUAL, ">", "$testResultsDirectory/$base-$actualTag.png" or die;
742 print ACTUAL $actualPNG;
745 open DIFF, ">", "$testResultsDirectory/$base-$diffsTag.png" or die;
749 copy("$expectedDir/$base-$expectedTag.png", "$testResultsDirectory/$base-$expectedTag.png");
751 open DIFFHTML, ">$testResultsDirectory/$base-$diffsTag.html" or die;
752 print DIFFHTML "<html>\n";
753 print DIFFHTML "<head>\n";
754 print DIFFHTML "<title>$base Image Compare</title>\n";
755 print DIFFHTML "<script language=\"Javascript\" type=\"text/javascript\">\n";
756 print DIFFHTML "var currentImage = 0;\n";
757 print DIFFHTML "var imageNames = new Array(\"Actual\", \"Expected\");\n";
758 print DIFFHTML "var imagePaths = new Array(\"$testName-$actualTag.png\", \"$testName-$expectedTag.png\");\n";
759 if (-f "$testDirectory/$base-w3c.png") {
760 copy("$testDirectory/$base-w3c.png", "$testResultsDirectory/$base-w3c.png");
761 print DIFFHTML "imageNames.push(\"W3C\");\n";
762 print DIFFHTML "imagePaths.push(\"$testName-w3c.png\");\n";
764 print DIFFHTML "function animateImage() {\n";
765 print DIFFHTML " var image = document.getElementById(\"animatedImage\");\n";
766 print DIFFHTML " var imageText = document.getElementById(\"imageText\");\n";
767 print DIFFHTML " image.src = imagePaths[currentImage];\n";
768 print DIFFHTML " imageText.innerHTML = imageNames[currentImage] + \" Image\";\n";
769 print DIFFHTML " currentImage = (currentImage + 1) % imageNames.length;\n";
770 print DIFFHTML " setTimeout('animateImage()',2000);\n";
771 print DIFFHTML "}\n";
772 print DIFFHTML "</script>\n";
773 print DIFFHTML "</head>\n";
774 print DIFFHTML "<body onLoad=\"animateImage();\">\n";
775 print DIFFHTML "<table>\n";
776 if ($diffPercentage) {
777 print DIFFHTML "<tr>\n";
778 print DIFFHTML "<td>Difference between images: <a href=\"$testName-$diffsTag.png\">$diffPercentage%</a></td>\n";
779 print DIFFHTML "</tr>\n";
781 print DIFFHTML "<tr>\n";
782 print DIFFHTML "<td><a href=\"" . toURL("$testDirectory/$test") . "\">test file</a></td>\n";
783 print DIFFHTML "</tr>\n";
784 print DIFFHTML "<tr>\n";
785 print DIFFHTML "<td id=\"imageText\" style=\"text-weight: bold;\">Actual Image</td>\n";
786 print DIFFHTML "</tr>\n";
787 print DIFFHTML "<tr>\n";
788 print DIFFHTML "<td><img src=\"$testName-$actualTag.png\" id=\"animatedImage\"></td>\n";
789 print DIFFHTML "</tr>\n";
790 print DIFFHTML "</table>\n";
791 print DIFFHTML "</body>\n";
792 print DIFFHTML "</html>\n";
796 if (($count + 1) % $testsPerDumpTool == 0 || $count == $#tests) {
797 if ($shouldCheckLeaks) {
799 if ($testsPerDumpTool == 1) {
800 $fileName = "$testResultsDirectory/$base-leaks.txt";
802 $fileName = "$testResultsDirectory/" . fileNameWithNumber($dumpToolName, $leaksOutputFileNumber) . "-leaks.txt";
804 my $leakCount = countAndPrintLeaks($dumpToolName, $dumpToolPID, $fileName);
805 $totalLeaks += $leakCount;
806 $leaksOutputFileNumber++ if ($leakCount);
814 push @{$tests{$result}}, $test;
815 $testType{$test} = $isText;
817 printf "\n%0.2fs total testing time\n", (time - $overallStartTime) . "";
819 !$isDumpToolOpen || die "Failed to close $dumpToolName.\n";
823 # Because multiple instances of this script are running concurrently we cannot
824 # safely delete this symlink.
825 # system "rm /tmp/LayoutTests";
827 # FIXME: Do we really want to check the image-comparison tool for leaks every time?
828 if ($shouldCheckLeaks && $pixelTests) {
829 $totalLeaks += countAndPrintLeaks("ImageDiff", $imageDiffToolPID, "$testResultsDirectory/ImageDiff-leaks.txt");
833 print "\nWARNING: $totalLeaks total leaks found!\n";
834 print "See above for individual leaks results.\n" if ($leaksOutputFileNumber > 2);
841 if ($report10Slowest) {
842 print "\n\nThe 10 slowest tests:\n\n";
844 for my $test (sort slowestcmp keys %durations) {
845 printf "%0.2f secs: %s\n", $durations{$test}, $test;
846 last if ++$count == 10;
852 if ($skippedOnly && $counts{"match"}) {
853 print "The following tests are in the Skipped file (" . File::Spec->abs2rel("$platformTestDirectory/Skipped", $testDirectory) . "), but succeeded:\n";
854 foreach my $test (@{$tests{"match"}}) {
859 if ($resetResults || ($counts{match} && $counts{match} == $count)) {
860 print "all $count test cases succeeded\n";
867 match => "succeeded",
868 mismatch => "had incorrect layout",
873 for my $type ("match", "mismatch", "new", "crash") {
874 my $c = $counts{$type};
876 my $t = $text{$type};
880 $message = sprintf "1 test case (%d%%) %s\n", 1 * 100 / $count, $t;
882 $message = sprintf "%d test cases (%d%%) %s\n", $c, $c * 100 / $count, $t;
884 $message =~ s-\(0%\)-(<1%)-;
889 mkpath $testResultsDirectory;
891 open HTML, ">", $testResults or die;
892 print HTML "<html>\n";
893 print HTML "<head>\n";
894 print HTML "<title>Layout Test Results</title>\n";
895 print HTML "</head>\n";
896 print HTML "<body>\n";
898 if ($counts{mismatch}) {
899 print HTML "<p>Tests where results did not match expected results:</p>\n";
900 print HTML "<table>\n";
901 for my $test (@{$tests{mismatch}}) {
902 my $base = stripExtension($test);
904 print HTML "<td><a href=\"" . toURL("$testDirectory/$test") . "\">$test</a></td>\n";
905 print HTML htmlForExpectedAndActualResults($base);
907 if ($imagesPresent{$base}) {
908 print HTML "<td><a href=\"" . toURL("$base-$expectedTag.png") . "\">expected image</a></td>\n";
909 print HTML "<td><a href=\"" . toURL("$base-$diffsTag.html") . "\">image diffs</a>\n";
910 print HTML "<a href=\"" . toURL("$base-$diffsTag.png") . "\">$imageDifferences{$base}%</a></td>\n";
912 print HTML "<td></td><td></td>\n";
915 print HTML "</tr>\n";
917 print HTML "</table>\n";
920 if ($counts{crash}) {
921 print HTML "<p>Tests that caused the DumpRenderTree tool to crash:</p>\n";
922 print HTML "<table>\n";
923 for my $test (@{$tests{crash}}) {
924 my $base = stripExtension($test);
925 my $expectedDir = $expectedResultDirectory{$base};
927 print HTML "<td><a href=\"" . toURL("$testDirectory/$test") . "\">$base</a></td>\n";
928 print HTML htmlForExpectedAndActualResults($base);
929 print HTML "<td><a href=\"$base-$errorTag.txt\">stderr</a></td>\n";
930 print HTML "</tr>\n";
932 print HTML "</table>\n";
936 print HTML "<p>Tests that had no expected results (probably new):</p>\n";
937 print HTML "<table>\n";
938 for my $test (@{$tests{new}}) {
939 my $base = stripExtension($test);
940 my $expectedDir = $expectedResultDirectory{$base};
942 print HTML "<td><a href=\"" . toURL("$testDirectory/$test") . "\">$base</a></td>\n";
943 print HTML "<td><a href=\"" . toURL("$expectedDir/$base-$expectedTag.txt") . "\">results</a></td>\n";
944 if ($pixelTests && -f "$expectedDir/$base-$expectedTag.png") {
945 print HTML "<td><a href=\"" . toURL("$expectedDir/$base-$expectedTag.png") . "\">image</a></td>\n";
947 print HTML "</tr>\n";
949 print HTML "</table>\n";
952 print HTML "</body>\n";
953 print HTML "</html>\n";
957 system "konqueror", $testResults if $launchSafari;
958 } elsif (isCygwin()) {
959 system "cygstart", $testResults if $launchSafari;
961 system "WebKitTools/Scripts/run-safari", $configurationOption, "-NSOpen", $testResults if $launchSafari;
964 closeCygpaths() if isCygwin();
968 sub countAndPrintLeaks($$$)
970 my ($dumpToolName, $dumpToolPID, $leaksFilePath) = @_;
972 print "\n" unless $atLineStart;
975 # We are excluding the following reported leaks so they don't get in our way when looking for WebKit leaks:
976 # This allows us ignore known leaks and only be alerted when new leaks occur. Some leaks are in the old
977 # versions of the system frameworks that are being used by the leaks bots. Even though a leak has been
978 # fixed, it will be listed here until the bot has been updated with the newer frameworks.
980 my @typesToExclude = (
983 my @callStacksToExclude = (
984 "Flash_EnforceLocalSecurity" # leaks in Flash plug-in code, rdar://problem/4449747
988 # Leak list for the version of Tiger used on the build bot.
989 push @callStacksToExclude, (
990 "CFRunLoopRunSpecific \\| malloc_zone_malloc", "CFRunLoopRunSpecific \\| CFAllocatorAllocate ", # leak in CFRunLoopRunSpecific, rdar://problem/4670839
991 "CGImageSourceGetPropertiesAtIndex", # leak in ImageIO, rdar://problem/4628809
992 "FOGetCoveredUnicodeChars", # leak in ATS, rdar://problem/3943604
993 "GetLineDirectionPreference", "InitUnicodeUtilities", # leaks tool falsely reporting leak in CFNotificationCenterAddObserver, rdar://problem/4964790
994 "ICCFPrefWrapper::GetPrefDictionary", # leaks in Internet Config. code, rdar://problem/4449794
995 "NSHTTPURLProtocol setResponseHeader:", # leak in multipart/mixed-replace handling in Foundation, no Radar, but fixed in Leopard
996 "NSURLCache cachedResponseForRequest", # leak in CFURL cache, rdar://problem/4768430
997 "PCFragPrepareClosureFromFile", # leak in Code Fragment Manager, rdar://problem/3426998
998 "WebCore::Selection::toRange", # bug in 'leaks', rdar://problem/4967949
999 "WebCore::SubresourceLoader::create", # bug in 'leaks', rdar://problem/4985806
1000 "_CFPreferencesDomainDeepCopyDictionary", # leak in CFPreferences, rdar://problem/4220786
1001 "_objc_msgForward", # leak in NSSpellChecker, rdar://problem/4965278
1002 "gldGetString", # leak in OpenGL, rdar://problem/5013699
1003 "LayoutTestController::queueReload", #rdar://problem/5546478 REGRESSION: 2 leaks on Tiger under LayoutTestController::queueReload
1004 "_setDefaultUserInfoFromURL", #rdar://problem/5546453 REGRESSION: 3 leaks on Tiger under _setDefaultUserInfoFromURL
1005 "SSLHandshake" #rdar://problem/5546440 REGRESSION: 1 leak on Tiger under SSL
1007 push @typesToExclude, (
1008 "THRD", # bug in 'leaks', Radar 3387783
1009 "DRHT" # ditto (endian little hate i)
1014 # Leak list for the version of Leopard used on the build bot.
1015 push @callStacksToExclude, (
1016 "CFHTTPMessageAppendBytes", # rdar://problem/5435912
1017 "sendDidReceiveDataCallback", # rdar://problem/5441619
1018 "_CFHTTPReadStreamReadMark", # rdar://problem/5441468
1019 "httpProtocolStart", # rdar://problem/5468837
1020 "_CFURLConnectionSendCallbacks", # rdar://problem/5441600
1024 my $leaksTool = sourceDir() . "/WebKitTools/Scripts/run-leaks";
1025 my $excludeString = "--exclude-callstack '" . (join "' --exclude-callstack '", @callStacksToExclude) . "'";
1026 $excludeString .= " --exclude-type '" . (join "' --exclude-type '", @typesToExclude) . "'" if @typesToExclude;
1028 print " ? checking for leaks in $dumpToolName\n";
1029 my $leaksOutput = `$leaksTool $excludeString $dumpToolPID`;
1030 my ($count, $bytes) = $leaksOutput =~ /Process $dumpToolPID: (\d+) leaks? for (\d+) total/;
1031 my ($excluded) = $leaksOutput =~ /(\d+) leaks? excluded/;
1033 my $adjustedCount = $count;
1034 $adjustedCount -= $excluded if $excluded;
1036 if (!$adjustedCount) {
1037 print " - no leaks found\n";
1038 unlink $leaksFilePath;
1041 my $dir = $leaksFilePath;
1042 $dir =~ s|/[^/]+$|| or die;
1046 print " + $adjustedCount leaks ($bytes bytes including $excluded excluded leaks) were found, details in $leaksFilePath\n";
1048 print " + $count leaks ($bytes bytes) were found, details in $leaksFilePath\n";
1051 open LEAKS, ">", $leaksFilePath or die;
1052 print LEAKS $leaksOutput;
1056 return $adjustedCount;
1059 # Break up a path into the directory (with slash) and base name.
1064 my $pathSeparator = "/";
1065 my $dirname = dirname($path) . $pathSeparator;
1066 $dirname = "" if $dirname eq "." . $pathSeparator;
1068 return ($dirname, basename($path));
1071 # Sort first by directory, then by file, so all paths in one directory are grouped
1072 # rather than being interspersed with items from subdirectories.
1073 # Use numericcmp to sort directory and filenames to make order logical.
1076 my ($patha, $pathb) = @_;
1078 my ($dira, $namea) = splitpath($patha);
1079 my ($dirb, $nameb) = splitpath($pathb);
1081 return numericcmp($dira, $dirb) if $dira ne $dirb;
1082 return numericcmp($namea, $nameb);
1085 # Sort numeric parts of strings as numbers, other parts as strings.
1086 # Makes 1.33 come after 1.3, which is cool.
1091 my @a = split /(\d+)/, $aa;
1092 my @b = split /(\d+)/, $bb;
1094 # Compare one chunk at a time.
1095 # Each chunk is either all numeric digits, or all not numeric digits.
1100 # Use numeric comparison if chunks are non-equal numbers.
1101 return $a <=> $b if $a =~ /^\d/ && $b =~ /^\d/ && $a != $b;
1103 # Use string comparison if chunks are any other kind of non-equal string.
1104 return $a cmp $b if $a ne $b;
1107 # One of the two is now empty; compare lengths for result in this case.
1111 # Sort slowest tests first.
1114 my ($testa, $testb) = @_;
1116 my $dura = $durations{$testa};
1117 my $durb = $durations{$testb};
1118 return $durb <=> $dura if $dura != $durb;
1119 return pathcmp($testa, $testb);
1124 return if $isDumpToolOpen;
1126 # Save some requires variables for the linux environment...
1127 my $homeDir = $ENV{'HOME'};
1128 my $libraryPath = $ENV{'LD_LIBRARY_PATH'};
1129 my $dbusAddress = $ENV{'DBUS_SESSION_BUS_ADDRESS'};
1130 my $display = $ENV{'DISPLAY'};
1131 my $testfonts = $ENV{'WEBKIT_TESTFONTS'};
1133 my $homeDrive = $ENV{'HOMEDRIVE'};
1134 my $homePath = $ENV{'HOMEPATH'};
1138 if (defined $display) {
1139 $ENV{DISPLAY} = $display;
1141 $ENV{DISPLAY} = ":1";
1143 $ENV{'WEBKIT_TESTFONTS'} = $testfonts;
1144 $ENV{HOME} = $homeDir;
1145 if (defined $libraryPath) {
1146 $ENV{LD_LIBRARY_PATH} = $libraryPath;
1148 if (defined $dbusAddress) {
1149 $ENV{DBUS_SESSION_BUS_ADDRESS} = $dbusAddress;
1152 $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
1153 $ENV{XML_CATALOG_FILES} = ""; # work around missing /etc/catalog <rdar://problem/4292995>
1154 $ENV{MallocStackLogging} = 1 if $shouldCheckLeaks;
1155 $ENV{DYLD_INSERT_LIBRARIES} = "/usr/lib/libgmalloc.dylib" if $guardMalloc;
1158 $ENV{HOMEDRIVE} = $homeDrive;
1159 $ENV{HOMEPATH} = $homePath;
1160 setPathForRunningWebKitApp(\%ENV) if isCygwin();
1165 push @args, $dumpTool;
1167 push @args, @toolArgs;
1169 $dumpTool = "valgrind";
1171 $dumpToolPID = open3(\*OUT, \*IN, \*ERROR, $dumpTool, @args) or die "Failed to start tool: $dumpTool\n";
1172 $isDumpToolOpen = 1;
1173 $dumpToolCrashed = 0;
1178 return if !$isDumpToolOpen;
1183 waitpid $dumpToolPID, 0;
1184 $isDumpToolOpen = 0;
1187 sub dumpToolDidCrash()
1189 return 1 if $dumpToolCrashed;
1190 return 0 unless $isDumpToolOpen;
1192 my $pid = waitpid(-1, WNOHANG);
1193 return $pid == $dumpToolPID;
1196 sub openHTTPDIfNeeded()
1198 return if $isHttpdOpen;
1200 mkdir "/tmp/WebKit";
1202 if (-f "/tmp/WebKit/httpd.pid") {
1203 my $oldPid = `cat /tmp/WebKit/httpd.pid`;
1205 if (0 != kill 0, $oldPid) {
1206 print "\nhttpd is already running: pid $oldPid, killing...\n";
1209 my $retryCount = 20;
1210 while ((0 != kill 0, $oldPid) && $retryCount) {
1215 die "Timed out waiting for httpd to quit" unless $retryCount;
1219 my $httpdPath = "/usr/sbin/httpd";
1222 my $windowsConfDirectory = "$testDirectory/http/conf/";
1223 unless (-x "/usr/lib/apache/libphp4.dll") {
1224 copy("$windowsConfDirectory/libphp4.dll", "/usr/lib/apache/libphp4.dll");
1225 chmod(0755, "/usr/lib/apache/libphp4.dll");
1227 $httpdConfig = "$windowsConfDirectory/cygwin-httpd.conf";
1229 $httpdConfig = "$testDirectory/http/conf/httpd.conf";
1230 $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
1232 my $documentRoot = "$testDirectory/http/tests";
1233 my $typesConfig = "$testDirectory/http/conf/mime.types";
1234 my $listen = "127.0.0.1:$httpdPort";
1235 my $absTestResultsDirectory = File::Spec->rel2abs(glob $testResultsDirectory);
1236 my $sslCertificate = "$testDirectory/http/conf/webkit-httpd.pem";
1238 mkpath $absTestResultsDirectory;
1241 "-f", "$httpdConfig",
1242 "-C", "DocumentRoot \"$documentRoot\"",
1243 "-C", "Listen $listen",
1244 "-c", "TypesConfig \"$typesConfig\"",
1245 "-c", "CustomLog \"$absTestResultsDirectory/access_log.txt\" common",
1246 "-c", "ErrorLog \"$absTestResultsDirectory/error_log.txt\"",
1247 # Apache wouldn't run CGIs with permissions==700 otherwise
1248 "-c", "User \"#$<\""
1251 # FIXME: Enable this on Windows once <rdar://problem/5345985> is fixed
1252 push(@args, "-c", "SSLCertificateFile \"$sslCertificate\"") unless isCygwin();
1254 open2(\*HTTPDIN, \*HTTPDOUT, $httpdPath, @args);
1256 my $retryCount = 20;
1257 while (system("/usr/bin/curl -q --silent --stderr - --output /dev/null $listen") && $retryCount) {
1262 die "Timed out waiting for httpd to start" unless $retryCount;
1269 return if !$isHttpdOpen;
1274 kill 15, `cat /tmp/WebKit/httpd.pid` if -f "/tmp/WebKit/httpd.pid";
1279 sub fileNameWithNumber($$)
1281 my ($base, $number) = @_;
1282 return "$base$number" if ($number > 1);
1286 sub processIgnoreTests($) {
1287 my @ignoreList = split(/\s*,\s*/, shift);
1288 my $addIgnoredDirectories = sub {
1289 return () if exists $ignoredLocalDirectories{basename($File::Find::dir)};
1290 $ignoredDirectories{File::Spec->abs2rel($File::Find::dir, $testDirectory)} = 1;
1293 foreach my $item (@ignoreList) {
1294 my $path = catfile($testDirectory, $item);
1296 $ignoredDirectories{$item} = 1;
1297 find({ preprocess => $addIgnoredDirectories, wanted => sub {} }, $path);
1300 $ignoredFiles{$item} = 1;
1303 print "ignoring '$item' on ignore-tests list\n";
1308 sub stripExtension($)
1312 $test =~ s/\.[a-zA-Z]+$//;
1316 sub isTextOnlyTest($)
1320 if ($actual =~ /^layer at/ms) {
1328 sub expectedDirectoryForTest($;$)
1330 my ($base, $isText) = @_;
1332 my @directories = @platformHierarchy;
1333 push @directories, map { catdir($platformBaseDirectory, $_) } qw(mac-leopard mac) if isCygwin();
1334 push @directories, $expectedDirectory;
1336 # If we already have expected results, just return their location.
1337 foreach my $directory (@directories) {
1338 return $directory if (-f "$directory/$base-$expectedTag.txt");
1341 # For platform-specific tests, the results should go right next to the test itself.
1342 # Note: The return value of this subroutine will be concatenated with $base
1343 # to determine the location of the new results, so returning $expectedDirectory
1344 # will put the results right next to the test.
1345 # FIXME: We want to allow platform/mac tests with platform/mac-leopard results,
1346 # so this needs to be enhanced.
1347 return $expectedDirectory if $base =~ /^platform/;
1349 # For cross-platform tests, text-only results should go in the cross-platform directory,
1350 # while render tree dumps should go in the least-specific platform directory.
1351 return $isText ? $expectedDirectory : $platformHierarchy[$#platformHierarchy];
1354 sub printFailureMessageForTest($$)
1356 my ($test, $description) = @_;
1359 print "\n" unless $atLineStart;
1362 print "$description\n";
1368 sub openCygpathIfNeeded($)
1372 return unless isCygwin();
1373 return $cygpaths{$options} if $cygpaths{$options} && $cygpaths{$options}->{"open"};
1375 local (*CYGPATHIN, *CYGPATHOUT);
1376 my $pid = open2(\*CYGPATHIN, \*CYGPATHOUT, "cygpath -f - $options");
1380 "out" => *CYGPATHOUT,
1384 $cygpaths{$options} = $cygpath;
1391 return unless isCygwin();
1393 foreach my $cygpath (values(%cygpaths)) {
1394 close $cygpath->{"in"};
1395 close $cygpath->{"out"};
1396 waitpid($cygpath->{"pid"}, 0);
1397 $cygpath->{"open"} = 0;
1402 sub convertPathUsingCygpath($$)
1404 my ($path, $options) = @_;
1406 my $cygpath = openCygpathIfNeeded($options);
1407 local *inFH = $cygpath->{"in"};
1408 local *outFH = $cygpath->{"out"};
1409 print outFH $path . "\n";
1410 chomp(my $convertedPath = <inFH>);
1411 return $convertedPath;
1414 sub toWindowsPath($)
1417 return unless isCygwin();
1419 return convertPathUsingCygpath($path, "-w");
1425 return $path unless isCygwin();
1427 return "file:///" . convertPathUsingCygpath($path, "-m");
1430 sub validateSkippedArg($$;$)
1432 my ($option, $value, $value2) = @_;
1433 my %validSkippedValues = map { $_ => 1 } qw(default ignore only);
1434 $value = lc($value);
1435 die "Invalid argument '" . $value . "' for option $option" unless $validSkippedValues{$value};
1436 $treatSkipped = $value;
1439 sub htmlForExpectedAndActualResults($)
1443 return "<td></td><td></td><td></td>\n" unless -s "$testResultsDirectory/$base-$diffsTag.txt";
1445 return "<td><a href=\"$base-$expectedTag.txt\">expected</a></td>\n"
1446 . "<td><a href=\"$base-$actualTag.txt\">actual</a></td>\n"
1447 . "<td><a href=\"$base-$diffsTag.txt\">diffs</a></td>\n";
1450 sub deleteExpectedAndActualResults($)
1454 unlink "$testResultsDirectory/$base-$actualTag.txt";
1455 unlink "$testResultsDirectory/$base-$diffsTag.txt";
1456 unlink "$testResultsDirectory/$base-$errorTag.txt";
1459 sub recordActualResultsAndDiff($$)
1461 my ($base, $actual) = @_;
1463 return unless length($actual);
1465 open ACTUAL, ">", "$testResultsDirectory/$base-$actualTag.txt" or die "Couldn't open actual results file for $base";
1466 print ACTUAL $actual;
1469 my $expectedDir = $expectedResultDirectory{$base};
1470 copy("$expectedDir/$base-$expectedTag.txt", "$testResultsDirectory/$base-$expectedTag.txt");
1472 system "diff -u \"$testResultsDirectory/$base-$expectedTag.txt\" \"$testResultsDirectory/$base-$actualTag.txt\" > \"$testResultsDirectory/$base-$diffsTag.txt\"";
1475 sub buildPlatformHierarchy()
1477 mkpath($platformTestDirectory) if ($platform eq "undefined" && !-d "$platformTestDirectory");
1479 my @platforms = split('-', $platform);
1481 for (my $i=0; $i < @platforms; $i++) {
1482 my $scoped = catdir($platformBaseDirectory, join('-', @platforms[0..($#platforms - $i)]));
1483 push(@hierarchy, $scoped) if (-d $scoped);