Changeset 90810 in webkit


Ignore:
Timestamp:
Jul 12, 2011 1:08:28 AM (13 years ago)
Author:
eric@webkit.org
Message:

[Qt] NRWT should pick up the right httpd config file
https://bugs.webkit.org/show_bug.cgi?id=64086

Reviewed by Adam Barth.

Tools:

This is more fall-out from the Port class inappropriately encapsulating
both platform and port knowledge. We need to split out some of this
platform knowledge into a separate class which can be better shared
between ports.

The fix was to move all the _path_to_apache_config_file logic down
into the WebKitPort baseclass so that all of the ports can find the
right apache config file, regardless of what platform they may be running on.

I did not move this down into base.Port (even though I considered it).
Chromium duplicates some of this logic, but since they have separate
subclasses for each port-OS combination (e.g. ChromiumMac, ChromiumWin)
they wouldn't notice the change. Eventually we'll move this logic
out of Port entirely, and then it will be shared by all ports.

I also cleaned up the http-config logic for ORWT while I was there,
although since we're killing that code, I'm happy to revert that part
of the change if changing it is viewed as needlessly risky.

During this cleanup, I noticed that no ports use the "default" httpd.conf
which is left over from Mac OS X Tiger (and old linux distros) which used
Apache 1.3. I've removed httpd.conf (and associated support in ORWT) since
we no longer support any ports which use this httpd.conf.

  • Scripts/webkitperl/httpd.pm:

(getHTTPDConfigPathForTestDirectory):

  • Scripts/webkitpy/layout_tests/port/base.py:
  • Scripts/webkitpy/layout_tests/port/gtk.py:
  • Scripts/webkitpy/layout_tests/port/mac.py:
  • Scripts/webkitpy/layout_tests/port/qt.py:
  • Scripts/webkitpy/layout_tests/port/webkit.py:
  • Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
  • Scripts/webkitpy/layout_tests/port/win.py:
  • Scripts/webkitpy/layout_tests/servers/apache_http_server.py:

LayoutTests:

Removed this old httpd.conf file (used by Tiger and old linux distros)
since no supported WebKit ports use it anymore.

  • http/conf/httpd.conf: Removed.
