Changeset 229469 in webkit


Ignore:
Timestamp:
Mar 9, 2018, 10:48:46 AM (7 years ago)
Author:
commit-queue@webkit.org
Message:

[webkitpy, WinCairo] Launch Apache HTTPD for HTTP Tests.
https://bugs.webkit.org/show_bug.cgi?id=183265

Patch by Basuke Suzuki <Basuke Suzuki> on 2018-03-09
Reviewed by Daniel Bates.

Launch apache httpd server from python script for WinCairo HTTP LayoutTests. By now, AppleWin uses
Cygwin to launch httpd server. This patch enables native Windows to run HTTP LayoutTests by starting
and stopping httpd server from the script.

Tools:

  • Scripts/webkitpy/layout_tests/servers/apache_http_server.py:

(LayoutTestApacheHttpd.init):
(LayoutTestApacheHttpd._copy_apache_config_file):
(LayoutTestApacheHttpd):
(LayoutTestApacheHttpd.platform):
(LayoutTestApacheHttpd._spawn_process):
(LayoutTestApacheHttpd._stop_running_server):
(LayoutTestApacheHttpd._run):
(LayoutTestApacheHttpd._server_error):

  • Scripts/webkitpy/layout_tests/servers/http_server_base.py:

(HttpServerBase.aliases):
(HttpServerBase):
(HttpServerBase._build_alias_path_pairs):
(HttpServerBase._build_alias_path_pairs._make_path):

  • Scripts/webkitpy/layout_tests/servers/http_server_base_unittest.py:

(TestHttpServerBase.test_corrupt_pid_file):
(TestHttpServerBase):
(TestHttpServerBase.test_build_alias_path_pairs):

  • Scripts/webkitpy/port/base.py:

(Port._apache_config_file_name_for_platform):

  • Scripts/webkitpy/port/port_testcase.py:

(test_apache_config_file_name_for_platform):

  • Scripts/webkitpy/port/win.py:

(WinPort._path_to_apache):
(WinCairoPort.default_baseline_search_path):
(WinCairoPort):
(WinCairoPort.check_httpd):

LayoutTests:

  • http/conf/win-httpd-2.4-php7.conf: Added.

