+2007-10-20 Eric Seidel <eric@webkit.org>
+
+ Reviewed by darin.
+
+ Add improved argument handling to sunspider, including
+ --runs=<number>, --tests=<pattern, --shark, and --help
+ Also re-factor code into subroutines
+
+ * sunspider: improved argument handling
+
2007-10-20 Maciej Stachowiak <mjs@apple.com>
Reviewed by Mark.
#!/usr/bin/perl -w
# Copyright (C) 2007 Apple Inc. All rights reserved.
+# Copyright (C) Eric Seidel <eric@webkit.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
use strict;
-
-sub usage()
-{
- die "Usage: sunspider engine [ max_runs ]\n";
+use Getopt::Long;
+use File::Basename;
+use Cwd;
+
+my $showHelp = 0;
+my $runShark = 0;
+my $jsShellPath;
+my $testsPattern;
+my $testRuns = 5; # This number may be different from what ./sunspider defaults to (that's OK)
+
+my $programName = basename($0);
+my $usage = <<EOF;
+Usage: $programName --shell=[path] [options]
+ --help Show this help message
+ --shell Path to javascript shell
+ --runs Number of times to run tests (default: $testRuns)
+ --tests Only run tests matching provided pattern
+ --shark Sample with the Mac OS X "Shark" performance testing tool (implies --runs=1)
+EOF
+
+GetOptions('runs=i' => \$testRuns,
+ 'shell=s' => \$jsShellPath,
+ 'shark' => \$runShark,
+ 'tests=s' => \$testsPattern,
+ 'help' => \$showHelp);
+
+$testRuns = 1 if $runShark;
+
+if (!$jsShellPath || $showHelp) {
+ print STDERR $usage;
+ exit 1;
}
-if (scalar @ARGV < 1) {
- usage();
+sub dumpToFile($$)
+{
+ my ($contents, $path) = @_;
+ open FILE, ">$path";
+ print FILE $contents;
+ close FILE;
}
-my $jsshell = $ARGV[0];
-
-my $max = $ARGV[1];
-$max = 5 if !$max;
+# FIXME: these globals are rather poor abstraction
+my @tests = ();
+my @categories = ();
+my %uniqueCategories = ();
-if ($max =~ /\D/) {
- usage();
+sub loadTestsList()
+{
+ open TESTLIST, "<./tests/LIST";
+ while (<TESTLIST>) {
+ chomp;
+ next unless !$testsPattern || /$testsPattern/;
+
+ push @tests, $_;
+ my $category = $_;
+ $category =~ s/-.*//;
+ if (!$uniqueCategories{$category}) {
+ push @categories, $category;
+ $uniqueCategories{$category} = $category;
+ }
+ }
+ close TESTLIST;
}
-print STDERR "Running SunSpider once for warmup, then $max times\n";
+sub writePrefixFile()
+{
+ my $prefix = "var tests = [ " . join(", ", map { '"' . $_ . '"' } @tests) . " ];\n";
+ $prefix .= "var categories = [ " . join(", ", map { '"' . $_ . '"' } @categories) . " ];\n";
-my @tests = ();
-my @categories = ();
-my %uniqueCategories = ();
+ mkdir "tmp";
+ dumpToFile($prefix, "tmp/sunspider-test-prefix.js");
+}
-open TESTLIST, "<./tests/LIST";
-while (<TESTLIST>) {
- chomp;
- next unless $_;
- push @tests, $_;
- my $category = $_;
- $category =~ s/-.*//;
- if (!$uniqueCategories{$category}) {
- push @categories, $category;
- $uniqueCategories{$category} = $category;
+sub runTestsOnce($)
+{
+ my ($useShark) = @_;
+ my $shellArgs = "-f tmp/sunspider-test-prefix.js -f resources/sunspider-standalone-driver.js 2> /dev/null";
+ my $output;
+ if ($useShark) {
+ print STDERR "Running sunspider under Shark... (this will take a while)\n";
+ print STDERR "shark -i -q \"$jsShellPath\" $shellArgs\n";
+ $output = `shark -i -q "$jsShellPath" $shellArgs`;
+ } else {
+ $output = `"$jsShellPath" $shellArgs`;
}
+ return $output;
}
-close TESTLIST;
-my $prefix = "var tests = [ " . join(", ", map { '"' . $_ . '"' } @tests) . " ];\n";
-$prefix .= "var categories = [ " . join(", ", map { '"' . $_ . '"' } @categories) . " ];\n";
-mkdir "tmp";
-open PREFIX, ">tmp/sunspider-test-prefix.js";
-print PREFIX $prefix;
-close PREFIX;
-my $discard = `"$jsshell" -f tmp/sunspider-test-prefix.js -f resources/sunspider-standalone-driver.js 2> /dev/null`;
+loadTestsList();
+if ($testsPattern) {
+ print STDERR "Found " . scalar(@tests) . " tests matching '" . $testsPattern . "'\n";
+} else {
+ print STDERR "Found " . scalar(@tests) . " tests\n";
+}
+die "No tests to run" unless scalar(@tests);
+print STDERR "Running SunSpider once for warmup, then $testRuns times\n";
+writePrefixFile();
+runTestsOnce(0);
print "Discarded first run.\n";
my $result;
my $count = 0;
my @results = ();
my $total = 0;
-while ($count++ < $max) {
- $result = `"$jsshell" -f tmp/sunspider-test-prefix.js -f resources/sunspider-standalone-driver.js 2> /dev/null`;
+while ($count++ < $testRuns) {
+ $result = runTestsOnce($runShark);
chomp $result;
push @results, $result;
print $result . "\n";
}
my $output = "var output = [\n" . join(",\n", @results) . "\n];\n";
+dumpToFile($output, "tmp/sunspider-results.js");
-open(OUTPUT, ">tmp/sunspider-results.js");
-print OUTPUT $output;
-close(OUTPUT);
+system("$jsShellPath", "-f", "tmp/sunspider-test-prefix.js", "-f", "tmp/sunspider-results.js", "-f", "resources/sunspider-analyze-results.js");
-system("$jsshell", "-f", "tmp/sunspider-test-prefix.js", "-f", "tmp/sunspider-results.js", "-f", "resources/sunspider-analyze-results.js");
+print STDERR "Shark sessions can be found in " . getcwd() . "\n" if $runShark;
+2007-10-20 Eric Seidel <eric@webkit.org>
+
+ Reviewed by darin.
+
+ Add improved argument handling to run-sunspider, including
+ --runs=<number>, --shell=<path>, --tests=<pattern>, --shark, and --help
+ Also re-factor code into subroutines
+
+ * Scripts/build-dumprendertree: removed bogus comments
+ * Scripts/build-testkjs: Added.
+ * Scripts/run-javascriptcore-tests: use build-testkjs
+ * Scripts/run-sunspider: improved argument handling, abstraction
+ * Scripts/run-webkit-tests: improved abstraction
+
2007-10-20 Matt Lilek <webkit@mattlilek.com>
Not reviewed, Windows build fix.
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-# Simplified build script for Web Kit Open Source Project.
-# Modified copy of build-webkit. Perhaps these could share code.
-# Currently only works for the Deployment build style.
use strict;
use FindBin;
--- /dev/null
+#!/usr/bin/perl -w
+
+# Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+# Copyright (C) 2007 Eric Seidel <eric@webkit.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+# its contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+use strict;
+use FindBin;
+use lib $FindBin::Bin;
+use webkitdirs;
+use POSIX;
+
+checkRequiredSystemConfig();
+setConfiguration();
+chdirWebKit();
+my @options = XcodeOptions();
+
+chdir "JavaScriptCore" or die "Can't find JavaScriptCore directory to build from";
+my $result;
+if (isOSX()) {
+ $result = system "xcodebuild", "-project", "JavaScriptCore.xcodeproj", "-target", "testkjs", @options, @ARGV;
+} elsif (isCygwin()) {
+ $result = buildVisualStudioProject("JavaScriptCore.vcproj/JavaScriptCore.sln");
+} elsif (isQt()) {
+ # Qt/Linux builds everything in one-shot. No need to build anything here.
+ $result = 0;
+} else {
+ die "Building not defined for this platform!\n";
+}
+exit WEXITSTATUS($result);
#!/usr/bin/perl -w
# Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+# Copyright (C) 2007 Eric Seidel <eric@webkit.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
print $arg."\n";
if( $arg =~ /root=(.*)/ ){
$root = $1;
- } elsif( $arg =~ /^--gtk$/i ){
+ } elsif( $arg =~ /^--gtk$/i || $arg =~ /^--qt$/i ){
} elsif( $arg =~ /^-/ or !($arg =~/=/)){
push( @jsArgs, $arg );
} else {
setConfigurationProductDir(Cwd::abs_path($root)) if (defined($root));
+if(!defined($root)){
+ chdirWebKit();
+ my @args;
+ push(@args, "--" . $configuration);
+
+ # FIXME: These should be stored per-config and ignored here
+ push(@xcodeArgs, "--qt") if isQt();
+ push(@xcodeArgs, "--gtk") if isGtk();
+
+ my $buildResult = system "WebKitTools/Scripts/build-testkjs", @xcodeArgs;
+ if ($buildResult) {
+ print STDERR "Compiling testkjs failed!\n";
+ exit WEXITSTATUS($buildResult);
+ }
+}
+
# Find JavaScriptCore directory
chdirWebKit();
chdir("JavaScriptCore");
-#compile TestKJS
-my @options = XcodeOptions();
-my $result;
-if (!defined($root)){
- if (isOSX()) {
- $result = system "xcodebuild", "-project", "JavaScriptCore.xcodeproj", "-target", "testkjs", @options, @coverageSupportOption, @xcodeArgs;
- }elsif (isCygwin()) {
- $result = buildVisualStudioProject("JavaScriptCore.vcproj/JavaScriptCore.sln");
- }
- exit WEXITSTATUS($result) if WEXITSTATUS($result);
-}
-
my $productDir = productDir();
chdir "tests/mozilla" or die;
$ENV{DYLD_FRAMEWORK_PATH} = $productDir;
setPathForRunningWebKitApp(\%ENV) if isCygwin();
-my $testkjsName;
-sub determineTestkjsName
+sub testKJSPath($)
{
- return if $testkjsName;
- if (isCygwin() && ($configuration eq "Debug")) {
- $testkjsName = "testkjs_debug";
- } else {
- $testkjsName = "testkjs";
- }
+ my ($productDir) = @_;
+ my $testkjsName = "testkjs";
+ $testkjsName .= "_debug" if (isCygwin() && ($configuration eq "Debug"));
+ return "$productDir/$testkjsName";
}
-$testkjsName = determineTestkjsName();
-
-$result = system "perl", "jsDriver.pl", "-e", "kjs", "-s", "$productDir/$testkjsName", "-f", "actual.html", @jsArgs;
-exit $result if $result;
+my $result = system "perl", "jsDriver.pl", "-e", "kjs", "-s", testKJSPath($productDir), "-f", "actual.html", @jsArgs;
+exit WEXITSTATUS($result) if $result;
my %failures;
#!/usr/bin/perl -w
# Copyright (C) 2007 Apple Inc. All rights reserved.
+# Copyright (C) 2007 Eric Seidel <eric@webkit.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
use strict;
use FindBin;
+use Getopt::Long qw(:config pass_through);
use lib $FindBin::Bin;
use webkitdirs;
use POSIX;
# determine configuration
-my $configuration;
setConfiguration();
-$configuration = configuration();
+my $configuration = configuration();
-my @xcodeArgs;
my $root;
+my $testRuns = 5; # This number may be different from what ./sunspider defaults to (that's OK)
+my $runShark = 0;
+my $showHelp = 0;
+my $testsPattern;
-# pre-evaluate arguments. jsDriver args have - preceding, xcode args do not.
-# special arguments
-# --root=<path to webkit root> use pre-built root
-# --gtk build gtk
-foreach my $arg(@ARGV) {
- print $arg."\n";
- if( $arg =~ /root=(.*)/ ){
- $root = $1;
- } elsif( $arg =~ /^--gtk$/i ){
- } else {
- push( @xcodeArgs, $arg );
- }
-}
+my $programName = basename($0);
+my $usage = <<EOF;
+Usage: $programName [options] [options to pass to build system]
+ --help Show this help message
+ --root Path to root tools build
+ --runs Number of times to run tests (default: $testRuns)
+ --tests Only run tests matching provided pattern
+ --shark Sample with the Mac OS X "Shark" performance testing tool (implies --runs=1)
+EOF
-setConfigurationProductDir(Cwd::abs_path($root)) if (defined($root));
+GetOptions('root=s' => sub { my ($argName, $value); setConfigurationProductDir(Cwd::abs_path($value)); },
+ 'runs=i' => \$testRuns,
+ 'shark' => \$runShark,
+ 'tests=s' => \$testsPattern,
+ 'help' => \$showHelp);
-# Find JavaScriptCore directory
-chdirWebKit();
-chdir("JavaScriptCore");
-
-#compile TestKJS
-my @options = XcodeOptions();
-my $result;
-if (!defined($root)){
- if (isOSX()) {
- $result = system "xcodebuild", "-project", "JavaScriptCore.xcodeproj", "-target", "testkjs", @options, @xcodeArgs;
- }elsif (isCygwin()) {
- $result = buildVisualStudioProject("JavaScriptCore.vcproj/JavaScriptCore.sln");
- }
- exit WEXITSTATUS($result) if WEXITSTATUS($result);
+$testRuns = 1 if $runShark;
+
+if ($showHelp) {
+ print STDERR $usage;
+ exit 1;
}
-my $productDir = productDir();
+sub buildTestKJS
+{
+ if (!defined($root)){
+ push(@ARGV, "--" . $configuration);
+
+ chdirWebKit();
+ my $buildResult = system "WebKitTools/Scripts/build-testkjs", @ARGV;
+ if ($buildResult) {
+ print STDERR "Compiling testkjs failed!\n";
+ exit WEXITSTATUS($buildResult);
+ }
+ }
+}
-$productDir .= "/JavaScriptCore" if (isQt() or isGtk());
-$ENV{DYLD_FRAMEWORK_PATH} = $productDir;
+sub setupEnviromentForExecution($)
+{
+ my ($productDir) = @_;
+ print "Starting sunspider with DYLD_FRAMEWORK_PATH set to point to built JavaScriptCore in $productDir.\n";
+ $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
+ # FIXME: Other platforms may wish to augment this method to use LD_LIBRARY_PATH, etc.
+}
-my $testkjsName;
-sub determineTestkjsName
+sub testKJSPath($)
{
- return if $testkjsName;
- if (isCygwin() && ($configuration eq "Debug")) {
- $testkjsName = "testkjs_debug";
- } else {
- $testkjsName = "testkjs";
- }
+ my ($productDir) = @_;
+ my $testkjsName = "testkjs";
+ $testkjsName .= "_debug" if (isCygwin() && ($configuration eq "Debug"));
+ return "$productDir/$testkjsName";
}
-$testkjsName = determineTestkjsName();
+
+buildTestKJS();
chdirWebKit();
chdir("SunSpider");
-exec "./sunspider", "$productDir/$testkjsName";
+my $productDir = productDir();
+# FIXME: This hack should be pushed down into productDir()
+$productDir .= "/JavaScriptCore" if (isQt() or isGtk());
+
+setupEnviromentForExecution($productDir);
+my @args = ("--shell", testKJSPath($productDir), "--runs", $testRuns);
+# This code could be removed if we chose to pass extra args to sunspider instead of Xcode
+push(@args, "--shark") if $runShark;
+push(@args, "--tests", $testsPattern) if $testsPattern;
+
+exec "./sunspider", @args;
# Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
# Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
# Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com)
+# Copyright (C) 2007 Eric Seidel <eric@webkit.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
chdirWebKit();
if(!defined($root)){
- my $buildResult;
- if (isCygwin()) {
- $buildResult = buildVisualStudioProject("WebKitTools/DumpRenderTree/DumpRenderTree.sln");
- } else {
- # Push the parameters to build-dumprendertree as an array
- my @args;
- push(@args, $configuration);
-
- if (isQt()) {
- push(@args, "--qt");
- } elsif (isGtk()) {
- push(@args, "--gtk");
- }
-
- $buildResult = system "WebKitTools/Scripts/build-dumprendertree", @args;
- }
+ # Push the parameters to build-dumprendertree as an array
+ my @args;
+ push(@args, "--" . $configuration);
+ push(@args, "--qt") if isQt();
+ push(@args, "--gtk") if isGtk();
+ my $buildResult = system "WebKitTools/Scripts/build-dumprendertree", @args;
if ($buildResult) {
print STDERR "Compiling DumpRenderTree failed!\n";
exit WEXITSTATUS($buildResult);