From 96184177e109514dc83c573833d4878ad1bc60d5 Mon Sep 17 00:00:00 2001 From: eseidel Date: Sun, 21 Oct 2007 02:43:49 +0000 Subject: [PATCH] 2007-10-20 Eric Seidel Reviewed by darin. Add improved argument handling to run-sunspider, including --runs=, --shell=, --tests=, --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 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@26838 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- SunSpider/ChangeLog | 10 ++ SunSpider/sunspider | 132 +++++++++++++------ WebKitTools/ChangeLog | 14 ++ WebKitTools/Scripts/build-dumprendertree | 3 - WebKitTools/Scripts/build-testkjs | 54 ++++++++ WebKitTools/Scripts/run-javascriptcore-tests | 50 +++---- WebKitTools/Scripts/run-sunspider | 108 ++++++++------- WebKitTools/Scripts/run-webkit-tests | 23 +--- 8 files changed, 266 insertions(+), 128 deletions(-) create mode 100755 WebKitTools/Scripts/build-testkjs diff --git a/SunSpider/ChangeLog b/SunSpider/ChangeLog index 81729bb473ff..17a5abc84f2b 100644 --- a/SunSpider/ChangeLog +++ b/SunSpider/ChangeLog @@ -1,3 +1,13 @@ +2007-10-20 Eric Seidel + + Reviewed by darin. + + Add improved argument handling to sunspider, including + --runs=, --tests= Reviewed by Mark. diff --git a/SunSpider/sunspider b/SunSpider/sunspider index dc397ef896ac..e9c023f790b7 100755 --- a/SunSpider/sunspider +++ b/SunSpider/sunspider @@ -1,6 +1,7 @@ #!/usr/bin/perl -w # Copyright (C) 2007 Apple Inc. All rights reserved. +# Copyright (C) Eric Seidel # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -24,72 +25,123 @@ # 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 = < \$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 () { + 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 () { - 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; diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog index 4216056d6076..b80fb90f7f97 100644 --- a/WebKitTools/ChangeLog +++ b/WebKitTools/ChangeLog @@ -1,3 +1,17 @@ +2007-10-20 Eric Seidel + + Reviewed by darin. + + Add improved argument handling to run-sunspider, including + --runs=, --shell=, --tests=, --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 Not reviewed, Windows build fix. diff --git a/WebKitTools/Scripts/build-dumprendertree b/WebKitTools/Scripts/build-dumprendertree index 7e17564846ef..6c2679b8abee 100755 --- a/WebKitTools/Scripts/build-dumprendertree +++ b/WebKitTools/Scripts/build-dumprendertree @@ -26,9 +26,6 @@ # (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; diff --git a/WebKitTools/Scripts/build-testkjs b/WebKitTools/Scripts/build-testkjs new file mode 100755 index 000000000000..f7911a09f8a9 --- /dev/null +++ b/WebKitTools/Scripts/build-testkjs @@ -0,0 +1,54 @@ +#!/usr/bin/perl -w + +# Copyright (C) 2005 Apple Computer, Inc. All rights reserved. +# Copyright (C) 2007 Eric Seidel +# +# 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); diff --git a/WebKitTools/Scripts/run-javascriptcore-tests b/WebKitTools/Scripts/run-javascriptcore-tests index 9f4cc04382d8..add0bf7f6b79 100755 --- a/WebKitTools/Scripts/run-javascriptcore-tests +++ b/WebKitTools/Scripts/run-javascriptcore-tests @@ -1,6 +1,7 @@ #!/usr/bin/perl -w # Copyright (C) 2005 Apple Computer, Inc. All rights reserved. +# Copyright (C) 2007 Eric Seidel # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -64,7 +65,7 @@ foreach my $arg(@ARGV) { 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 { @@ -74,22 +75,26 @@ foreach my $arg(@ARGV) { 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; @@ -97,21 +102,16 @@ $productDir .= "/JavaScriptCore" if (isQt() or isGtk()); $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; diff --git a/WebKitTools/Scripts/run-sunspider b/WebKitTools/Scripts/run-sunspider index dabcc7a2604e..b2beec5dc255 100755 --- a/WebKitTools/Scripts/run-sunspider +++ b/WebKitTools/Scripts/run-sunspider @@ -1,6 +1,7 @@ #!/usr/bin/perl -w # Copyright (C) 2007 Apple Inc. All rights reserved. +# Copyright (C) 2007 Eric Seidel # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -25,69 +26,88 @@ 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= 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 = < 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; diff --git a/WebKitTools/Scripts/run-webkit-tests b/WebKitTools/Scripts/run-webkit-tests index 1d624053adb3..bbccd120fa3d 100755 --- a/WebKitTools/Scripts/run-webkit-tests +++ b/WebKitTools/Scripts/run-webkit-tests @@ -3,6 +3,7 @@ # 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 # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -249,23 +250,13 @@ $productDir .= "/bin" if (isQt()); 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); -- 2.36.0