Changeset 110059 in webkit


Ignore:
Timestamp:
Mar 7, 2012 8:58:25 AM (12 years ago)
Author:
Philippe Normand
Message:

[GTK] race condition in run-gtk-tests
https://bugs.webkit.org/show_bug.cgi?id=80495

Reviewed by Martin Robinson.

Refactored the script to wait the a11y dbus service becomes
available before starting the tests.

  • Scripts/run-gtk-tests:

(TestRunner._lookup_atspi2_binary):
(TestRunner):
(TestRunner._wait_dbus_service_and_run):
(TestRunner._wait_dbus_service_and_run.on_name_appeared):
(TestRunner._wait_dbus_service_and_run.on_name_vanished):
(TestRunner.run):
(TestRunner.run.bailout):
(TestRunner.run.run_for_real):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r110058 r110059  
     12012-03-07  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GTK] race condition in run-gtk-tests
     4        https://bugs.webkit.org/show_bug.cgi?id=80495
     5
     6        Reviewed by Martin Robinson.
     7
     8        Refactored the script to wait the a11y dbus service becomes
     9        available before starting the tests.
     10
     11        * Scripts/run-gtk-tests:
     12        (TestRunner._lookup_atspi2_binary):
     13        (TestRunner):
     14        (TestRunner._wait_dbus_service_and_run):
     15        (TestRunner._wait_dbus_service_and_run.on_name_appeared):
     16        (TestRunner._wait_dbus_service_and_run.on_name_vanished):
     17        (TestRunner.run):
     18        (TestRunner.run.bailout):
     19        (TestRunner.run.run_for_real):
     20
    1212012-03-07  Dinu Jacob  <dinu.jacob@nokia.com>
    222
  • trunk/Tools/Scripts/run-gtk-tests

    r109722 r110059  
    2020from webkitpy.common.system.executive import Executive
    2121import subprocess
    22 import os, sys
     22import os
     23import sys
     24import time
     25from gi.repository import Gio, GLib
     26
     27TIMEOUT=180 # seconds
    2328
    2429class TestRunner:
     
    4954            build_directory = os.path.join(top_level, 'WebKitBuild', 'Debug')
    5055
     56        self._a11y_registryd = None
     57        self._timed_out = False
    5158        self._gtk_tools_directory = os.path.join(top_level, "Tools", "gtk")
    5259        self._programs_path = os.path.join(build_directory, "Programs")
     
    7380        paths_to_check = [ 'libexec',
    7481                           'lib/at-spi2-core',
    75                            'lib32/at-spi2-core'
     82                           'lib32/at-spi2-core',
    7683                           'lib64/at-spi2-core' ]
    7784        for path in paths_to_check:
     
    8188
    8289        return None
     90
     91    def _run_command_when_dbus_service_appears(self, service_name, handler):
     92        def on_name_appeared(*args):
     93            handler()
     94
     95        def on_name_vanished(*args):
     96            pass
     97
     98        Gio.bus_watch_name(Gio.BusType.SESSION, service_name,
     99                           Gio.BusNameWatcherFlags.NONE, on_name_appeared, on_name_vanished)
     100
     101
     102    def _check_if_tests_have_timed_out(self):
     103        if time.time() - self._start_time <= TIMEOUT:
     104            return False
     105        sys.stdout.write("Tests timed out after %d seconds\n" % TIMEOUT)
     106        sys.stdout.flush()
     107        self._timed_out = True
     108        return True
     109
     110    def _ensure_accessibility_daemon_is_running(self, jhbuild_path):
     111        a11y_registryd_path = self._lookup_atspi2_binary(jhbuild_path, 'at-spi2-registryd')
     112        if a11y_registryd_path:
     113            try:
     114                self._a11y_registryd = Executive().popen([a11y_registryd_path], env=test_env)
     115            except:
     116                sys.stderr.write("Failed to run the accessibility registry\n")
     117                sys.stderr.flush()
     118                self._a11y_registryd = None
    83119
    84120    def run(self):
     
    93129        test_env['GSETTINGS_BACKEND'] = 'memory'
    94130
    95         exit_status = [0]
     131        failed_tests = []
    96132        def _error_handler(error):
    97             exit_status[0] = error.exit_code
     133            failed_tests.append(error.script_args[2])
    98134
    99135        jhbuild_path = os.path.join(self._gtk_tools_directory, "run-with-jhbuild")
    100136
    101137        # Make sure the accessibility bus is launched.
    102         a11y_bus_launched = False
    103138        a11y_bus_launcher_path = self._lookup_atspi2_binary(jhbuild_path, 'at-spi-bus-launcher')
    104         if a11y_bus_launcher_path:
    105             try:
    106                 a11y_bus_launcher = Executive().popen([a11y_bus_launcher_path], env=test_env)
    107                 a11y_bus_launched = True
    108             except:
    109                 sys.stderr.write("Failed to launch the accessibility bus\n")
    110                 sys.stderr.flush()
     139        assert(a11y_bus_launcher_path)
     140        try:
     141            a11y_bus_launcher = Executive().popen([a11y_bus_launcher_path], env=test_env)
     142        except:
     143            sys.stderr.write("Failed to launch the accessibility bus\n")
     144            sys.stderr.flush()
     145            return 1
    111146
    112         # Make sure the accessibility registry daemon is running.
    113         a11y_registryd_running = False
    114         a11y_registryd_path = self._lookup_atspi2_binary(jhbuild_path, 'at-spi2-registryd')
    115         if a11y_registryd_path:
    116             try:
    117                 a11y_registryd = Executive().popen([a11y_registryd_path], env=test_env)
    118                 a11y_registryd_running = True
    119             except:
    120                 sys.stderr.write("Failed to run the accessibility registry\n")
    121                 sys.stderr.flush()
     147        loop = GLib.MainLoop()
     148        self._start_time = time.time()
    122149
    123         for test in self._tests:
    124             out = self._executive.run_command([jhbuild_path ,'gtester', test], env=test_env,
    125                                               error_handler=_error_handler)
    126             sys.stdout.write(out)
    127             sys.stdout.flush()
     150        def run_tests():
     151            self._ensure_accessibility_daemon_is_running(jhbuild_path)
    128152
    129         if a11y_registryd_running:
    130             a11y_registryd.kill()
    131         if a11y_bus_launched:
    132             a11y_bus_launcher.kill()
     153            for test in self._tests:
     154                out = self._executive.run_command([jhbuild_path ,'gtester', test], env=test_env,
     155                                                  error_handler=_error_handler)
     156                sys.stdout.write(out)
     157                sys.stdout.flush()
    133158
    134         if exit_status[0]:
    135             sys.stdout.write("Tests failed\n")
    136             sys.stdout.flush()
     159                if self._check_if_tests_have_timed_out():
     160                    break
    137161
    138         return exit_status[0]
     162            if self._a11y_registryd:
     163                self._a11y_registryd.terminate()
     164
     165            a11y_bus_launcher.terminate()
     166
     167            if failed_tests:
     168                names = [os.path.basename(t) for t in failed_tests]
     169                sys.stdout.write("Tests failed: %s\n" % ", ".join(names))
     170                sys.stdout.flush()
     171
     172            loop.quit()
     173
     174        self._run_command_when_dbus_service_appears("org.a11y.Bus", run_tests)
     175        loop.run()
     176
     177        return len(failed_tests) or int(self._timed_out)
    139178
    140179if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.