blob: 6b112bf25704198eeb41f2b9a6ac729e02702dc7 [file] [edit]
#!/usr/bin/env python3
#
# Copyright (C) 2011, 2012, 2017, 2021 Igalia S.L.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; see the file COPYING.LIB. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
import logging
import optparse
import os
import sys
from webkitpy.port.linux_container_sdk_utils import maybe_enter_webkit_container_sdk, maybe_use_container_sdk_root_dir
maybe_enter_webkit_container_sdk()
from webkitpy.results.options import upload_options
maybe_use_container_sdk_root_dir()
top_level_directory = os.path.normpath(os.path.join(os.path.dirname(__file__), "..", ".."))
sys.path.insert(0, os.path.join(top_level_directory, "Tools", "jhbuild"))
sys.path.insert(0, os.path.join(top_level_directory, "Tools", "glib"))
import common
from api_test_runner import TestRunner, check_environment, create_option_parser, get_runner_args
from gi.repository import Gio, GLib
class GtkTestRunner(TestRunner):
TestRunner.TEST_TARGETS = [ "WebKitGTK", "TestWebKit", "TestJSC", "TestWTF", "TestWebCore", "TestJavaScriptCore" ]
def __init__(self, options, tests=[]):
super(GtkTestRunner, self).__init__("gtk", options, tests)
def _ensure_accessibility_service_is_running(self):
# The a11y service is DBus activatable so we simply need to call it to ensure it
# has been started.
try:
proxy = Gio.DBusProxy.new_for_bus_sync(Gio.BusType.SESSION,
Gio.DBusProxyFlags.NONE,
None,
'org.a11y.Bus',
'/org/a11y/bus',
'org.a11y.Bus',
None)
# After this returns we know the bus is setup, the return value doesn't matter.
proxy.GetAddress()
except GLib.Error as e:
sys.stderr.write("Failed to talk to the accessibility service: {}\n".format(e.message))
sys.stderr.flush()
return False
return True
def _setup_testing_environment(self):
super(GtkTestRunner, self)._setup_testing_environment()
# If we cannot start the accessibility daemons, we can just skip the accessibility tests.
if not self._ensure_accessibility_service_is_running():
print("Could not start accessibility bus, so disabling TestWebKitAccessibility")
self._disabled_tests.append("WebKitGTK/TestWebKitAccessibility")
def _tear_down_testing_environment(self):
super(GtkTestRunner, self)._tear_down_testing_environment()
def is_glib_test(self, test_program):
return os.path.basename(os.path.dirname(test_program)) in ["WebKitGTK"] or os.path.basename(test_program) in ["TestJSC"]
def is_google_test(self, test_program):
return os.path.basename(test_program) in ["TestWebKit", "TestWTF", "TestWebCore", "TestJavaScriptCore"]
def is_qt_test(self, test_program):
return False
def is_wpe_platform_test(self, test_program):
return False
def is_wpe_platform_wayland_test(self, test_program):
return False
if __name__ == "__main__":
runner_args = get_runner_args(sys.argv)
check_environment("gtk")
option_group_definitions = []
option_group_definitions.append(('Upload Options', upload_options()))
option_parser = create_option_parser()
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.'),
for group_name, group_options in option_group_definitions:
option_group = optparse.OptionGroup(option_parser, group_name)
option_group.add_options(group_options)
option_parser.add_option_group(option_group)
options, args = option_parser.parse_args()
logging.basicConfig(level=logging.INFO, format="%(message)s")
runner = GtkTestRunner(options, args)
sys.exit(runner.run_tests())