Title: [113969] trunk/Tools
Revision
113969
Author
[email protected]
Date
2012-04-12 06:33:24 -0700 (Thu, 12 Apr 2012)

Log Message

[GTK] Test runner crashes without recent versions of pulseaudio-utils
https://bugs.webkit.org/show_bug.cgi?id=83774

Patch by Simon Pena <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (113968 => 113969)


--- trunk/Tools/ChangeLog	2012-04-12 13:28:22 UTC (rev 113968)
+++ trunk/Tools/ChangeLog	2012-04-12 13:33:24 UTC (rev 113969)
@@ -1,3 +1,18 @@
+2012-04-12  Simon Pena  <[email protected]>
+
+        [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  <[email protected]>
 
         [Qt] Use QRawFont when building with Qt 5

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py (113968 => 113969)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py	2012-04-12 13:28:22 UTC (rev 113968)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py	2012-04-12 13:33:24 UTC (rev 113969)
@@ -84,6 +84,7 @@
         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,18 +92,38 @@
         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()
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to