[GTK] Test runner crashes without recent versions of pulseaudio-utils
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Apr 2012 13:33:24 +0000 (13:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Apr 2012 13:33:24 +0000 (13:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83774

Patch by Simon Pena <spena@igalia.com> on 2012-04-12
Reviewed by Philippe Normand.

Besides checking that pactl is available, check also that its output
is the expected one, and handle gracefully when it isn't, when
trying to unload pulseaudio modules.

* Scripts/webkitpy/layout_tests/port/gtk.py:
(GtkPort._unload_pulseaudio_module):
(GtkPort._restore_pulseaudio_module):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/port/gtk.py

index 4f7d005..a39badd 100644 (file)
@@ -1,3 +1,18 @@
+2012-04-12  Simon Pena  <spena@igalia.com>
+
+        [GTK] Test runner crashes without recent versions of pulseaudio-utils
+        https://bugs.webkit.org/show_bug.cgi?id=83774
+
+        Reviewed by Philippe Normand.
+
+        Besides checking that pactl is available, check also that its output
+        is the expected one, and handle gracefully when it isn't, when
+        trying to unload pulseaudio modules.
+
+        * Scripts/webkitpy/layout_tests/port/gtk.py:
+        (GtkPort._unload_pulseaudio_module):
+        (GtkPort._restore_pulseaudio_module):
+
 2012-03-05  Pierre Rossi  <pierre.rossi@gmail.com>
 
         [Qt] Use QRawFont when building with Qt 5
index 70bbf10..71e5a3b 100644 (file)
@@ -84,6 +84,7 @@ class GtkPort(WebKitPort):
         with open(os.devnull, 'w') as devnull:
             try:
                 pactl_process = subprocess.Popen(["pactl", "list", "short", "modules"], stdout=subprocess.PIPE, stderr=devnull)
+                pactl_process.wait()
             except OSError:
                 # pactl might not be available.
                 _log.debug('pactl not found. Please install pulseaudio-utils to avoid some potential media test failures.')
@@ -91,17 +92,37 @@ class GtkPort(WebKitPort):
         modules_list = pactl_process.communicate()[0]
         for module in modules_list.splitlines():
             if module.find("module-stream-restore") >= 0:
-                self._pa_module_index = module.split('\t')[0]
-                break
-        if int(self._pa_module_index) != -1:
-            subprocess.Popen(["pactl", "unload-module", self._pa_module_index])
+                # Some pulseaudio-utils versions don't provide
+                # the index, just an empty string
+                self._pa_module_index = module.split('\t')[0] or -1
+                try:
+                    # Since they could provide other stuff (not an index
+                    # nor an empty string, let's make sure this is an int.
+                    if int(self._pa_module_index) != -1:
+                        pactl_process = subprocess.Popen(["pactl", "unload-module", self._pa_module_index])
+                        pactl_process.wait()
+                        if pactl_process.returncode == 0:
+                            _log.debug('Unloaded module-stream-restore successfully')
+                        else:
+                            _log.debug('Unloading module-stream-restore failed')
+                except ValueError:
+                        # pactl should have returned an index if the module is found
+                        _log.debug('Unable to parse module index. Please check if your pulseaudio-utils version is too old.')
+                return
 
     def _restore_pulseaudio_module(self):
         # If pulseaudio's module-stream-restore was previously unloaded,
-        # restore it back.
+        # restore it back. We shouldn't need extra checks here, since an
+        # index != -1 here means we successfully unloaded it previously.
         if self._pa_module_index != -1:
             with open(os.devnull, 'w') as devnull:
-                subprocess.Popen(["pactl", "load-module", "module-stream-restore"], stdout=devnull, stderr=devnull)
+                pactl_process = subprocess.Popen(["pactl", "load-module", "module-stream-restore"], stdout=devnull, stderr=devnull)
+                pactl_process.wait()
+                if pactl_process.returncode == 0:
+                    _log.debug('Restored module-stream-restore successfully')
+                else:
+                    _log.debug('Restoring module-stream-restore failed')
+
 
     def setup_test_run(self):
         self._unload_pulseaudio_module()