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