3 # Copyright (C) 2007 Apple Inc. All rights reserved.
4 # Copyright (C) 2007 Eric Seidel <eric@webkit.org>
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
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.
15 # THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 use Getopt::Long qw(:config pass_through);
30 use lib $FindBin::Bin;
35 # determine configuration
37 my $configuration = configuration();
40 my $testRuns = 5; # This number may be different from what ./sunspider defaults to (that's OK)
45 my $programName = basename($0);
47 Usage: $programName [options] [options to pass to build system]
48 --help Show this help message
49 --root Path to root tools build
50 --runs Number of times to run tests (default: $testRuns)
51 --tests Only run tests matching provided pattern
52 --shark Sample with the Mac OS X "Shark" performance testing tool (implies --runs=1)
55 GetOptions('root=s' => sub { my ($argName, $value); setConfigurationProductDir(Cwd::abs_path($value)); },
56 'runs=i' => \$testRuns,
57 'shark' => \$runShark,
58 'tests=s' => \$testsPattern,
59 'help' => \$showHelp);
61 $testRuns = 1 if $runShark;
71 push(@ARGV, "--" . $configuration);
74 my $buildResult = system "WebKitTools/Scripts/build-testkjs", @ARGV;
76 print STDERR "Compiling testkjs failed!\n";
77 exit WEXITSTATUS($buildResult);
82 sub setupEnviromentForExecution($)
84 my ($productDir) = @_;
85 print "Starting sunspider with DYLD_FRAMEWORK_PATH set to point to built JavaScriptCore in $productDir.\n";
86 $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
87 # FIXME: Other platforms may wish to augment this method to use LD_LIBRARY_PATH, etc.
92 my ($productDir) = @_;
93 my $testkjsName = "testkjs";
94 $testkjsName .= "_debug" if (isCygwin() && ($configuration eq "Debug"));
95 return "$productDir/$testkjsName";
103 my $productDir = productDir();
104 # FIXME: This hack should be pushed down into productDir()
105 $productDir .= "/JavaScriptCore" if (isQt() or isGtk());
107 setupEnviromentForExecution($productDir);
108 my @args = ("--shell", testKJSPath($productDir), "--runs", $testRuns);
109 # This code could be removed if we chose to pass extra args to sunspider instead of Xcode
110 push(@args, "--shark") if $runShark;
111 push(@args, "--tests", $testsPattern) if $testsPattern;
113 exec "./sunspider", @args;