run-webkit-httpd 3.6 KB

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