Location:
trunk
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r90806 r90810  
     12011-07-12  Eric Seidel  <eric@webkit.org>
     2
     3        [Qt] NRWT should pick up the right httpd config file
     4        https://bugs.webkit.org/show_bug.cgi?id=64086
     5
     6        Reviewed by Adam Barth.
     7
     8        Removed this old httpd.conf file (used by Tiger and old linux distros)
     9        since no supported WebKit ports use it anymore.
     10
     11        * http/conf/httpd.conf: Removed.
     12
    1132011-07-11  Hironori Bono  <hbono@chromium.org>
    214
  • trunk/Tools/ChangeLog

    r90806 r90810  
     12011-07-12  Eric Seidel  <eric@webkit.org>
     2
     3        [Qt] NRWT should pick up the right httpd config file
     4        https://bugs.webkit.org/show_bug.cgi?id=64086
     5
     6        Reviewed by Adam Barth.
     7
     8        This is more fall-out from the Port class inappropriately encapsulating
     9        both platform and port knowledge.  We need to split out some of this
     10        platform knowledge into a separate class which can be better shared
     11        between ports.
     12
     13        The fix was to move all the _path_to_apache_config_file logic down
     14        into the WebKitPort baseclass so that all of the ports can find the
     15        right apache config file, regardless of what platform they may be running on.
     16
     17        I did not move this down into base.Port (even though I considered it).
     18        Chromium duplicates some of this logic, but since they have separate
     19        subclasses for each port-OS combination (e.g. ChromiumMac, ChromiumWin)
     20        they wouldn't notice the change.  Eventually we'll move this logic
     21        out of Port entirely, and then it will be shared by all ports.
     22
     23        I also cleaned up the http-config logic for ORWT while I was there,
     24        although since we're killing that code, I'm happy to revert that part
     25        of the change if changing it is viewed as needlessly risky.
     26
     27        During this cleanup, I noticed that no ports use the "default" httpd.conf
     28        which is left over from Mac OS X Tiger (and old linux distros) which used
     29        Apache 1.3.  I've removed httpd.conf (and associated support in ORWT) since
     30        we no longer support any ports which use this httpd.conf.
     31
     32        * Scripts/webkitperl/httpd.pm:
     33        (getHTTPDConfigPathForTestDirectory):
     34        * Scripts/webkitpy/layout_tests/port/base.py:
     35        * Scripts/webkitpy/layout_tests/port/gtk.py:
     36        * Scripts/webkitpy/layout_tests/port/mac.py:
     37        * Scripts/webkitpy/layout_tests/port/qt.py:
     38        * Scripts/webkitpy/layout_tests/port/webkit.py:
     39        * Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
     40        * Scripts/webkitpy/layout_tests/port/win.py:
     41        * Scripts/webkitpy/layout_tests/servers/apache_http_server.py:
     42
    1432011-07-11  Hironori Bono  <hbono@chromium.org>
    244
  • trunk/Tools/Scripts/webkitperl/httpd.pm

    r88012 r90810  
    137137    my ($testDirectory) = @_;
    138138    die "No test directory has been specified." unless ($testDirectory);
     139
    139140    my $httpdConfig;
    140141    my $httpdPath = getHTTPDPath();
     142    my $httpdConfDirectory = "$testDirectory/http/conf/";
     143
    141144    if (isCygwin()) {
    142         my $windowsConfDirectory = "$testDirectory/http/conf/";
    143         unless (-x "/usr/lib/apache/libphp4.dll") {
    144             copy("$windowsConfDirectory/libphp4.dll", "/usr/lib/apache/libphp4.dll");
    145             chmod(0755, "/usr/lib/apache/libphp4.dll");
     145        my $libPHP4DllPath = "/usr/lib/apache/libphp4.dll";
     146        # FIXME: run-webkit-tests should not modify the user's system, especially not in this method!
     147        unless (-x $libPHP4DllPath) {
     148            copy("$httpdConfDirectory/libphp4.dll", $libPHP4DllPath);
     149            chmod(0755, $libPHP4DllPath);
    146150        }
    147         $httpdConfig = "$windowsConfDirectory/cygwin-httpd.conf";
     151        $httpdConfig = "cygwin-httpd.conf";  # This is an apache 1.3 config.
    148152    } elsif (isMsys()) {
    149         $httpdConfig = "$testDirectory/http/conf/apache2-msys-httpd.conf";
     153        $httpdConfig = "apache2-msys-httpd.conf";
    150154    } elsif (isDebianBased()) {
    151         $httpdConfig = "$testDirectory/http/conf/apache2-debian-httpd.conf";
     155        $httpdConfig = "apache2-debian-httpd.conf";
    152156    } elsif (isFedoraBased()) {
    153         $httpdConfig = "$testDirectory/http/conf/fedora-httpd.conf";
     157        $httpdConfig = "fedora-httpd.conf"; # This is an apache2 config, despite the name.
    154158    } else {
    155         $httpdConfig = "$testDirectory/http/conf/httpd.conf";
    156         $httpdConfig = "$testDirectory/http/conf/apache2-httpd.conf" if `$httpdPath -v` =~ m|Apache/2|;
    157     }
    158     return $httpdConfig;
     159        # All other ports use apache2, so just use our default apache2 config.
     160        $httpdConfig = "apache2-httpd.conf";
     161    }
     162    return "$httpdConfDirectory/$httpdConfig";
    159163}
    160164
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py

    r90796 r90810  
    7474
    7575
    76 # FIXME: This class should merge with webkitpy.common.config.ports.
     76# FIXME: This class should merge with WebKitPort now that Chromium behaves mostly like other webkit ports.
    7777class Port(object):
    7878    """Abstract class for Port-specific hooks for the layout_test package."""
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py

    r90786 r90810  
    6868        environment['LIBOVERLAY_SCROLLBAR'] = '0'
    6969        environment['WEBKIT_INSPECTOR_PATH'] = self._build_path('Programs/resources/inspector')
    70 
    7170        return environment
    72 
    73     def _path_to_apache_config_file(self):
    74         # FIXME: This needs to detect the distribution and change config files.
    75         return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'apache2-debian-httpd.conf')
    7671
    7772    def _path_to_driver(self):
     
    9085            return '/usr/sbin/apache2'
    9186
    92     def _path_to_apache_config_file(self):
    93         if self._is_redhat_based():
    94             config_name = 'fedora-httpd.conf'
    95         else:
    96             config_name = 'apache2-debian-httpd.conf'
    97 
    98         return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', config_name)
    99 
    10087    def _path_to_wdiff(self):
    10188        if self._is_redhat_based():
     
    10390        else:
    10491            return '/usr/bin/wdiff'
    105 
    106     def _is_redhat_based(self):
    107         return self._filesystem.exists(self._filesystem.join('/etc', 'redhat-release'))
    10892
    10993    def _path_to_webcore_library(self):
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py

    r90697 r90810  
    114114        return self._build_java_test_support()
    115115
    116     def _path_to_apache_config_file(self):
    117         return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'apache2-httpd.conf')
    118 
    119116    def _path_to_webcore_library(self):
    120117        return self._build_path('WebCore.framework/Versions/A/WebCore')
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/qt.py

    r90543 r90810  
    6464        self._name = "-".join(name_components)
    6565
    66     def _path_to_apache_config_file(self):
    67         # FIXME: This needs to detect the distribution and change config files.
    68         return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'apache2-debian-httpd.conf')
    69 
    7066    def _build_driver(self):
    7167        # The Qt port builds DRT as part of the main build step
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py

    r90548 r90810  
    3737import os
    3838import re
     39import sys
    3940import time
    4041
     42from webkitpy.common.memoized import memoized
    4143from webkitpy.common.net.buildbot import BuildBot
    4244from webkitpy.common.system.executive import ScriptError
     
    5052    def __init__(self, **kwargs):
    5153        Port.__init__(self, **kwargs)
    52         self._cached_apache_path = None  # FIXME: This class should use @memoized instead.
    5354
    5455        # FIXME: Disable pixel tests until they are run by default on build.webkit.org.
     
    359360        return 'wdiff'
    360361
     362    # FIXME: This does not belong on the port object.
     363    @memoized
    361364    def _path_to_apache(self):
    362         if not self._cached_apache_path:
    363             # The Apache binary path can vary depending on OS and distribution
    364             # See http://wiki.apache.org/httpd/DistrosDefaultLayout
    365             for path in ["/usr/sbin/httpd", "/usr/sbin/apache2"]:
    366                 if self._filesystem.exists(path):
    367                     self._cached_apache_path = path
    368                     break
    369 
    370             if not self._cached_apache_path:
    371                 _log.error("Could not find apache. Not installed or unknown path.")
    372 
    373         return self._cached_apache_path
     365        # The Apache binary path can vary depending on OS and distribution
     366        # See http://wiki.apache.org/httpd/DistrosDefaultLayout
     367        for path in ["/usr/sbin/httpd", "/usr/sbin/apache2"]:
     368            if self._filesystem.exists(path):
     369                return path
     370            _log.error("Could not find apache. Not installed or unknown path.")
     371        return None
     372
     373    # FIXME: This belongs on some platform abstraction instead of Port.
     374    def _is_redhat_based(self):
     375        return self._filesystem.exists('/etc/redhat-release')
     376
     377    def _is_debian_based(self):
     378        return self._filesystem.exists('/etc/debian_version')
     379
     380    # We pass sys_platform into this method to make it easy to unit test.
     381    def _apache_config_file_name_for_platform(self, sys_platform):
     382        if sys_platform == 'cygwin':
     383            return 'cygwin-httpd.conf'  # CYGWIN is the only platform to still use Apache 1.3.
     384        if sys_platform.startswith('linux'):
     385            if self._is_redhat_based():
     386                return 'fedora-httpd.conf'  # This is an Apache 2.x config file despite the naming.
     387            if self._is_debian_based():
     388                return 'apache2-debian-httpd.conf'
     389        # All platforms use apache2 except for CYGWIN (and Mac OS X Tiger and prior, which we no longer support).
     390        return "apache2-httpd.conf"
     391
     392    def _path_to_apache_config_file(self):
     393        config_file_name = self._apache_config_file_name_for_platform(sys.platform)
     394        return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', config_file_name)
    374395
    375396
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py

    r90448 r90810  
    147147        expected_stderr = "MOCK run_command: ['Tools/Scripts/build-webkittestrunner', '--release']\n"
    148148        self.assertFalse(output.assert_outputs(self, port._build_driver, expected_stderr=expected_stderr))
     149
     150    def _assert_config_file_for_platform(self, port, platform, config_file):
     151        self.assertEquals(port._apache_config_file_name_for_platform(platform), config_file)
     152
     153    def test_linux_distro_detection(self):
     154        port = TestWebKitPort()
     155        self.assertFalse(port._is_redhat_based())
     156        self.assertFalse(port._is_debian_based())
     157
     158        port._filesystem = MockFileSystem({'/etc/redhat-release': ''})
     159        self.assertTrue(port._is_redhat_based())
     160        self.assertFalse(port._is_debian_based())
     161
     162        port._filesystem = MockFileSystem({'/etc/debian_version': ''})
     163        self.assertFalse(port._is_redhat_based())
     164        self.assertTrue(port._is_debian_based())
     165
     166    def test_apache_config_file_name_for_platform(self):
     167        port = TestWebKitPort()
     168        self._assert_config_file_for_platform(port, 'cygwin', 'cygwin-httpd.conf')
     169
     170        self._assert_config_file_for_platform(port, 'linux2', 'apache2-httpd.conf')
     171        self._assert_config_file_for_platform(port, 'linux3', 'apache2-httpd.conf')
     172
     173        port._is_redhat_based = lambda: True
     174        self._assert_config_file_for_platform(port, 'linux2', 'fedora-httpd.conf')
     175
     176        port = TestWebKitPort()
     177        port._is_debian_based = lambda: True
     178        self._assert_config_file_for_platform(port, 'linux2', 'apache2-debian-httpd.conf')
     179
     180        self._assert_config_file_for_platform(port, 'mac', 'apache2-httpd.conf')
     181        self._assert_config_file_for_platform(port, 'win32', 'apache2-httpd.conf')  # win32 isn't a supported sys.platform.  AppleWin/WinCairo/WinCE ports all use cygwin.
     182        self._assert_config_file_for_platform(port, 'barf', 'apache2-httpd.conf')
     183
     184    def test_path_to_apache_config_file(self):
     185        port = TestWebKitPort()
     186        # Mock out _apache_config_file_name_for_platform to ignore the passed sys.platform value.
     187        port._apache_config_file_name_for_platform = lambda platform: 'httpd.conf'
     188        self.assertEquals(port._path_to_apache_config_file(), '/mock/LayoutTests/http/conf/httpd.conf')
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/win.py

    r90697 r90810  
    5858        return map(self._webkit_baseline_path, self.FALLBACK_PATHS[self._version])
    5959
    60     def _path_to_apache_config_file(self):
    61         return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'cygwin-httpd.conf')
     60    # FIXME: webkitperl/httpd.pm installs /usr/lib/apache/libphp4.dll on cycwin automatically
     61    # as part of running old-run-webkit-tests.  That's bad design, but we may need some similar hack.
     62    # We might use setup_environ_for_server for such a hack (or modify apache_http_server.py).
  • trunk/Tools/Scripts/webkitpy/layout_tests/servers/apache_http_server.py

    r90534 r90810  
    6363
    6464        test_dir = self._port_obj.layout_tests_dir()
    65         js_test_resources_dir = self._cygwin_safe_join(test_dir, "fast", "js",
    66             "resources")
     65        js_test_resources_dir = self._cygwin_safe_join(test_dir, "fast", "js", "resources")
    6766        media_resources_dir = self._cygwin_safe_join(test_dir, "media")
    68         mime_types_path = self._cygwin_safe_join(test_dir, "http", "conf",
    69             "mime.types")
    70         cert_file = self._cygwin_safe_join(test_dir, "http", "conf",
    71             "webkit-httpd.pem")
     67        mime_types_path = self._cygwin_safe_join(test_dir, "http", "conf", "mime.types")
     68        cert_file = self._cygwin_safe_join(test_dir, "http", "conf", "webkit-httpd.pem")
    7269        access_log = self._cygwin_safe_join(output_dir, "access_log.txt")
    7370        error_log = self._cygwin_safe_join(output_dir, "error_log.txt")
     
    10097
    10198        if self._is_cygwin():
    102             cygbin = self._port_obj._path_from_base('third_party', 'cygwin',
    103                 'bin')
     99            cygbin = self._port_obj._path_from_base('third_party', 'cygwin', 'bin')
    104100            # Not entirely sure why, but from cygwin we need to run the
    105101            # httpd command through bash.
     
    127123        return sys.platform in ("win32", "cygwin")
    128124
     125    # FIXME: This is the wrong place to have this method.  Perhaps this belongs in filesystem.py?
    129126    def _cygwin_safe_join(self, *parts):
    130         """Returns a platform appropriate path."""
    131127        path = os.path.join(*parts)
    132128        if self._is_cygwin():
     
    161157        httpd_config_copy = os.path.join(output_dir, "httpd.conf")
    162158        httpd_conf = self._filesystem.read_text_file(httpd_config)
     159        # FIXME: This only works for Chromium. Instead it should use some abstraction on the port object.
    163160        if self._is_cygwin():
    164161            # This is a gross hack, but it lets us use the upstream .conf file
     
    168165            # file. We have apache/cygwin checked into our tree so
    169166            # people don't have to install it into their cygwin.
    170             cygusr = self._port_obj._path_from_base('third_party', 'cygwin',
    171                 'usr')
    172             httpd_conf = httpd_conf.replace('ServerRoot "/usr"',
    173                 'ServerRoot "%s"' % self._get_cygwin_path(cygusr))
     167            cygusr = self._port_obj._path_from_base('third_party', 'cygwin', 'usr')
     168            httpd_conf = httpd_conf.replace('ServerRoot "/usr"', 'ServerRoot "%s"' % self._get_cygwin_path(cygusr))
    174169
    175170        self._filesystem.write_text_file(httpd_config_copy, httpd_conf)
Note: See TracChangeset for help on using the changeset viewer.