[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

ossy at webkit.org ossy at webkit.org
Thu Apr 8 01:38:25 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 4833723b32fd75d831a3988f172aff76211919a8
Author: ossy at webkit.org <ossy at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Feb 4 01:07:11 2010 +0000

    Rubber-stamped by Eric Seidel.
    
    Roll back r53559 and r54084 again, because roll out didn't solve flakeyness on the Windows Test bots
    https://bugs.webkit.org/show_bug.cgi?id=34399
    
    * Scripts/run-iexploder-tests:
    * Scripts/run-webkit-httpd:
    * Scripts/run-webkit-tests:
    * Scripts/webkitperl/httpd.pm: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54314 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 89bf080..fb86419 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -2,6 +2,18 @@
 
         Rubber-stamped by Eric Seidel.
 
+        Roll back r53559 and r54084 again, because roll out didn't solve flakeyness on the Windows Test bots
+        https://bugs.webkit.org/show_bug.cgi?id=34399
+
+        * Scripts/run-iexploder-tests:
+        * Scripts/run-webkit-httpd:
+        * Scripts/run-webkit-tests:
+        * Scripts/webkitperl/httpd.pm: Added.
+
+2010-02-03  Csaba Osztrogonác  <ossy at webkit.org>
+
+        Rubber-stamped by Eric Seidel.
+
         Roll out r53559 and r54084, because it might caused flakeyness on the Windows Test bots
 
         * Scripts/run-iexploder-tests:
diff --git a/WebKitTools/Scripts/run-iexploder-tests b/WebKitTools/Scripts/run-iexploder-tests
index ed5ecd6..1b3976f 100755
--- a/WebKitTools/Scripts/run-iexploder-tests
+++ b/WebKitTools/Scripts/run-iexploder-tests
@@ -38,16 +38,17 @@ use Getopt::Long;
 use IPC::Open2;
 
 use lib $FindBin::Bin;
+use webkitperl::httpd;
 use webkitdirs;
 
-sub openHTTPDIfNeeded();
-sub closeHTTPD();
+sub configureAndOpenHTTPDIfNeeded();
 sub runSafariWithIExploder();
 
 # Argument handling
 my $guardMalloc = '';
 my $httpdPort = 8000;
 my $downloadTest;
+my $iExploderTestDirectory = "/tmp/iExploderTest";
 
 GetOptions(
     'guard-malloc|g' => \$guardMalloc,
@@ -63,8 +64,8 @@ chdirWebKit();
 
 checkFrameworks();
 
-my $httpdOpen = 0;
-openHTTPDIfNeeded();
+my $isHttpdOpen = 0;
+configureAndOpenHTTPDIfNeeded();
 
 if ($downloadTest) {
     system "/usr/bin/curl -o ~/Desktop/iexploder$downloadTest.html \"http://127.0.0.1:$httpdPort/iexploder.cgi?lookup=1&test=$downloadTest\"";
@@ -72,11 +73,11 @@ if ($downloadTest) {
 } else {
     runSafariWithIExploder();
     print "Last generated tests:\n";
-    system "grep 'iexploder.cgi' /tmp/WebKit/access_log.txt | tail -n -5 | awk -F'[ =&\\?]' '{if (\$8 == \"lookup\") print \$11; else print \$9}'";
+    system "grep 'iexploder.cgi' $iExploderTestDirectory/access_log.txt | tail -n -5 | awk -F'[ =&\\?]' '{if (\$8 == \"lookup\") print \$11; else print \$9}'";
 }
 
-closeHTTPD();
-
+rmtree $iExploderTestDirectory;
+$isHttpdOpen = !closeHTTPD();
 
 sub runSafariWithIExploder()
 {
@@ -87,7 +88,7 @@ sub runSafariWithIExploder()
         $redirectTo = "http://127.0.0.1:$httpdPort/index.html";
     }
 
-    open REDIRECT_HTML, ">", "/tmp/WebKit/redirect.html" or die;
+    open REDIRECT_HTML, ">", "$iExploderTestDirectory/redirect.html" or die;
     print REDIRECT_HTML "<html>\n";
     print REDIRECT_HTML "    <head>\n";
     print REDIRECT_HTML "        <meta http-equiv=\"refresh\" content=\"1;URL=$redirectTo\" />\n";
@@ -102,35 +103,17 @@ sub runSafariWithIExploder()
     
     local %ENV;
     $ENV{DYLD_INSERT_LIBRARIES} = "/usr/lib/libgmalloc.dylib" if $guardMalloc;
-    system "WebKitTools/Scripts/run-safari", "-NSOpen", "/tmp/WebKit/redirect.html";
+    system "WebKitTools/Scripts/run-safari", "-NSOpen", "$iExploderTestDirectory/redirect.html";
 }
 
-sub openHTTPDIfNeeded()
+sub configureAndOpenHTTPDIfNeeded()
 {
-    return if $httpdOpen;
-
-    mkdir "/tmp/WebKit";
-    
-    if (-f "/tmp/WebKit/httpd.pid") {
-        my $oldPid = `cat /tmp/WebKit/httpd.pid`;
-        chomp $oldPid;
-        if (0 != kill 0, $oldPid) {
-            print "\nhttpd is already running: pid $oldPid, killing...\n";
-            kill 15, $oldPid;
-            
-            my $retryCount = 20;
-            while ((0 != kill 0, $oldPid) && $retryCount) {
-                sleep 1;
-                --$retryCount;
-            }
-            
-            die "Timed out waiting for httpd to quit" unless $retryCount;
-        }
-    }
-    
-    my $testDirectory = getcwd() . "/LayoutTests";
-    my $iExploderDirectory = getcwd() . "/WebKitTools/iExploder";
-    my $httpdPath = "/usr/sbin/httpd";
+    return if $isHttpdOpen;
+    mkdir $iExploderTestDirectory;
+    my $httpdPath = getHTTPDPath();
+    my $webkitDirectory = getcwd();
+    my $testDirectory = $webkitDirectory . "/LayoutTests";
+    my $iExploderDirectory = $webkitDirectory . "/WebKitTools/iExploder";
     my $httpdConfig = "$testDirectory/http/conf/httpd.conf";
     $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
     my $documentRoot = "$iExploderDirectory/htdocs";
@@ -138,36 +121,18 @@ sub openHTTPDIfNeeded()
     my $sslCertificate = "$testDirectory/http/conf/webkit-httpd.pem";
     my $listen = "127.0.0.1:$httpdPort";
 
-    open2(\*HTTPDIN, \*HTTPDOUT, $httpdPath, 
+
+    my @args = (
         "-f", "$httpdConfig",
         "-C", "DocumentRoot \"$documentRoot\"",
         "-C", "Listen $listen",
         "-c", "TypesConfig \"$typesConfig\"",
-        "-c", "CustomLog \"/tmp/WebKit/access_log.txt\" common",
-        "-c", "ErrorLog \"/tmp/WebKit/error_log.txt\"",
+        "-c", "CustomLog \"$iExploderTestDirectory/access_log.txt\" common",
+        "-c", "ErrorLog \"$iExploderTestDirectory/error_log.txt\"",
         "-c", "SSLCertificateFile \"$sslCertificate\"",
         # Apache wouldn't run CGIs with permissions==700 otherwise
-        "-c", "User \"#$<\"");
-
-    my $retryCount = 20;
-    while (system("/usr/bin/curl -q --silent --stderr - --output " . File::Spec->devnull() . " $listen") && $retryCount) {
-        sleep 1;
-        --$retryCount;
-    }
-    
-    die "Timed out waiting for httpd to start" unless $retryCount;
-    
-    $httpdOpen = 1;
-}
-
-sub closeHTTPD()
-{
-    return if !$httpdOpen;
-
-    close HTTPDIN;
-    close HTTPDOUT;
-
-    kill 15, `cat /tmp/WebKit/httpd.pid` if -f "/tmp/WebKit/httpd.pid";
+        "-c", "User \"#$<\""
+    );
 
-    $httpdOpen = 0;
+    $isHttpdOpen = openHTTPD(@args);
 }
diff --git a/WebKitTools/Scripts/run-webkit-httpd b/WebKitTools/Scripts/run-webkit-httpd
index 9a97190..018f64c 100755
--- a/WebKitTools/Scripts/run-webkit-httpd
+++ b/WebKitTools/Scripts/run-webkit-httpd
@@ -33,11 +33,13 @@ use strict;
 use warnings;
 
 use Cwd;
+use File::Path;
 use File::Basename;
 use Getopt::Long;
 use FindBin;
 
 use lib $FindBin::Bin;
+use webkitperl::httpd;
 use webkitdirs;
 
 # Argument handling
@@ -62,39 +64,7 @@ if (!$result || @ARGV || $showHelp) {
 setConfiguration();
 my $productDir = productDir();
 chdirWebKit();
-
-mkdir "/tmp/WebKit";
-
-if (-f "/tmp/WebKit/httpd.pid") {
-    my $oldPid = `cat /tmp/WebKit/httpd.pid`;
-    chomp $oldPid;
-    if (0 != kill 0, $oldPid) {
-        print "\nhttpd is already running: pid $oldPid, killing...\n";
-        kill 15, $oldPid;
-        
-        my $retryCount = 20;
-        while ((0 != kill 0, $oldPid) && $retryCount) {
-            sleep 1;
-            --$retryCount;
-        }
-        
-        die "Timed out waiting for httpd to quit" unless $retryCount;
-    }
-}
-
-my $testDirectory = getcwd() . "/LayoutTests";
-my $jsTestResourcesDirectory = $testDirectory . "/fast/js/resources";
-my $httpdPath = "/usr/sbin/httpd";
-$httpdPath = "/usr/sbin/apache2" if isDebianBased();
-my $httpdConfig = "$testDirectory/http/conf/httpd.conf";
-$httpdConfig = "$testDirectory/http/conf/cygwin-httpd.conf" if isCygwin();
-$httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
-$httpdConfig = "$testDirectory/http/conf/apache2-debian-httpd.conf" if isDebianBased();
-$httpdConfig = "$testDirectory/http/conf/fedora-httpd.conf" if isFedoraBased();
-my $documentRoot = "$testDirectory/http/tests";
-my $typesConfig = "$testDirectory/http/conf/mime.types";
-my $sslCertificate = "$testDirectory/http/conf/webkit-httpd.pem";
-
+my $testDirectory = File::Spec->catfile(getcwd(), "LayoutTests");
 my $listen = "127.0.0.1:$httpdPort";
 $listen = "$httpdPort" if ($allInterfaces);
 
@@ -103,19 +73,13 @@ if ($allInterfaces) {
 } else {
     print "Starting httpd on <http://$listen/>...\n";
 }
+setShouldWaitForUserInterrupt();
 print "Press Ctrl+C to stop it.\n\n";
 
 my @args = (
-    "-f", "$httpdConfig",
-    "-C", "DocumentRoot \"$documentRoot\"",
-    # Setup a link to where the js test templates are stored, use -c so that mod_alias will already be laoded.
-    "-c", "Alias /js-test-resources \"$jsTestResourcesDirectory\"",
     "-C", "Listen $listen",
-    "-c", "TypesConfig \"$typesConfig\"",
     "-c", "CustomLog |/usr/bin/tee common",
     "-c", "ErrorLog |/usr/bin/tee",
-    # Apache wouldn't run CGIs with permissions==700 otherwise.
-    "-c", "User \"#$<\"",
     # Run in single-process mode, do not detach from the controlling terminal.
     "-X",
     # Disable Keep-Alive support. Makes testing in multiple browsers easier (no need to wait
@@ -123,9 +87,6 @@ my @args = (
     "-c", "KeepAlive 0"
 );
 
-# FIXME: Enable this on Windows once <rdar://problem/5345985> is fixed
-push(@args, "-c", "SSLCertificateFile \"$sslCertificate\"") unless isCygwin();
-
-system($httpdPath, @args);
-
-unlink "/tmp/WebKit/httpd.pid";
+my @defaultArgs = getDefaultConfigForTestDirectory($testDirectory);
+ at args = (@defaultArgs, @args);
+openHTTPD(@args);
diff --git a/WebKitTools/Scripts/run-webkit-tests b/WebKitTools/Scripts/run-webkit-tests
index e80326e..bb4fb34 100755
--- a/WebKitTools/Scripts/run-webkit-tests
+++ b/WebKitTools/Scripts/run-webkit-tests
@@ -67,6 +67,7 @@ use Time::HiRes qw(time usleep);
 use List::Util 'shuffle';
 
 use lib $FindBin::Bin;
+use webkitperl::httpd;
 use webkitdirs;
 use VCSUtils;
 use POSIX;
@@ -75,8 +76,8 @@ sub buildPlatformResultHierarchy();
 sub buildPlatformTestHierarchy(@);
 sub closeCygpaths();
 sub closeDumpTool();
-sub closeHTTPD();
 sub closeWebSocketServer();
+sub configureAndOpenHTTPDIfNeeded();
 sub countAndPrintLeaks($$$);
 sub countFinishedTest($$$$);
 sub deleteExpectedAndActualResults($);
@@ -91,7 +92,6 @@ sub resolveAndMakeTestResultsDirectory();
 sub numericcmp($$);
 sub openDiffTool();
 sub openDumpTool();
-sub openHTTPDIfNeeded();
 sub parseLeaksandPrintUniqueLeaks();
 sub openWebSocketServerIfNeeded();
 sub pathcmp($$);
@@ -143,7 +143,8 @@ my $showHelp = 0;
 my $stripEditingCallbacks = isCygwin();
 my $testHTTP = 1;
 my $testMedia = 1;
-my $testResultsDirectory = "/tmp/layout-test-results";
+my $tmpDir = "/tmp";
+my $testResultsDirectory = File::Spec->catfile($tmpDir, "layout-test-results");
 my $testsPerDumpTool = 1000;
 my $threaded = 0;
 # DumpRenderTree has an internal timeout of 15 seconds, so this must be > 15.
@@ -383,7 +384,8 @@ my @platformTestHierarchy = buildPlatformTestHierarchy(@platformResultHierarchy)
 
 $expectedDirectory = $ENV{"WebKitExpectedTestResultsDirectory"} if $ENV{"WebKitExpectedTestResultsDirectory"};
 
-my $testResults = catfile($testResultsDirectory, "results.html");
+$testResultsDirectory = File::Spec->rel2abs($testResultsDirectory);
+my $testResults = File::Spec->catfile($testResultsDirectory, "results.html");
 
 print "Running tests from $testDirectory\n";
 if ($pixelTests) {
@@ -605,7 +607,7 @@ for my $test (@tests) {
     }
 
     if ($test =~ /^http\//) {
-        openHTTPDIfNeeded();
+        configureAndOpenHTTPDIfNeeded();
         if ($test !~ /^http\/tests\/local\// && $test !~ /^http\/tests\/ssl\// && $test !~ /^http\/tests\/wml\// && $test !~ /^http\/tests\/media\//) {
             my $path = canonpath($test);
             $path =~ s/^http\/tests\///;
@@ -945,7 +947,7 @@ printf "\n%0.2fs total testing time\n", (time - $overallStartTime) . "";
 
 !$isDumpToolOpen || die "Failed to close $dumpToolName.\n";
 
-closeHTTPD();
+$isHttpdOpen = !closeHTTPD();
 closeWebSocketServer();
 
 # Because multiple instances of this script are running concurrently we cannot 
@@ -1345,95 +1347,21 @@ sub dumpToolDidCrash()
     return DumpRenderTreeSupport::processIsCrashing($dumpToolPID);
 }
 
-sub openHTTPDIfNeeded()
+sub configureAndOpenHTTPDIfNeeded()
 {
     return if $isHttpdOpen;
-
-    mkdir "/tmp/WebKit";
-    
-    if (-f "/tmp/WebKit/httpd.pid") {
-        my $oldPid = `cat /tmp/WebKit/httpd.pid`;
-        chomp $oldPid;
-        if (0 != kill 0, $oldPid) {
-            print "\nhttpd is already running: pid $oldPid, killing...\n";
-            kill 15, $oldPid;
-            
-            my $retryCount = 20;
-            while ((0 != kill 0, $oldPid) && $retryCount) {
-                sleep 1;
-                --$retryCount;
-            }
-            
-            die "Timed out waiting for httpd to quit" unless $retryCount;
-        }
-    }
-    
-    my $httpdPath = "/usr/sbin/httpd";
-    my $httpdConfig;
-    if (isCygwin()) {
-        my $windowsConfDirectory = "$testDirectory/http/conf/";
-        unless (-x "/usr/lib/apache/libphp4.dll") {
-            copy("$windowsConfDirectory/libphp4.dll", "/usr/lib/apache/libphp4.dll");
-            chmod(0755, "/usr/lib/apache/libphp4.dll");
-        }
-        $httpdConfig = "$windowsConfDirectory/cygwin-httpd.conf";
-    } elsif (isDebianBased()) {
-        $httpdPath = "/usr/sbin/apache2";
-        $httpdConfig = "$testDirectory/http/conf/apache2-debian-httpd.conf";
-    } elsif (isFedoraBased()) {
-        $httpdPath = "/usr/sbin/httpd";
-        $httpdConfig = "$testDirectory/http/conf/fedora-httpd.conf";
-    } else {
-        $httpdConfig = "$testDirectory/http/conf/httpd.conf";
-        $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
-    }
-    my $documentRoot = "$testDirectory/http/tests";
-    my $jsTestResourcesDirectory = $testDirectory . "/fast/js/resources";
-    my $typesConfig = "$testDirectory/http/conf/mime.types";
-    my $listen = "127.0.0.1:$httpdPort";
     my $absTestResultsDirectory = resolveAndMakeTestResultsDirectory();
-    my $sslCertificate = "$testDirectory/http/conf/webkit-httpd.pem";
-
+    my $listen = "127.0.0.1:$httpdPort";
     my @args = (
-        "-f", "$httpdConfig",
-        "-C", "DocumentRoot \"$documentRoot\"",
-        # Setup a link to where the js test templates are stored, use -c so that mod_alias will already be laoded.
-        "-c", "Alias /js-test-resources \"$jsTestResourcesDirectory\"",
-        "-C", "Listen $listen",
-        "-c", "TypesConfig \"$typesConfig\"",
         "-c", "CustomLog \"$absTestResultsDirectory/access_log.txt\" common",
         "-c", "ErrorLog \"$absTestResultsDirectory/error_log.txt\"",
-        # Apache wouldn't run CGIs with permissions==700 otherwise
-        "-c", "User \"#$<\""
+        "-C", "Listen $listen"
     );
 
-    # FIXME: Enable this on Windows once <rdar://problem/5345985> is fixed
-    # The version of Apache we use with Cygwin does not support SSL
-    push(@args, "-c", "SSLCertificateFile \"$sslCertificate\"") unless isCygwin();
-
-    open2(\*HTTPDIN, \*HTTPDOUT, $httpdPath, @args);
-
-    my $retryCount = 20;
-    while (system("/usr/bin/curl -q --silent --stderr - --output " . File::Spec->devnull() . " $listen") && $retryCount) {
-        sleep 1;
-        --$retryCount;
-    }
-    
-    die "Timed out waiting for httpd to start" unless $retryCount;
-    
-    $isHttpdOpen = 1;
-}
-
-sub closeHTTPD()
-{
-    return if !$isHttpdOpen;
-
-    close HTTPDIN;
-    close HTTPDOUT;
-
-    kill 15, `cat /tmp/WebKit/httpd.pid` if -f "/tmp/WebKit/httpd.pid";
+    my @defaultArgs = getDefaultConfigForTestDirectory($testDirectory);
+    @args = (@defaultArgs, @args);
 
-    $isHttpdOpen = 0;
+    $isHttpdOpen = openHTTPD(@args);
 }
 
 sub openWebSocketServerIfNeeded()
diff --git a/WebKitTools/Scripts/webkitperl/httpd.pm b/WebKitTools/Scripts/webkitperl/httpd.pm
new file mode 100644
index 0000000..d082870
--- /dev/null
+++ b/WebKitTools/Scripts/webkitperl/httpd.pm
@@ -0,0 +1,202 @@
+# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved
+# Copyright (C) 2006 Alexey Proskuryakov (ap at nypop.com)
+# Copyright (C) 2010 Andras Becsi (abecsi at inf.u-szeged.hu), University of Szeged
+#
+# 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.
+
+# Module to share code to start and stop the Apache daemon.
+
+use strict;
+use warnings;
+
+use File::Path;
+use File::Spec;
+use File::Spec::Functions;
+use IPC::Open2;
+
+use webkitdirs;
+
+BEGIN {
+   use Exporter   ();
+   our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
+   $VERSION     = 1.00;
+   @ISA         = qw(Exporter);
+   @EXPORT      = qw(&getHTTPDPath &getDefaultConfigForTestDirectory &openHTTPD &closeHTTPD &getHTTPDPid &setShouldWaitForUserInterrupt);
+   %EXPORT_TAGS = ( );
+   @EXPORT_OK   = ();
+}
+
+my $tmpDir = "/tmp";
+my $httpdPath;
+my $httpdPidDir = File::Spec->catfile($tmpDir, "WebKit");
+my $httpdPidFile = File::Spec->catfile($httpdPidDir, "httpd.pid");
+my $httpdPid;
+my $waitForUserInterrupt = 0;
+
+$SIG{'INT'} = 'cleanup';
+$SIG{'TERM'} = 'cleanup';
+
+sub getHTTPDPath
+{
+    if (isDebianBased()) {
+        $httpdPath = "/usr/sbin/apache2";
+    } else {
+        $httpdPath = "/usr/sbin/httpd";
+    }
+    return $httpdPath;
+}
+
+sub getDefaultConfigForTestDirectory
+{
+    my ($testDirectory) = @_;
+    die "No test directory has been specified." unless ($testDirectory);
+
+    my $httpdConfig;
+    getHTTPDPath();
+    if (isCygwin()) {
+        my $windowsConfDirectory = "$testDirectory/http/conf/";
+        unless (-x "/usr/lib/apache/libphp4.dll") {
+            copy("$windowsConfDirectory/libphp4.dll", "/usr/lib/apache/libphp4.dll");
+            chmod(0755, "/usr/lib/apache/libphp4.dll");
+        }
+        $httpdConfig = "$windowsConfDirectory/cygwin-httpd.conf";
+    } elsif (isDebianBased()) {
+        $httpdConfig = "$testDirectory/http/conf/apache2-debian-httpd.conf";
+    } elsif (isFedoraBased()) {
+        $httpdConfig = "$testDirectory/http/conf/fedora-httpd.conf";
+    } else {
+        $httpdConfig = "$testDirectory/http/conf/httpd.conf";
+        $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
+    }
+
+    my $documentRoot = "$testDirectory/http/tests";
+    my $jsTestResourcesDirectory = $testDirectory . "/fast/js/resources";
+    my $typesConfig = "$testDirectory/http/conf/mime.types";
+    my $httpdLockFile = File::Spec->catfile($httpdPidDir, "httpd.lock");
+    my $httpdScoreBoardFile = File::Spec->catfile($httpdPidDir, "httpd.scoreboard");
+
+    my @httpdArgs = (
+        "-f", "$httpdConfig",
+        "-C", "DocumentRoot \"$documentRoot\"",
+        # Setup a link to where the js test templates are stored, use -c so that mod_alias will already be loaded.
+        "-c", "Alias /js-test-resources \"$jsTestResourcesDirectory\"",
+        "-c", "TypesConfig \"$typesConfig\"",
+        # Apache wouldn't run CGIs with permissions==700 otherwise
+        "-c", "User \"#$<\"",
+        "-c", "LockFile \"$httpdLockFile\"",
+        "-c", "PidFile \"$httpdPidFile\"",
+        "-c", "ScoreBoardFile \"$httpdScoreBoardFile\"",
+    );
+
+    # FIXME: Enable this on Windows once <rdar://problem/5345985> is fixed
+    # The version of Apache we use with Cygwin does not support SSL
+    my $sslCertificate = "$testDirectory/http/conf/webkit-httpd.pem";
+    push(@httpdArgs, "-c", "SSLCertificateFile \"$sslCertificate\"") unless isCygwin();
+
+    return @httpdArgs;
+
+}
+
+sub openHTTPD(@)
+{
+    my (@args) = @_;
+    die "No HTTPD configuration has been specified" unless (@args);
+    mkdir($httpdPidDir, 0755);
+    die "No write permissions to $httpdPidDir" unless (-w $httpdPidDir);
+
+    if (-f $httpdPidFile) {
+        open (PIDFILE, $httpdPidFile);
+        my $oldPid = <PIDFILE>;
+        chomp $oldPid;
+        close PIDFILE;
+        if (0 != kill 0, $oldPid) {
+            print "\nhttpd is already running: pid $oldPid, killing...\n";
+            kill 15, $oldPid;
+
+            my $retryCount = 20;
+            while ((kill(0, $oldPid) != 0) && $retryCount) {
+                sleep 1;
+                --$retryCount;
+            }
+
+            die "Timed out waiting for httpd to quit" unless $retryCount;
+        }
+    }
+
+    $httpdPath = "/usr/sbin/httpd" unless ($httpdPath);
+
+    open2(">&1", \*HTTPDIN, $httpdPath, @args);
+
+    my $retryCount = 20;
+    while (!-f $httpdPidFile && $retryCount) {
+        sleep 1;
+        --$retryCount;
+    }
+
+    if (!$retryCount) {
+        rmtree $httpdPidDir;
+        die "Timed out waiting for httpd to start";
+    }
+
+    $httpdPid = <PIDFILE> if open(PIDFILE, $httpdPidFile);
+    chomp $httpdPid if $httpdPid;
+    close PIDFILE;
+
+    waitpid($httpdPid, 0) if ($waitForUserInterrupt && $httpdPid);
+
+    return 1;
+}
+
+sub closeHTTPD
+{
+    close HTTPDIN;
+    if ($httpdPid) {
+        kill 15, $httpdPid;
+        my $retryCount = 20;
+        while (-f $httpdPidFile && $retryCount) {
+            sleep 1;
+            --$retryCount;
+        }
+
+        if (!$retryCount) {
+            print STDERR "Timed out waiting for httpd to terminate!\n";
+            return 0;
+        }
+    }
+    rmdir $httpdPidDir;
+    return 1;
+}
+
+sub setShouldWaitForUserInterrupt
+{
+    $waitForUserInterrupt = 1;
+}
+
+sub cleanup
+{
+    closeHTTPD();
+    print "\n";
+    exit(1);
+}

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list