Changeset 53559 in webkit


Ignore:
Timestamp:
Jan 20, 2010 12:05:58 PM (14 years ago)
Author:
Csaba Osztrogonác
Message:

Extract Apache handling to httpd.pm module and use the provided functionality
in scripts where Apache is needed.
The module httpd.pm stores the PID of Apache in a variable and cleans up
the PID directory after Apache properly shut down. Catching INT and TERM
signals allows the scripts to close Apache and clean up its PID directory
even if the testing was interrupted.

Patch by Andras Becsi <abecsi@inf.u-szeged.hu> on 2010-01-20
Reviewed by Alexey Proskuryakov.

https://bugs.webkit.org/show_bug.cgi?id=33153

  • Scripts/webkitperl/httpd.pm: Added.
  • Scripts/run-iexploder-tests:
  • Scripts/run-webkit-httpd:
  • Scripts/run-webkit-tests:
Location:
trunk/WebKitTools
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r53543 r53559  
     12010-01-20  Andras Becsi  <abecsi@inf.u-szeged.hu>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        Extract Apache handling to httpd.pm module and use the provided functionality
     6        in scripts where Apache is needed.
     7        The module httpd.pm stores the PID of Apache in a variable and cleans up
     8        the PID directory after Apache properly shut down. Catching INT and TERM
     9        signals allows the scripts to close Apache and clean up its PID directory
     10        even if the testing was interrupted.
     11
     12        https://bugs.webkit.org/show_bug.cgi?id=33153
     13
     14        * Scripts/webkitperl/httpd.pm: Added.
     15        * Scripts/run-iexploder-tests:
     16        * Scripts/run-webkit-httpd:
     17        * Scripts/run-webkit-tests:
     18
    1192010-01-20  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
    220
  • trunk/WebKitTools/Scripts/run-iexploder-tests

    r50080 r53559  
    3939
    4040use lib $FindBin::Bin;
     41use webkitperl::httpd;
    4142use webkitdirs;
    4243
    43 sub openHTTPDIfNeeded();
    44 sub closeHTTPD();
     44sub configureAndOpenHTTPDIfNeeded();
    4545sub runSafariWithIExploder();
    4646
     
    4949my $httpdPort = 8000;
    5050my $downloadTest;
     51my $iExploderTestDirectory = "/tmp/iExploderTest";
    5152
    5253GetOptions(
     
    6465checkFrameworks();
    6566
    66 my $httpdOpen = 0;
    67 openHTTPDIfNeeded();
     67my $isHttpdOpen = 0;
     68configureAndOpenHTTPDIfNeeded();
    6869
    6970if ($downloadTest) {
     
    7374    runSafariWithIExploder();
    7475    print "Last generated tests:\n";
    75     system "grep 'iexploder.cgi' /tmp/WebKit/access_log.txt | tail -n -5 | awk -F'[ =&\\?]' '{if (\$8 == \"lookup\") print \$11; else print \$9}'";
     76    system "grep 'iexploder.cgi' $iExploderTestDirectory/access_log.txt | tail -n -5 | awk -F'[ =&\\?]' '{if (\$8 == \"lookup\") print \$11; else print \$9}'";
    7677}
    7778
    78 closeHTTPD();
    79 
     79rmtree $iExploderTestDirectory;
     80$isHttpdOpen = !closeHTTPD();
    8081
    8182sub runSafariWithIExploder()
     
    8889    }
    8990
    90     open REDIRECT_HTML, ">", "/tmp/WebKit/redirect.html" or die;
     91    open REDIRECT_HTML, ">", "$iExploderTestDirectory/redirect.html" or die;
    9192    print REDIRECT_HTML "<html>\n";
    9293    print REDIRECT_HTML "    <head>\n";
     
    103104    local %ENV;
    104105    $ENV{DYLD_INSERT_LIBRARIES} = "/usr/lib/libgmalloc.dylib" if $guardMalloc;
    105     system "WebKitTools/Scripts/run-safari", "-NSOpen", "/tmp/WebKit/redirect.html";
     106    system "WebKitTools/Scripts/run-safari", "-NSOpen", "$iExploderTestDirectory/redirect.html";
    106107}
    107108
    108 sub openHTTPDIfNeeded()
     109sub configureAndOpenHTTPDIfNeeded()
    109110{
    110     return if $httpdOpen;
    111 
    112     mkdir "/tmp/WebKit";
    113    
    114     if (-f "/tmp/WebKit/httpd.pid") {
    115         my $oldPid = `cat /tmp/WebKit/httpd.pid`;
    116         chomp $oldPid;
    117         if (0 != kill 0, $oldPid) {
    118             print "\nhttpd is already running: pid $oldPid, killing...\n";
    119             kill 15, $oldPid;
    120            
    121             my $retryCount = 20;
    122             while ((0 != kill 0, $oldPid) && $retryCount) {
    123                 sleep 1;
    124                 --$retryCount;
    125             }
    126            
    127             die "Timed out waiting for httpd to quit" unless $retryCount;
    128         }
    129     }
    130    
    131     my $testDirectory = getcwd() . "/LayoutTests";
    132     my $iExploderDirectory = getcwd() . "/WebKitTools/iExploder";
    133     my $httpdPath = "/usr/sbin/httpd";
     111    return if $isHttpdOpen;
     112    mkdir $iExploderTestDirectory;
     113    my $httpdPath = getHTTPDPath();
     114    my $webkitDirectory = getcwd();
     115    my $testDirectory = $webkitDirectory . "/LayoutTests";
     116    my $iExploderDirectory = $webkitDirectory . "/WebKitTools/iExploder";
    134117    my $httpdConfig = "$testDirectory/http/conf/httpd.conf";
    135118    $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
     
    139122    my $listen = "127.0.0.1:$httpdPort";
    140123
    141     open2(\*HTTPDIN, \*HTTPDOUT, $httpdPath,
     124
     125    my @args = (
    142126        "-f", "$httpdConfig",
    143127        "-C", "DocumentRoot \"$documentRoot\"",
    144128        "-C", "Listen $listen",
    145129        "-c", "TypesConfig \"$typesConfig\"",
    146         "-c", "CustomLog \"/tmp/WebKit/access_log.txt\" common",
    147         "-c", "ErrorLog \"/tmp/WebKit/error_log.txt\"",
     130        "-c", "CustomLog \"$iExploderTestDirectory/access_log.txt\" common",
     131        "-c", "ErrorLog \"$iExploderTestDirectory/error_log.txt\"",
    148132        "-c", "SSLCertificateFile \"$sslCertificate\"",
    149133        # Apache wouldn't run CGIs with permissions==700 otherwise
    150         "-c", "User \"#$<\"");
     134        "-c", "User \"#$<\""
     135    );
    151136
    152     my $retryCount = 20;
    153     while (system("/usr/bin/curl -q --silent --stderr - --output " . File::Spec->devnull() . " $listen") && $retryCount) {
    154         sleep 1;
    155         --$retryCount;
    156     }
    157    
    158     die "Timed out waiting for httpd to start" unless $retryCount;
    159    
    160     $httpdOpen = 1;
     137    $isHttpdOpen = openHTTPD(@args);
    161138}
    162 
    163 sub closeHTTPD()
    164 {
    165     return if !$httpdOpen;
    166 
    167     close HTTPDIN;
    168     close HTTPDOUT;
    169 
    170     kill 15, `cat /tmp/WebKit/httpd.pid` if -f "/tmp/WebKit/httpd.pid";
    171 
    172     $httpdOpen = 0;
    173 }
  • trunk/WebKitTools/Scripts/run-webkit-httpd

    r47930 r53559  
    3434
    3535use Cwd;
     36use File::Path;
    3637use File::Basename;
    3738use Getopt::Long;
     
    3940
    4041use lib $FindBin::Bin;
     42use webkitperl::httpd;
    4143use webkitdirs;
    4244
     
    6365my $productDir = productDir();
    6466chdirWebKit();
    65 
    66 mkdir "/tmp/WebKit";
    67 
    68 if (-f "/tmp/WebKit/httpd.pid") {
    69     my $oldPid = `cat /tmp/WebKit/httpd.pid`;
    70     chomp $oldPid;
    71     if (0 != kill 0, $oldPid) {
    72         print "\nhttpd is already running: pid $oldPid, killing...\n";
    73         kill 15, $oldPid;
    74        
    75         my $retryCount = 20;
    76         while ((0 != kill 0, $oldPid) && $retryCount) {
    77             sleep 1;
    78             --$retryCount;
    79         }
    80        
    81         die "Timed out waiting for httpd to quit" unless $retryCount;
    82     }
    83 }
    84 
    85 my $testDirectory = getcwd() . "/LayoutTests";
    86 my $jsTestResourcesDirectory = $testDirectory . "/fast/js/resources";
    87 my $httpdPath = "/usr/sbin/httpd";
    88 $httpdPath = "/usr/sbin/apache2" if isDebianBased();
    89 my $httpdConfig = "$testDirectory/http/conf/httpd.conf";
    90 $httpdConfig = "$testDirectory/http/conf/cygwin-httpd.conf" if isCygwin();
    91 $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
    92 $httpdConfig = "$testDirectory/http/conf/apache2-debian-httpd.conf" if isDebianBased();
    93 $httpdConfig = "$testDirectory/http/conf/fedora-httpd.conf" if isFedoraBased();
    94 my $documentRoot = "$testDirectory/http/tests";
    95 my $typesConfig = "$testDirectory/http/conf/mime.types";
    96 my $sslCertificate = "$testDirectory/http/conf/webkit-httpd.pem";
    97 
     67my $testDirectory = File::Spec->catfile(getcwd(), "LayoutTests");
    9868my $listen = "127.0.0.1:$httpdPort";
    9969$listen = "$httpdPort" if ($allInterfaces);
     
    10474    print "Starting httpd on <http://$listen/>...\n";
    10575}
     76setShouldWaitForUserInterrupt();
    10677print "Press Ctrl+C to stop it.\n\n";
    10778
    10879my @args = (
    109     "-f", "$httpdConfig",
    110     "-C", "DocumentRoot \"$documentRoot\"",
    111     # Setup a link to where the js test templates are stored, use -c so that mod_alias will already be laoded.
    112     "-c", "Alias /js-test-resources \"$jsTestResourcesDirectory\"",
    11380    "-C", "Listen $listen",
    114     "-c", "TypesConfig \"$typesConfig\"",
    11581    "-c", "CustomLog |/usr/bin/tee common",
    11682    "-c", "ErrorLog |/usr/bin/tee",
    117     # Apache wouldn't run CGIs with permissions==700 otherwise.
    118     "-c", "User \"#$<\"",
    11983    # Run in single-process mode, do not detach from the controlling terminal.
    12084    "-X",
     
    12488);
    12589
    126 # FIXME: Enable this on Windows once <rdar://problem/5345985> is fixed
    127 push(@args, "-c", "SSLCertificateFile \"$sslCertificate\"") unless isCygwin();
    128 
    129 system($httpdPath, @args);
    130 
    131 unlink "/tmp/WebKit/httpd.pid";
     90my @defaultArgs = getDefaultConfigForTestDirectory($testDirectory);
     91@args = (@defaultArgs, @args);
     92openHTTPD(@args);
  • trunk/WebKitTools/Scripts/run-webkit-tests

    r53015 r53559  
    6868
    6969use lib $FindBin::Bin;
     70use webkitperl::httpd;
    7071use webkitdirs;
    7172use VCSUtils;
     
    7677sub closeCygpaths();
    7778sub closeDumpTool();
    78 sub closeHTTPD();
    7979sub closeWebSocketServer();
     80sub configureAndOpenHTTPDIfNeeded();
    8081sub countAndPrintLeaks($$$);
    8182sub countFinishedTest($$$$);
     
    9293sub openDiffTool();
    9394sub openDumpTool();
    94 sub openHTTPDIfNeeded();
    9595sub parseLeaksandPrintUniqueLeaks();
    9696sub openWebSocketServerIfNeeded();
     
    144144my $testHTTP = 1;
    145145my $testMedia = 1;
    146 my $testResultsDirectory = "/tmp/layout-test-results";
     146my $tmpDir = "/tmp";
     147my $testResultsDirectory = File::Spec->catfile($tmpDir, "layout-test-results");
    147148my $testsPerDumpTool = 1000;
    148149my $threaded = 0;
     
    384385$expectedDirectory = $ENV{"WebKitExpectedTestResultsDirectory"} if $ENV{"WebKitExpectedTestResultsDirectory"};
    385386
    386 my $testResults = catfile($testResultsDirectory, "results.html");
     387$testResultsDirectory = File::Spec->rel2abs($testResultsDirectory);
     388my $testResults = File::Spec->catfile($testResultsDirectory, "results.html");
    387389
    388390print "Running tests from $testDirectory\n";
     
    606608
    607609    if ($test =~ /^http\//) {
    608         openHTTPDIfNeeded();
     610        configureAndOpenHTTPDIfNeeded();
    609611        if ($test !~ /^http\/tests\/local\// && $test !~ /^http\/tests\/ssl\// && $test !~ /^http\/tests\/wml\// && $test !~ /^http\/tests\/media\//) {
    610612            my $path = canonpath($test);
     
    946948!$isDumpToolOpen || die "Failed to close $dumpToolName.\n";
    947949
    948 closeHTTPD();
     950$isHttpdOpen = !closeHTTPD();
    949951closeWebSocketServer();
    950952
     
    13461348}
    13471349
    1348 sub openHTTPDIfNeeded()
     1350sub configureAndOpenHTTPDIfNeeded()
    13491351{
    13501352    return if $isHttpdOpen;
    1351 
    1352     mkdir "/tmp/WebKit";
    1353    
    1354     if (-f "/tmp/WebKit/httpd.pid") {
    1355         my $oldPid = `cat /tmp/WebKit/httpd.pid`;
    1356         chomp $oldPid;
    1357         if (0 != kill 0, $oldPid) {
    1358             print "\nhttpd is already running: pid $oldPid, killing...\n";
    1359             kill 15, $oldPid;
    1360            
    1361             my $retryCount = 20;
    1362             while ((0 != kill 0, $oldPid) && $retryCount) {
    1363                 sleep 1;
    1364                 --$retryCount;
    1365             }
    1366            
    1367             die "Timed out waiting for httpd to quit" unless $retryCount;
    1368         }
    1369     }
    1370    
    1371     my $httpdPath = "/usr/sbin/httpd";
    1372     my $httpdConfig;
    1373     if (isCygwin()) {
    1374         my $windowsConfDirectory = "$testDirectory/http/conf/";
    1375         unless (-x "/usr/lib/apache/libphp4.dll") {
    1376             copy("$windowsConfDirectory/libphp4.dll", "/usr/lib/apache/libphp4.dll");
    1377             chmod(0755, "/usr/lib/apache/libphp4.dll");
    1378         }
    1379         $httpdConfig = "$windowsConfDirectory/cygwin-httpd.conf";
    1380     } elsif (isDebianBased()) {
    1381         $httpdPath = "/usr/sbin/apache2";
    1382         $httpdConfig = "$testDirectory/http/conf/apache2-debian-httpd.conf";
    1383     } elsif (isFedoraBased()) {
    1384         $httpdPath = "/usr/sbin/httpd";
    1385         $httpdConfig = "$testDirectory/http/conf/fedora-httpd.conf";
    1386     } else {
    1387         $httpdConfig = "$testDirectory/http/conf/httpd.conf";
    1388         $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
    1389     }
    1390     my $documentRoot = "$testDirectory/http/tests";
    1391     my $jsTestResourcesDirectory = $testDirectory . "/fast/js/resources";
    1392     my $typesConfig = "$testDirectory/http/conf/mime.types";
     1353    my $absTestResultsDirectory = resolveAndMakeTestResultsDirectory();
    13931354    my $listen = "127.0.0.1:$httpdPort";
    1394     my $absTestResultsDirectory = resolveAndMakeTestResultsDirectory();
    1395     my $sslCertificate = "$testDirectory/http/conf/webkit-httpd.pem";
    1396 
    13971355    my @args = (
    1398         "-f", "$httpdConfig",
    1399         "-C", "DocumentRoot \"$documentRoot\"",
    1400         # Setup a link to where the js test templates are stored, use -c so that mod_alias will already be laoded.
    1401         "-c", "Alias /js-test-resources \"$jsTestResourcesDirectory\"",
    1402         "-C", "Listen $listen",
    1403         "-c", "TypesConfig \"$typesConfig\"",
    14041356        "-c", "CustomLog \"$absTestResultsDirectory/access_log.txt\" common",
    14051357        "-c", "ErrorLog \"$absTestResultsDirectory/error_log.txt\"",
    1406         # Apache wouldn't run CGIs with permissions==700 otherwise
    1407         "-c", "User \"#$<\""
     1358        "-C", "Listen $listen"
    14081359    );
    14091360
    1410     # FIXME: Enable this on Windows once <rdar://problem/5345985> is fixed
    1411     # The version of Apache we use with Cygwin does not support SSL
    1412     push(@args, "-c", "SSLCertificateFile \"$sslCertificate\"") unless isCygwin();
    1413 
    1414     open2(\*HTTPDIN, \*HTTPDOUT, $httpdPath, @args);
    1415 
    1416     my $retryCount = 20;
    1417     while (system("/usr/bin/curl -q --silent --stderr - --output " . File::Spec->devnull() . " $listen") && $retryCount) {
    1418         sleep 1;
    1419         --$retryCount;
    1420     }
    1421    
    1422     die "Timed out waiting for httpd to start" unless $retryCount;
    1423    
    1424     $isHttpdOpen = 1;
    1425 }
    1426 
    1427 sub closeHTTPD()
    1428 {
    1429     return if !$isHttpdOpen;
    1430 
    1431     close HTTPDIN;
    1432     close HTTPDOUT;
    1433 
    1434     kill 15, `cat /tmp/WebKit/httpd.pid` if -f "/tmp/WebKit/httpd.pid";
    1435 
    1436     $isHttpdOpen = 0;
     1361    my @defaultArgs = getDefaultConfigForTestDirectory($testDirectory);
     1362    @args = (@defaultArgs, @args);
     1363
     1364    $isHttpdOpen = openHTTPD(@args);
    14371365}
    14381366
Note: See TracChangeset for help on using the changeset viewer.