For WinCairo from native Windows environment.

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r229468 r229469  
     12018-03-09  Basuke Suzuki  <Basuke.Suzuki@sony.com>
     2
     3        [webkitpy, WinCairo] Launch Apache HTTPD for HTTP Tests.
     4        https://bugs.webkit.org/show_bug.cgi?id=183265
     5
     6        Reviewed by Daniel Bates.
     7
     8        Launch apache httpd server from python script for WinCairo HTTP LayoutTests. By now, AppleWin uses
     9        Cygwin to launch httpd server. This patch enables native Windows to run HTTP LayoutTests by starting
     10        and stopping httpd server from the script.
     11
     12        * http/conf/win-httpd-2.4-php7.conf: Added.
     13        For WinCairo from native Windows environment.
     14
    1152018-03-09  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/Tools/ChangeLog

    r229461 r229469  
     12018-03-09  Basuke Suzuki  <Basuke.Suzuki@sony.com>
     2
     3        [webkitpy, WinCairo] Launch Apache HTTPD for HTTP Tests.
     4        https://bugs.webkit.org/show_bug.cgi?id=183265
     5
     6        Reviewed by Daniel Bates.
     7
     8        Launch apache httpd server from python script for WinCairo HTTP LayoutTests. By now, AppleWin uses
     9        Cygwin to launch httpd server. This patch enables native Windows to run HTTP LayoutTests by starting
     10        and stopping httpd server from the script.
     11
     12        * Scripts/webkitpy/layout_tests/servers/apache_http_server.py:
     13        (LayoutTestApacheHttpd.__init__):
     14        (LayoutTestApacheHttpd._copy_apache_config_file):
     15        (LayoutTestApacheHttpd):
     16        (LayoutTestApacheHttpd.platform):
     17        (LayoutTestApacheHttpd._spawn_process):
     18        (LayoutTestApacheHttpd._stop_running_server):
     19        (LayoutTestApacheHttpd._run):
     20        (LayoutTestApacheHttpd._server_error):
     21        * Scripts/webkitpy/layout_tests/servers/http_server_base.py:
     22        (HttpServerBase.aliases):
     23        (HttpServerBase):
     24        (HttpServerBase._build_alias_path_pairs):
     25        (HttpServerBase._build_alias_path_pairs._make_path):
     26        * Scripts/webkitpy/layout_tests/servers/http_server_base_unittest.py:
     27        (TestHttpServerBase.test_corrupt_pid_file):
     28        (TestHttpServerBase):
     29        (TestHttpServerBase.test_build_alias_path_pairs):
     30        * Scripts/webkitpy/port/base.py:
     31        (Port._apache_config_file_name_for_platform):
     32        * Scripts/webkitpy/port/port_testcase.py:
     33        (test_apache_config_file_name_for_platform):
     34        * Scripts/webkitpy/port/win.py:
     35        (WinPort._path_to_apache):
     36        (WinCairoPort.default_baseline_search_path):
     37        (WinCairoPort):
     38        (WinCairoPort.check_httpd):
     39
    1402018-03-09  Carlos Garcia Campos  <cgarcia@igalia.com>
    241
  • trunk/Tools/Scripts/webkitpy/layout_tests/servers/apache_http_server.py

    r229141 r229469  
    102102            '-k', "start"]
    103103
    104         for alias in self.aliases():
    105             start_cmd.extend(['-c', 'Alias %s "%s"' % (alias[0], alias[1])])
     104        for (alias, path) in self.aliases():
     105            start_cmd.extend(['-c', 'Alias %s "%s"' % (alias, path)])
    106106
    107107        if not port_obj.host.platform.is_win():
     
    165165        self._filesystem.write_text_file(httpd_config_copy, httpd_conf)
    166166
    167         if self._port_obj.host.platform.is_cygwin():
     167        if self.platform.is_cygwin():
    168168            # Convert to MSDOS file naming:
    169169            precompiledDrive = re.compile('^/cygdrive/[cC]')
     
    174174        return httpd_config_copy
    175175
     176    @property
     177    def platform(self):
     178        return self._port_obj.host.platform
     179
    176180    def _spawn_process(self):
    177181        _log.debug('Starting %s server, cmd="%s"' % (self._name, str(self._start_cmd)))
    178182        retval, err = self._run(self._start_cmd)
    179183        if retval or len(err):
    180             raise http_server_base.ServerError('Failed to start %s: %s' % (self._name, err))
     184            raise self._server_error('Failed to start %s' % self._name, err, retval)
    181185
    182186        # For some reason apache isn't guaranteed to have created the pid file before
     
    190194        # If apache was forcefully killed, the pid file will not have been deleted, so check
    191195        # that the process specified by the pid_file no longer exists before deleting the file.
    192         if self._pid and not self._port_obj.host.platform.is_win() and not self._executive.check_running_pid(self._pid):
     196        if self._pid and not self.platform.is_win() and not self._executive.check_running_pid(self._pid):
    193197            self._filesystem.remove(self._pid_file)
    194198            return
     
    197201
    198202        # Windows httpd outputs shutdown status in stderr:
    199         if self._port_obj.host.platform.is_win() and not retval and len(err):
     203        if self.platform.is_win() and not retval and len(err):
    200204            _log.debug('Shutdown: %s' % err)
    201205            err = ""
    202206
    203207        if retval or len(err):
    204             raise http_server_base.ServerError('Failed to stop %s: %s' % (self._name, err))
     208            raise self._server_error('Failed to stop %s' % self._name, err, retval)
    205209
    206210        # For some reason apache isn't guaranteed to have actually stopped after
     
    208212        # pid file to be removed.
    209213        if not self._wait_for_action(lambda: not self._filesystem.exists(self._pid_file)):
    210             if self._port_obj.host.platform.is_win():
     214            if self.platform.is_win():
    211215                self._remove_pid_file()
    212216                return
     
    220224        err = process.stderr.read()
    221225        return (retval, err)
     226
     227    def _server_error(self, message, stderr_output, exit_code):
     228        if self.platform.is_win() and exit_code == 720005 and not stderr_output:
     229            stderr_output = 'Access is denied. Do you have administrator privilege?'
     230        return http_server_base.ServerError('{}: {} (exit code={})'.format(message, stderr_output, exit_code))
  • trunk/Tools/Scripts/webkitpy/layout_tests/servers/http_server_base.py

    r225733 r229469  
    165165
    166166    def aliases(self):
     167        """Return path pairs used to define aliases. First item is URL path and second
     168        one is actual location in the file system."""
    167169        json_data = self._filesystem.read_text_file(self._port_obj.path_from_webkit_base("Tools", "Scripts", "webkitpy", "layout_tests", "servers", "aliases.json"))
    168         results = []
    169         for item in json.loads(json_data):
    170             results.append([item[0], self._port_obj._filesystem.join(self.tests_dir, item[1])])
    171         return results
     170        return self._build_alias_path_pairs(json.loads(json_data))
     171
     172    def _build_alias_path_pairs(self, data):
     173        def _make_path(path):
     174            return self._filesystem.join(self.tests_dir, self._filesystem.normpath(path))
     175        return [(alias, _make_path(path)) for (alias, path) in data]
    172176
    173177    def _remove_pid_file(self):
  • trunk/Tools/Scripts/webkitpy/layout_tests/servers/http_server_base_unittest.py

    r174136 r229469  
    5757        # was actually a real implementation.
    5858        self.assertEqual(host.filesystem.files[server._pid_file], None)
     59
     60    def test_build_alias_path_pairs(self):
     61        host = MockHost()
     62        test_port = test.TestPort(host)
     63        server = HttpServerBase(test_port)
     64
     65        data = [
     66            ['/media-resources', 'media'],
     67            ['/modern-media-controls', '../Source/WebCore/Modules/modern-media-controls'],
     68            ['/resources/testharness.css', 'resources/testharness.css'],
     69        ]
     70
     71        expected = [
     72            ('/media-resources', '/test.checkout/LayoutTests/media'),
     73            ('/modern-media-controls', '/test.checkout/LayoutTests/../Source/WebCore/Modules/modern-media-controls'),
     74            ('/resources/testharness.css', '/test.checkout/LayoutTests/resources/testharness.css'),
     75        ]
     76
     77        self.assertEqual(server._build_alias_path_pairs(data), expected)
  • trunk/Tools/Scripts/webkitpy/port/base.py

    r229116 r229469  
    12511251    # We pass sys_platform into this method to make it easy to unit test.
    12521252    def _apache_config_file_name_for_platform(self, sys_platform):
    1253         if sys_platform == 'cygwin' or sys_platform.startswith('win'):
     1253        if sys_platform == 'cygwin':
    12541254            return 'apache' + self._apache_version() + '-httpd-win.conf'
     1255        if sys_platform == 'win32':
     1256            return 'win-httpd-' + self._apache_version() + '-php7.conf'
    12551257        if sys_platform == 'darwin':
    12561258            return 'apache' + self._apache_version() + self._darwin_php_version() + '-httpd.conf'
  • trunk/Tools/Scripts/webkitpy/port/port_testcase.py

    r229380 r229469  
    630630
    631631        self._assert_config_file_for_platform(port, 'mac', 'apache2.2-httpd.conf')
    632         self._assert_config_file_for_platform(port, 'win32', 'apache2.2-httpd-win.conf')  # win32 isn't a supported sys.platform.  AppleWin/WinCairo ports all use cygwin.
     632        self._assert_config_file_for_platform(port, 'win32', 'win-httpd-2.2-php7.conf')  # WinCairo uses win32. Only AppleWin port uses cygwin.
    633633        self._assert_config_file_for_platform(port, 'barf', 'apache2.2-httpd.conf')
    634634
  • trunk/Tools/Scripts/webkitpy/port/win.py

    r228480 r229469  
    185185
    186186    def _path_to_apache(self):
    187         httpdPath = os.path.join('C:', 'xampp', 'apache', 'bin', 'httpd.exe')
    188         if self._filesystem.exists(httpdPath):
    189             return httpdPath
    190         _log.error("Could not find apache. Not installed or unknown path.")
     187        root = os.environ.get('XAMPP_ROOT', 'C:\\xampp')
     188        path = self._filesystem.join(root, 'apache', 'bin', 'httpd.exe')
     189        if self._filesystem.exists(path):
     190            return path
     191        _log.error('Could not find apache in the expected location. (path=%s)' % path)
    191192        return None
    192193
     
    464465        fallback_names.append('wincairo')
    465466        return map(self._webkit_baseline_path, fallback_names)
     467
     468    def check_httpd(self):
     469        if not super(WinCairoPort, self).check_httpd():
     470            return False
     471
     472        path = self._path_to_apache()
     473        if not path:
     474            return False
     475
     476        # To launch Apache as a daemon, service installation is required.
     477        exit_code = self._executive.run_command([path, '-k', 'install', '-T'], return_exit_code=True)
     478        # 0=success, 2=already installed, 720005=permission error, etc.
     479        if exit_code == 0 or exit_code == 2:
     480            return True
     481        _log.error('Httpd cannot run as a service. Perhaps you forgot to log in as an adminstrator user? (exit code=%s)' % exit_code)
     482        return False
Note: See TracChangeset for help on using the changeset viewer.