1#!/usr/bin/perl 2 3# Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. 4# Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 5# Copyright (C) 2011 Research In Motion Limited. All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 11# 1. Redistributions of source code must retain the above copyright 12# notice, this list of conditions and the following disclaimer. 13# 2. Redistributions in binary form must reproduce the above copyright 14# notice, this list of conditions and the following disclaimer in the 15# documentation and/or other materials provided with the distribution. 16# 3. Neither the name of Apple Inc. ("Apple") nor the names of 17# its contributors may be used to endorse or promote products derived 18# from this software without specific prior written permission. 19# 20# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 21# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 24# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 31# Script to run Apache with the same configuration as used in http layout tests. 32 33use strict; 34use warnings; 35 36use Cwd; 37use File::Path; 38use File::Basename; 39use Getopt::Long; 40use FindBin; 41 42use lib $FindBin::Bin; 43use webkitperl::httpd; 44use webkitdirs; 45 46# FIXME: Dynamic HTTP-port configuration in this file is wrong. The various 47# apache config files in LayoutTests/http/config govern the port numbers. 48# Dynamic configuration as-written will also cause random failures in 49# an IPv6 environment. See https://bugs.webkit.org/show_bug.cgi?id=37104. 50# Argument handling 51my $httpdPort = 8000; 52my $allInterfaces = 0; 53my $showHelp; 54 55my $result = GetOptions( 56 'all-interfaces|a' => \$allInterfaces, 57 'help|h' => \$showHelp, 58 'port=i' => \$httpdPort, 59); 60 61if (!$result || @ARGV || $showHelp) { 62 print "Usage: " . basename($0) . " [options]\n"; 63 print " -a|--all-interfaces Bind to all interfaces\n"; 64 print " -h|--help Show this help message\n"; 65 print " -p|--port NNNN Bind to port NNNN\n"; 66 exit 1; 67} 68 69setConfiguration(); 70my $productDir = productDir(); 71chdirWebKit(); 72my $testDirectory = File::Spec->catfile(getcwd(), "LayoutTests"); 73$testDirectory = convertMsysPath($testDirectory) if isMsys(); 74my $listen = "127.0.0.1:$httpdPort"; 75$listen = "$httpdPort" if ($allInterfaces); 76 77if ($allInterfaces) { 78 print "Starting httpd on port $httpdPort (all interfaces)...\n"; 79} else { 80 print "Starting httpd on <http://$listen/>...\n"; 81} 82setShouldWaitForUserInterrupt(); 83print "Press Ctrl+C to stop it.\n\n"; 84 85my @args = ( 86 "-C", "Listen $listen", 87 # Disable Keep-Alive support. Makes testing in multiple browsers easier (no need to wait 88 # for another browser's connection to expire). 89 "-c", "KeepAlive 0" 90); 91push @args, ( 92 "-c", "CustomLog |/usr/bin/tee common", 93 "-c", "ErrorLog |/usr/bin/tee", 94 # Run in single-process mode, do not detach from the controlling terminal. 95 "-X", 96) unless isMsys(); 97 98my @defaultArgs = getDefaultConfigForTestDirectory($testDirectory); 99@args = (@defaultArgs, @args); 100openHTTPD(@args); 101