run-javascriptcore-tests 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. #!/usr/bin/perl -w
  2. # Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
  3. # Copyright (C) 2007 Eric Seidel <eric@webkit.org>
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. #
  9. # 1. Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright
  12. # notice, this list of conditions and the following disclaimer in the
  13. # documentation and/or other materials provided with the distribution.
  14. # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
  15. # its contributors may be used to endorse or promote products derived
  16. # from this software without specific prior written permission.
  17. #
  18. # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  19. # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  22. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  27. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. # Script to run the WebKit Open Source Project JavaScriptCore tests (adapted from Mozilla).
  29. use strict;
  30. use FindBin;
  31. use Getopt::Long qw(:config pass_through);
  32. use lib $FindBin::Bin;
  33. use webkitdirs;
  34. use POSIX;
  35. use File::Copy::Recursive qw(dircopy);
  36. use File::Copy;
  37. # determine configuration
  38. setConfiguration();
  39. my $configuration = configuration();
  40. my @testsToSkip = (
  41. # Various ecma/Date tests sometimes fail on Windows (but not Mac) https://bugs.webkit.org/show_bug.cgi?id=25160
  42. "ecma/Date/15.9.2.1.js",
  43. "ecma/Date/15.9.2.2-1.js",
  44. "ecma/Date/15.9.2.2-2.js",
  45. "ecma/Date/15.9.2.2-3.js",
  46. "ecma/Date/15.9.2.2-4.js",
  47. "ecma/Date/15.9.2.2-5.js",
  48. "ecma/Date/15.9.2.2-6.js",
  49. # ecma_3/Date/15.9.5.7.js fails on Mac (but not Windows) https://bugs.webkit.org/show_bug.cgi?id=25161
  50. "ecma_3/Date/15.9.5.6.js",
  51. "ecma_3/Date/15.9.5.7.js",
  52. # These three fail on Linux in certain time zones, at certain times
  53. # of the year (!): https://bugs.webkit.org/show_bug.cgi?id=71371
  54. "ecma/Date/15.9.5.14.js",
  55. "ecma/Date/15.9.5.31-1.js",
  56. "ecma/Date/15.9.5.34-1.js",
  57. );
  58. if (isPSOrbis()) {
  59. # These four fail on our platform and is caused by bug 13417
  60. push(@testsToSkip, "ecma/Date/15.9.5.28-1.js");
  61. push(@testsToSkip, "ecma/Date/15.9.5.29-1.js");
  62. push(@testsToSkip, "ecma/Date/15.9.5.35-1.js");
  63. push(@testsToSkip, "ecma_3/Date/15.9.5.6.js");
  64. # The following are disabled because the tests calls quit() which causes
  65. # this script to terminate prematurely when running in batched mode.
  66. push(@testsToSkip, "ecma_3/ExecutionContexts/10.1.3-2.js"); # The current version of JSC does not meet the requirement (i.e. OBJECT.toSource) of this test
  67. push(@testsToSkip, "ecma_3/Statements/regress-121744.js"); # As stated in the test itself "AS OF 14 JULY 2002, DON'T RUN THIS TEST IN EITHER RHINO OR PIDERMONKEY"
  68. } elsif (isPSVita()) {
  69. # see PSVita bug #82445 and #82444
  70. push(@testsToSkip, "ecma/Date/15.9.5.28-1.js");
  71. push(@testsToSkip, "ecma/Date/15.9.5.29-1.js");
  72. push(@testsToSkip, "ecma/Date/15.9.5.35-1.js");
  73. # see PSVita bug #82447 (math pow(10.0, y) function precision issue)
  74. push(@testsToSkip, "ecma/GlobalObject/15.1.2.2-1.js");
  75. # see PSVita bug #86008 (not enough RWX memory when running with JIT compiler)
  76. push(@testsToSkip, "js1_5/Regress/regress-159334.js");
  77. # The following are disabled because the tests calls quit() which causes
  78. # this script to terminate prematurely when running in batched mode.
  79. push(@testsToSkip, "ecma_3/ExecutionContexts/10.1.3-2.js"); # The current version of JSC does not meet the requirement (i.e. OBJECT.toSource) of this test
  80. push(@testsToSkip, "ecma_3/Statements/regress-121744.js"); # As stated in the test itself "AS OF 14 JULY 2002, DON'T RUN THIS TEST IN EITHER RHINO OR PIDERMONKEY"
  81. }
  82. my $jsDriverArgs = "-L " . join(" ", @testsToSkip);
  83. # These variables are intentionally left undefined.
  84. my $root;
  85. my $showHelp;
  86. my $batch;
  87. my $testsToSkipFromCommandline;
  88. my $buildJSC = 1;
  89. my $programName = basename($0);
  90. my $buildJSCDefault = $buildJSC ? "will check" : "will not check";
  91. my $usage = <<EOF;
  92. Usage: $programName [options] [options to pass to build system]
  93. --help Show this help message
  94. --jsDriver-args= A string of arguments to pass to jsDriver.pl
  95. --root= Path to pre-built root containing jsc
  96. --[no-]build Check (or don't check) to see if the jsc build is up-to-date (default: $buildJSCDefault)
  97. EOF
  98. GetOptions(
  99. 'j|jsDriver-args=s' => \$jsDriverArgs,
  100. 'root=s' => \$root,
  101. 'build!' => \$buildJSC,
  102. 'help' => \$showHelp,
  103. 'batch=s' => \$batch,
  104. 'skip=s' => \$testsToSkipFromCommandline
  105. );
  106. # Assume any arguments left over from GetOptions are assumed to be build arguments
  107. my @buildArgs = @ARGV;
  108. # Arguments passed to --jsDriver-args (if any) are passed to jsDriver.pl
  109. my @jsArgs = split(" ", $jsDriverArgs);
  110. push (@jsArgs, "--batch=" . $batch) if defined($batch);
  111. push (@jsArgs, split(" ","-L $testsToSkipFromCommandline")) if defined($testsToSkipFromCommandline);
  112. if ($showHelp) {
  113. print STDERR $usage;
  114. exit 1;
  115. }
  116. setConfigurationProductDir(Cwd::abs_path($root)) if (defined($root) && !isPSOrbis() && !isPSVita());
  117. if (!defined($root) && $buildJSC) {
  118. chdirWebKit();
  119. push(@buildArgs, argumentsForConfiguration());
  120. print "Running: build-jsc " . join(" ", @buildArgs) . "\n";
  121. my $buildResult = system "perl", "Tools/Scripts/build-jsc", @buildArgs;
  122. if ($buildResult) {
  123. print STDERR "Compiling jsc failed!\n";
  124. exit exitStatus($buildResult);
  125. }
  126. }
  127. my $productDir = jscProductDir();
  128. $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
  129. setPathForRunningWebKitApp(\%ENV) if isCygwin();
  130. sub testapiPath($)
  131. {
  132. my ($productDir) = @_;
  133. my $jscName = "testapi";
  134. $jscName .= "_debug" if configurationForVisualStudio() eq "Debug_All";
  135. return "$productDir/$jscName";
  136. }
  137. #run api tests
  138. if (isAppleMacWebKit() || isAppleWinWebKit()) {
  139. chdirWebKit();
  140. chdir($productDir) or die "Failed to switch directory to '$productDir'\n";
  141. my $path = testapiPath($productDir);
  142. # Use an "indirect object" so that system() won't get confused if the path
  143. # contains spaces (see perldoc -f exec).
  144. my $testapiResult = system { $path } $path;
  145. exit exitStatus($testapiResult) if $testapiResult;
  146. }
  147. # Find JavaScriptCore directory
  148. chdirWebKit();
  149. chdir("Source/JavaScriptCore");
  150. chdir "tests/mozilla" or die "Failed to switch directory to 'tests/mozilla'\n";
  151. # [PlayStation platforms]
  152. my $srcDir = sourceDir() . "/" . $root . "/";
  153. printf "Using executables from $srcDir\n";
  154. $ENV{ORBIS_JSC_APPHOME} = $srcDir if isPSOrbis();
  155. $ENV{PSP2_JSC_APPHOME} = $srcDir if isPSVita();
  156. printf "Running: jsDriver.pl -e squirrelfish -s %s -f actual.html %s\n", jscPath($productDir), join(" ", @jsArgs);
  157. my @jsDriverCmd = ("perl", "jsDriver.pl", "-e", "squirrelfish", "-s", jscPath($productDir), "-f", "actual.html", @jsArgs);
  158. if (isGtk() || isEfl()) {
  159. my @jhbuildPrefix = sourceDir() . "/Tools/jhbuild/jhbuild-wrapper";
  160. if (isEfl()) {
  161. push(@jhbuildPrefix, '--efl');
  162. } elsif (isGtk()) {
  163. push(@jhbuildPrefix, '--gtk');
  164. }
  165. push(@jhbuildPrefix, 'run');
  166. unshift(@jsDriverCmd, @jhbuildPrefix);
  167. }
  168. my $result = system(@jsDriverCmd);
  169. exit exitStatus($result) if $result;
  170. # [PSOrbis] clean-up
  171. if (isPSOrbis()) {
  172. rmtree("sce_sys");
  173. unlink glob "*.self";
  174. unlink glob "*.sprx";
  175. } elsif (isPSVita()) {
  176. rmtree("icudata");
  177. unlink glob "*.self";
  178. unlink glob "*.suprx";
  179. }
  180. my %failures;
  181. open EXPECTED, "expected.html" or die "Failed to open 'expected.html'\n";
  182. while (<EXPECTED>) {
  183. last if /failures reported\.$/;
  184. }
  185. while (<EXPECTED>) {
  186. chomp;
  187. $failures{$_} = 1;
  188. }
  189. close EXPECTED;
  190. my %newFailures;
  191. open ACTUAL, "actual.html" or die "Failed to open 'actual.html'";
  192. while (<ACTUAL>) {
  193. last if /failures reported\.$/;
  194. }
  195. while (<ACTUAL>) {
  196. chomp;
  197. if ($failures{$_}) {
  198. delete $failures{$_};
  199. } else {
  200. $newFailures{$_} = 1;
  201. }
  202. }
  203. close ACTUAL;
  204. my $numNewFailures = keys %newFailures;
  205. if ($numNewFailures) {
  206. print "\n** Danger, Will Robinson! Danger! The following failures have been introduced:\n";
  207. foreach my $failure (sort keys %newFailures) {
  208. print "\t$failure\n";
  209. }
  210. }
  211. my $numOldFailures = keys %failures;
  212. if ($numOldFailures) {
  213. print "\nYou fixed the following test";
  214. print "s" if $numOldFailures != 1;
  215. print ":\n";
  216. foreach my $failure (sort keys %failures) {
  217. print "\t$failure\n";
  218. }
  219. }
  220. print "\n";
  221. print "$numNewFailures regression";
  222. print "s" if $numNewFailures != 1;
  223. print " found.\n";
  224. print "$numOldFailures test";
  225. print "s" if $numOldFailures != 1;
  226. print " fixed.\n";
  227. print "OK.\n" if $numNewFailures == 0;
  228. exit(1) if $numNewFailures;