[GTK][Wayland] Allow running the layout tests under a native Wayland environment.
authorclopez@igalia.com <clopez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Jan 2017 22:28:43 +0000 (22:28 +0000)
committerclopez@igalia.com <clopez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Jan 2017 22:28:43 +0000 (22:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165232

Reviewed by Michael Catanzaro.

Add a new WaylandDriver to run the tests in the user current wayland session.

Also merge all the configuration options for selecting the display server inside one
switch --display-server=xvfb/xorg/wayland/weston (defaulting to xvfb).

This switch is supported on the scripts: run-gtk-tests, run-perf-tests and run-webkit-tests.

* Scripts/run-gtk-tests: Add missing logging.basicConfig() initialization for the error logger.
(TestRunner._create_driver):
* Scripts/webkitpy/layout_tests/run_webkit_tests.py:
(parse_args):
* Scripts/webkitpy/performance_tests/perftestsrunner.py:
(PerfTestsRunner._parse_args):
* Scripts/webkitpy/port/gtk.py:
(GtkPort.__init__):
(GtkPort._driver_class):
(GtkPort._search_paths):
* Scripts/webkitpy/port/waylanddriver.py: Added.
(WaylandDriver):
(WaylandDriver.check_driver):
(WaylandDriver._setup_environ_for_test):
(WaylandDriver._start):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210523 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/run-gtk-tests
Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py
Tools/Scripts/webkitpy/port/gtk.py
Tools/Scripts/webkitpy/port/waylanddriver.py [new file with mode: 0644]

index 0fd173f..c571183 100644 (file)
@@ -1,3 +1,33 @@
+2017-01-09  Carlos Alberto Lopez Perez  <clopez@igalia.com>
+
+        [GTK][Wayland] Allow running the layout tests under a native Wayland environment.
+        https://bugs.webkit.org/show_bug.cgi?id=165232
+
+        Reviewed by Michael Catanzaro.
+
+        Add a new WaylandDriver to run the tests in the user current wayland session.
+
+        Also merge all the configuration options for selecting the display server inside one
+        switch --display-server=xvfb/xorg/wayland/weston (defaulting to xvfb).
+
+        This switch is supported on the scripts: run-gtk-tests, run-perf-tests and run-webkit-tests.
+
+        * Scripts/run-gtk-tests: Add missing logging.basicConfig() initialization for the error logger.
+        (TestRunner._create_driver):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+        (parse_args):
+        * Scripts/webkitpy/performance_tests/perftestsrunner.py:
+        (PerfTestsRunner._parse_args):
+        * Scripts/webkitpy/port/gtk.py:
+        (GtkPort.__init__):
+        (GtkPort._driver_class):
+        (GtkPort._search_paths):
+        * Scripts/webkitpy/port/waylanddriver.py: Added.
+        (WaylandDriver):
+        (WaylandDriver.check_driver):
+        (WaylandDriver._setup_environ_for_test):
+        (WaylandDriver._start):
+
 2017-01-09  Andy Estes  <aestes@apple.com>
 
         [QuickLook] Add a layout test for webkit.org/b/135651
index 9579b7f..d83625e 100755 (executable)
@@ -17,6 +17,7 @@
 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 # Boston, MA 02110-1301, USA.
 
+import logging
 import subprocess
 import os
 import sys
@@ -209,10 +210,7 @@ class TestRunner:
         return True
 
     def _create_driver(self, port_options=[]):
-        if self._options.use_wayland:
-            self._port._wayland = True
-        else:
-            self._port._nativexorg = not self._options.use_xvfb
+        self._port._display_server = self._options.display_server
         driver = self._port.create_driver(worker_number=0, no_timeout=True)._make_driver(pixel_tests=False)
         if not driver.check_driver(self._port):
             raise RuntimeError("Failed to check driver %s" %driver.__class__.__name__)
@@ -486,11 +484,12 @@ if __name__ == "__main__":
     option_parser.add_option('-t', '--timeout',
                              action='store', type='int', dest='timeout', default=10,
                              help='Time in seconds until a test times out')
-    option_parser.add_option('--no-xvfb', action='store_false', dest='use_xvfb', default=True,
-                             help='Do not run tests under Xvfb')
-    option_parser.add_option('--wayland', action='store_true', dest='use_wayland', default=False,
-                             help='Run the layout tests inside a (virtualized) weston')
+    option_parser.add_option('--display-server', choices=['xvfb', 'xorg', 'weston', 'wayland'], default='xvfb',
+                             help='"xvfb": Use a virtualized X11 server. "xorg": Use the current X11 session. '
+                                  '"weston": Use a virtualized Weston server. "wayland": Use the current wayland session.'),
     options, args = option_parser.parse_args()
 
+    logging.basicConfig(level=logging.INFO, format="%(message)s")
+
     runner = TestRunner(options, args)
     sys.exit(runner.run_tests())
index 7173809..7c6ddc8 100755 (executable)
@@ -289,8 +289,9 @@ def parse_args(args):
         optparse.make_option("--profiler", action="store",
             help="Output per-test profile information, using the specified profiler."),
         optparse.make_option("--no-timeout", action="store_true", default=False, help="Disable test timeouts"),
-        optparse.make_option("--wayland",  action="store_true", default=False,
-            help="Run the layout tests inside a (virtualized) weston compositor (GTK only)."),
+        optparse.make_option('--display-server', choices=['xvfb', 'xorg', 'weston', 'wayland'], default='xvfb',
+            help='"xvfb": Use a virtualized X11 server. "xorg": Use the current X11 session. '
+                 '"weston": Use a virtualized Weston server. "wayland": Use the current wayland session.'),
     ]))
 
     option_group_definitions.append(("iOS Simulator Options", [
index 325f65a..e003420 100644 (file)
@@ -135,6 +135,9 @@ class PerfTestsRunner(object):
                 help="wrapper command to insert before invocations of "
                  "DumpRenderTree or WebKitTestRunner; option is split on whitespace before "
                  "running. (Example: --wrapper='valgrind --smc-check=all')"),
+            optparse.make_option('--display-server', choices=['xvfb', 'xorg', 'weston', 'wayland'], default='xvfb',
+                help='"xvfb": Use a virtualized X11 server. "xorg": Use the current X11 session. '
+                     '"weston": Use a virtualized Weston server. "wayland": Use the current wayland session.'),
             ]
         return optparse.OptionParser(option_list=(perf_option_list)).parse_args(args)
 
index 7b24152..c1b05c8 100644 (file)
@@ -1,5 +1,6 @@
 # Copyright (C) 2010 Google Inc. All rights reserved.
 # Copyright (C) 2013 Samsung Electronics.  All rights reserved.
+# Copyright (C) 2017 Igalia S.L. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
@@ -40,6 +41,7 @@ from webkitpy.port.pulseaudio_sanitizer import PulseAudioSanitizer
 from webkitpy.port.xvfbdriver import XvfbDriver
 from webkitpy.port.westondriver import WestonDriver
 from webkitpy.port.xorgdriver import XorgDriver
+from webkitpy.port.waylanddriver import WaylandDriver
 from webkitpy.port.linux_get_crash_log import GDBCrashLogGenerator
 from webkitpy.port.leakdetector_valgrind import LeakDetectorValgrind
 
@@ -52,10 +54,7 @@ class GtkPort(Port):
     def __init__(self, *args, **kwargs):
         super(GtkPort, self).__init__(*args, **kwargs)
         self._pulseaudio_sanitizer = PulseAudioSanitizer()
-        self._wayland = self.get_option("wayland")
-        self._nativexorg = False
-        if os.environ.get("USE_NATIVE_XDISPLAY"):
-            self._nativexorg = True
+        self._display_server = self.get_option("display_server")
 
         if self.get_option("leaks"):
             self._leakdetector = LeakDetectorValgrind(self._executive, self._filesystem, self.results_directory())
@@ -80,9 +79,12 @@ class GtkPort(Port):
 
     @memoized
     def _driver_class(self):
-        if self._wayland:
+        if self._display_server == "weston":
             return WestonDriver
-        if self._nativexorg:
+        if self._display_server == "wayland":
+            return WaylandDriver
+        # FIXME: re-configure the perf bot to pass --display-server=xorg
+        if self._display_server == "xorg" or os.environ.get("USE_NATIVE_XDISPLAY"):
             return XorgDriver
         return XvfbDriver
 
@@ -190,7 +192,7 @@ class GtkPort(Port):
 
     def _search_paths(self):
         search_paths = []
-        if self._wayland:
+        if self._driver_class() in [WaylandDriver, WestonDriver]:
             search_paths.append(self.port_name + "-wayland")
         search_paths.append(self.port_name)
         search_paths.append('wk2')
diff --git a/Tools/Scripts/webkitpy/port/waylanddriver.py b/Tools/Scripts/webkitpy/port/waylanddriver.py
new file mode 100644 (file)
index 0000000..b822d01
--- /dev/null
@@ -0,0 +1,64 @@
+# Copyright (C) 2016 Igalia S.L. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#
+#     * Neither the name of the copyright holder nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import logging
+import os
+
+from webkitpy.port.driver import Driver
+
+_log = logging.getLogger(__name__)
+
+
+class WaylandDriver(Driver):
+    @staticmethod
+    def check_driver(port):
+        if "WAYLAND_DISPLAY" not in os.environ:
+                _log.error("WAYLAND_DISPLAY not found in the environment. Cannot run tests.")
+                return False
+        return True
+
+    def _setup_environ_for_test(self):
+        driver_environment = self._port.setup_environ_for_server(self._server_name)
+        driver_environment['WAYLAND_DISPLAY'] = os.environ.get('WAYLAND_DISPLAY')
+        driver_environment['GDK_BACKEND'] = 'wayland'
+        if driver_environment.get('DISPLAY'):
+            del driver_environment['DISPLAY']
+        driver_environment['LOCAL_RESOURCE_ROOT'] = self._port.layout_tests_dir()
+        driver_environment['DUMPRENDERTREE_TEMP'] = str(self._driver_tempdir)
+        driver_environment['XDG_CACHE_HOME'] = self._port.host.filesystem.join(str(self._driver_tempdir), 'appcache')
+        return driver_environment
+
+    def _start(self, pixel_tests, per_test_args):
+        super(WaylandDriver, self).stop()
+        self._driver_tempdir = self._port.host.filesystem.mkdtemp(prefix='%s-' % self._server_name)
+        self._crashed_process_name = None
+        self._crashed_pid = None
+        self._server_process = self._port._server_process_constructor(self._port, self._server_name, self.cmd_line(pixel_tests, per_test_args), self._setup_environ_for_test())
+        self._server_process.start()